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

Function TestAddEquivalentDeclarations

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

Source from the content-addressed store, hash-verified

2742}
2743
2744func TestAddEquivalentDeclarations(t *testing.T) {
2745 reg, err := types.NewProtoRegistry(types.ProtoTypeDefs(&proto2pb.TestAllTypes{}, &proto3pb.TestAllTypes{}))
2746 if err != nil {
2747 t.Fatalf("types.NewProtoRegistry() failed: %v", err)
2748 }
2749 env, err := NewEnv(containers.DefaultContainer, reg, CrossTypeNumericComparisons(true))
2750 if err != nil {
2751 t.Fatalf("NewEnv() failed: %v", err)
2752 }
2753 optIndex := testFunction(t, "optional_index",
2754 decls.Overload("optional_map_key_value",
2755 []*types.Type{
2756 types.NewMapType(types.NewTypeParamType("K"), types.NewTypeParamType("V")),
2757 types.NewTypeParamType("K")},
2758 types.NewOptionalType(types.NewTypeParamType("V"))))
2759 optIndexEquiv := testFunction(t, "optional_index",
2760 decls.Overload("optional_map_key_value",
2761 []*types.Type{
2762 types.NewMapType(types.NewTypeParamType("K"), types.NewTypeParamType("V")),
2763 types.NewTypeParamType("K")},
2764 types.NewOptionalType(types.NewTypeParamType("V"))))
2765 err = env.AddFunctions(optIndex)
2766 if err != nil {
2767 t.Fatalf("env.Add(optIndex) failed: %v", err)
2768 }
2769 err = env.AddFunctions(optIndexEquiv)
2770 if err != nil {
2771 t.Errorf("env.Add(optIndexEquiv) failed: %v", err)
2772 }
2773}
2774
2775func TestCheckErrorData(t *testing.T) {
2776 p, err := parser.NewParser(

Callers

nothing calls this directly

Calls 10

AddFunctionsMethod · 0.95
NewProtoRegistryFunction · 0.92
ProtoTypeDefsFunction · 0.92
OverloadFunction · 0.92
NewMapTypeFunction · 0.92
NewTypeParamTypeFunction · 0.92
NewOptionalTypeFunction · 0.92
NewEnvFunction · 0.70
testFunctionFunction · 0.70

Tested by

no test coverage detected