(t *testing.T)
| 596 | } |
| 597 | |
| 598 | func TestFunctionDisableDeclarationMergeReenable(t *testing.T) { |
| 599 | e, err := NewCustomEnv( |
| 600 | Function("enabled", |
| 601 | DisableDeclaration(true), |
| 602 | Overload("enabled_any", []*Type{BoolType}, BoolType), |
| 603 | ), |
| 604 | // Ensure the previously disabled declaration is enabled |
| 605 | Function("enabled", |
| 606 | DisableDeclaration(false), |
| 607 | Overload("enabled_any", []*Type{BoolType}, BoolType, |
| 608 | FunctionBinding(func(args ...ref.Val) ref.Val { |
| 609 | return types.True |
| 610 | })), |
| 611 | ), |
| 612 | ) |
| 613 | if err != nil { |
| 614 | t.Fatalf("NewCustomEnv() failed: %v", err) |
| 615 | } |
| 616 | ast, iss := e.Parse("enabled(true)") |
| 617 | if iss.Err() != nil { |
| 618 | t.Errorf("Parse(enabled(true)) failed: %v", iss.Err()) |
| 619 | } |
| 620 | prg, err := e.Program(ast) |
| 621 | if err != nil { |
| 622 | t.Fatalf("Program(ast) failed: %v", err) |
| 623 | } |
| 624 | out, _, err := prg.Eval(NoVars()) |
| 625 | if err != nil { |
| 626 | t.Errorf("enabled runtime binding missing: %v", err) |
| 627 | } else if out != types.True { |
| 628 | t.Errorf("enabled runtime binding failed: %v", out) |
| 629 | } |
| 630 | _, iss = e.Compile("enabled(true)") |
| 631 | if iss.Err() != nil { |
| 632 | t.Errorf("Compile(enabled(true)) got an unexpected error: %v", iss.Err()) |
| 633 | } |
| 634 | } |
| 635 | |
| 636 | func TestExprDeclToDeclaration(t *testing.T) { |
| 637 | paramT := chkdecls.NewTypeParamType("T") |
nothing calls this directly
no test coverage detected