(t *testing.T)
| 526 | } |
| 527 | |
| 528 | func TestFunctionDisableDeclaration(t *testing.T) { |
| 529 | e, err := NewCustomEnv( |
| 530 | Function("disabled", |
| 531 | DisableDeclaration(true), |
| 532 | Overload("disabled_any", []*Type{BoolType}, BoolType), |
| 533 | SingletonFunctionImpl(func(args ...ref.Val) ref.Val { |
| 534 | return types.True |
| 535 | }), |
| 536 | ), |
| 537 | ) |
| 538 | if err != nil { |
| 539 | t.Fatalf("NewCustomEnv() failed: %v", err) |
| 540 | } |
| 541 | ast, iss := e.Parse("disabled(true)") |
| 542 | if iss.Err() != nil { |
| 543 | t.Errorf("Parse(disabled(true)) failed: %v", iss.Err()) |
| 544 | } |
| 545 | prg, err := e.Program(ast) |
| 546 | if err != nil { |
| 547 | t.Fatalf("Program(ast) failed: %v", err) |
| 548 | } |
| 549 | out, _, err := prg.Eval(NoVars()) |
| 550 | if err != nil { |
| 551 | t.Errorf("disabled runtime binding missing: %v", err) |
| 552 | } else if out != types.True { |
| 553 | t.Errorf("disabled runtime binding failed: %v", out) |
| 554 | } |
| 555 | _, iss = e.Compile("disabled(true)") |
| 556 | if iss.Err() == nil || !strings.Contains(iss.Err().Error(), "undeclared reference to 'disabled'") { |
| 557 | t.Errorf("Compile(disabled(true)) got an unexpected error: %v", iss.Err()) |
| 558 | } |
| 559 | } |
| 560 | |
| 561 | func TestFunctionDisableDeclarationMerge(t *testing.T) { |
| 562 | e, err := NewCustomEnv( |
nothing calls this directly
no test coverage detected