(t *testing.T)
| 263 | } |
| 264 | |
| 265 | func TestSingletonUnaryBindingParameterized(t *testing.T) { |
| 266 | // Test the case where the singleton unary impl is merged with the earlier declaration. |
| 267 | e, err := NewCustomEnv( |
| 268 | Variable("x", AnyType), |
| 269 | Function("isSorted", MemberOverload("list_int_is_sorted", []*Type{ListType(IntType)}, BoolType)), |
| 270 | Function("isSorted", MemberOverload("list_uint_is_sorted", []*Type{ListType(UintType)}, BoolType), |
| 271 | SingletonUnaryBinding(func(arg ref.Val) ref.Val { return types.True })), |
| 272 | ) |
| 273 | if err != nil { |
| 274 | t.Errorf("NewCustomEnv() failed: %v", err) |
| 275 | } |
| 276 | ast, iss := e.Parse("x.isSorted()") |
| 277 | if iss.Err() != nil { |
| 278 | t.Fatalf("Parse('x.isSorted()') failed: %v", iss.Err()) |
| 279 | } |
| 280 | prg, err := e.Program(ast) |
| 281 | if err != nil { |
| 282 | t.Fatalf("Program() failed: %v", err) |
| 283 | } |
| 284 | out, _, err := prg.Eval(map[string]any{"x": []int{1, 2, 3}}) |
| 285 | if err != nil { |
| 286 | t.Errorf("prg.Eval(x=[1,2,3]) failed: %v", err) |
| 287 | } |
| 288 | if out != types.True { |
| 289 | t.Errorf("Eval got %v, wanted true", out) |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | func TestSingletonBinaryBinding(t *testing.T) { |
| 294 | _, err := NewCustomEnv( |
nothing calls this directly
no test coverage detected