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

Function TestFrameResolveName

interpreter/frame_test.go:115–199  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

113}
114
115func TestFrameResolveName(t *testing.T) {
116 baseAct, err := NewActivation(map[string]any{"x": 1})
117 if err != nil {
118 t.Fatalf("NewActivation(x) failed: %v", err)
119 }
120 childAct, err := NewActivation(map[string]any{"y": 2})
121 if err != nil {
122 t.Fatalf("NewActivation(y) failed: %v", err)
123 }
124
125 tests := []struct {
126 name string
127 setup func() *ExecutionFrame
128 varName string
129 wantVal any
130 wantFound bool
131 }{
132 {
133 name: "resolve in base activation",
134 setup: func() *ExecutionFrame {
135 return mustNewExecutionFrame(t, baseAct)
136 },
137 varName: "x",
138 wantVal: 1,
139 wantFound: true,
140 },
141 {
142 name: "missing in base activation",
143 setup: func() *ExecutionFrame {
144 return mustNewExecutionFrame(t, baseAct)
145 },
146 varName: "y",
147 wantVal: nil,
148 wantFound: false,
149 },
150 {
151 name: "resolve in child activation",
152 setup: func() *ExecutionFrame {
153 f := mustNewExecutionFrame(t, baseAct)
154 return f.Push(childAct)
155 },
156 varName: "y",
157 wantVal: 2,
158 wantFound: true,
159 },
160 {
161 name: "resolve in parent activation from child",
162 setup: func() *ExecutionFrame {
163 f := mustNewExecutionFrame(t, baseAct)
164 return f.Push(childAct)
165 },
166 varName: "x",
167 wantVal: 1,
168 wantFound: true,
169 },
170 {
171 name: "missing in hierarchical activation",
172 setup: func() *ExecutionFrame {

Callers

nothing calls this directly

Calls 7

mustNewExecutionFrameFunction · 0.85
setupMethod · 0.80
CloseMethod · 0.80
NewActivationFunction · 0.70
ResolveNameMethod · 0.65
PushMethod · 0.45
PopMethod · 0.45

Tested by

no test coverage detected