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

Function TestCopyDeclarations

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 10

ParseMethod · 0.95
NewTextSourceFunction · 0.92
NewParserFunction · 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