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

Function TestCopyDeclarations

checker/env_test.go:44–65  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

42}
43
44func TestCopyDeclarations(t *testing.T) {
45 src := common.NewTextSource(`1 + 2 != 3 - 4`)
46 parsedAst, errors := parser.Parse(src)
47 if len(errors.GetErrors()) > 0 {
48 t.Fatalf("Unexpected parse errors: %v", errors.ToDisplayString())
49 }
50
51 env := newStdEnv(t)
52 _, errors = Check(parsedAst, src, env)
53 if len(errors.GetErrors()) > 0 {
54 t.Fatalf("Check(parsedAst, src, env): %v", errors.ToDisplayString())
55 }
56
57 copy, err := NewEnv(containers.DefaultContainer, newTestRegistry(t), ValidatedDeclarations(env))
58 if err != nil {
59 t.Fatalf("NewEnv(container, registry, CopyDeclarations(env)) failed %v: ", err)
60 }
61 _, errors = Check(parsedAst, src, copy)
62 if len(errors.GetErrors()) > 0 {
63 t.Fatalf("Check(parsedAst, src, copy): %v", errors.ToDisplayString())
64 }
65}
66
67func BenchmarkNewStdEnv(b *testing.B) {
68 for i := 0; i < b.N; i++ {

Callers

nothing calls this directly

Calls 9

NewTextSourceFunction · 0.92
ParseFunction · 0.92
newStdEnvFunction · 0.85
CheckFunction · 0.85
ValidatedDeclarationsFunction · 0.85
GetErrorsMethod · 0.80
NewEnvFunction · 0.70
newTestRegistryFunction · 0.70
ToDisplayStringMethod · 0.45

Tested by

no test coverage detected