TestCostModelValidation covers rejection of a model whose projection has no runtime counterpart. Environment construction is the last point at which such a model can be reported.
(t *testing.T)
| 5776 | // TestCostModelValidation covers rejection of a model whose projection has no runtime counterpart. |
| 5777 | // Environment construction is the last point at which such a model can be reported. |
| 5778 | func TestCostModelValidation(t *testing.T) { |
| 5779 | _, err := NewEnv(CostModel( |
| 5780 | cost.Overload(overloads.InList, cost.EvalCost(cost.ElemOf(cost.Const(3)))), |
| 5781 | )) |
| 5782 | if err == nil { |
| 5783 | t.Fatal("NewEnv() succeeded, wanted the unanswerable projection reported") |
| 5784 | } |
| 5785 | if !strings.Contains(err.Error(), "ElemOf is not defined over Const") { |
| 5786 | t.Errorf("NewEnv() errored: %v, wanted the unanswerable projection reported", err) |
| 5787 | } |
| 5788 | } |
| 5789 | |
| 5790 | // TestCostModelValueProjections charges an element projection through a real evaluation. The two |
| 5791 | // lists have the same length and the same number of literals, so every other term in the total is |