evalCostAndState evaluates the ast and reports the tracked cost along with whether evaluation state was recorded.
(t *testing.T, env *Env, ast *Ast, opts ...ProgramOption)
| 1724 | // evalCostAndState evaluates the ast and reports the tracked cost along with whether evaluation |
| 1725 | // state was recorded. |
| 1726 | func evalCostAndState(t *testing.T, env *Env, ast *Ast, opts ...ProgramOption) (uint64, bool) { |
| 1727 | t.Helper() |
| 1728 | prg, err := env.Program(ast, opts...) |
| 1729 | if err != nil { |
| 1730 | t.Fatalf("env.Program() failed: %v", err) |
| 1731 | } |
| 1732 | _, det, err := prg.Eval(map[string]any{"a": "xyz-abcdefghij"}) |
| 1733 | if err != nil { |
| 1734 | t.Fatalf("prg.Eval() failed: %v", err) |
| 1735 | } |
| 1736 | cost := det.ActualCost() |
| 1737 | if cost == nil { |
| 1738 | t.Fatalf("det.ActualCost() returned nil") |
| 1739 | } |
| 1740 | state := det.State() |
| 1741 | return *cost, state != nil && len(state.IDs()) != 0 |
| 1742 | } |
| 1743 | |
| 1744 | func TestParseError(t *testing.T) { |
| 1745 | env := testEnv(t) |
no test coverage detected