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)
| 1752 | // evalCostAndState evaluates the ast and reports the tracked cost along with whether evaluation |
| 1753 | // state was recorded. |
| 1754 | func evalCostAndState(t *testing.T, env *Env, ast *Ast, opts ...ProgramOption) (uint64, bool) { |
| 1755 | t.Helper() |
| 1756 | prg, err := env.Program(ast, opts...) |
| 1757 | if err != nil { |
| 1758 | t.Fatalf("env.Program() failed: %v", err) |
| 1759 | } |
| 1760 | _, det, err := prg.Eval(map[string]any{"a": "xyz-abcdefghij"}) |
| 1761 | if err != nil { |
| 1762 | t.Fatalf("prg.Eval() failed: %v", err) |
| 1763 | } |
| 1764 | cost := det.ActualCost() |
| 1765 | if cost == nil { |
| 1766 | t.Fatalf("det.ActualCost() returned nil") |
| 1767 | } |
| 1768 | state := det.State() |
| 1769 | return *cost, state != nil && len(state.IDs()) != 0 |
| 1770 | } |
| 1771 | |
| 1772 | func TestParseError(t *testing.T) { |
| 1773 | env := testEnv(t) |
no test coverage detected