MCPcopy Create free account
hub / github.com/cel-expr/cel-go / TestCheckInvalidOptSelectMember

Function TestCheckInvalidOptSelectMember

checker/checker_test.go:2808–2827  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2806}
2807
2808func TestCheckInvalidOptSelectMember(t *testing.T) {
2809 fac := ast.NewExprFactory()
2810 target := fac.NewStruct(1, "Foo", nil)
2811 arg1 := fac.NewStruct(2, "Foo", nil)
2812 arg2 := fac.NewLiteral(3, types.String("field"))
2813 call := fac.NewMemberCall(4, "_?._", target, arg1, arg2)
2814
2815 // This is not valid syntax, just for illustration purposes.
2816 src := common.NewTextSource("Foo{}._?._(Foo{}, 'field')")
2817 parsed := ast.NewAST(call, ast.NewSourceInfo(src))
2818 reg := newTestRegistry(t)
2819 env, err := NewEnv(containers.DefaultContainer, reg)
2820 if err != nil {
2821 t.Fatalf("NewEnv(cont, reg) failed: %v", err)
2822 }
2823 _, iss := Check(parsed, src, env)
2824 if !strings.Contains(iss.ToDisplayString(), "incorrect signature. member call") {
2825 t.Errorf("got %s, wanted 'incorrect signature. member call'", iss.ToDisplayString())
2826 }
2827}
2828
2829func TestCheckInvalidOptSelectMissingArg(t *testing.T) {
2830 fac := ast.NewExprFactory()

Callers

nothing calls this directly

Calls 13

NewStructMethod · 0.95
NewLiteralMethod · 0.95
NewMemberCallMethod · 0.95
NewExprFactoryFunction · 0.92
StringTypeAlias · 0.92
NewTextSourceFunction · 0.92
NewASTFunction · 0.92
NewSourceInfoFunction · 0.92
CheckFunction · 0.85
newTestRegistryFunction · 0.70
NewEnvFunction · 0.70
ContainsMethod · 0.65

Tested by

no test coverage detected