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

Function TestCheckInvalidOptSelectMember

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

Source from the content-addressed store, hash-verified

2848}
2849
2850func TestCheckInvalidOptSelectMember(t *testing.T) {
2851 fac := ast.NewExprFactory()
2852 target := fac.NewStruct(1, "Foo", nil)
2853 arg1 := fac.NewStruct(2, "Foo", nil)
2854 arg2 := fac.NewLiteral(3, types.String("field"))
2855 call := fac.NewMemberCall(4, "_?._", target, arg1, arg2)
2856
2857 // This is not valid syntax, just for illustration purposes.
2858 src := common.NewTextSource("Foo{}._?._(Foo{}, 'field')")
2859 parsed := ast.NewAST(call, ast.NewSourceInfo(src))
2860 reg := newTestRegistry(t)
2861 env, err := NewEnv(containers.DefaultContainer, reg)
2862 if err != nil {
2863 t.Fatalf("NewEnv(cont, reg) failed: %v", err)
2864 }
2865 _, iss := Check(parsed, src, env)
2866 if !strings.Contains(iss.ToDisplayString(), "incorrect signature. member call") {
2867 t.Errorf("got %s, wanted 'incorrect signature. member call'", iss.ToDisplayString())
2868 }
2869}
2870
2871func TestCheckInvalidOptSelectMissingArg(t *testing.T) {
2872 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