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

Function TestFrameParent

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

Source from the content-addressed store, hash-verified

199}
200
201func TestFrameParent(t *testing.T) {
202 baseAct, err := NewActivation(map[string]any{"x": 1})
203 if err != nil {
204 t.Fatalf("NewActivation(x) failed: %v", err)
205 }
206 childAct, err := NewActivation(map[string]any{"y": 2})
207 if err != nil {
208 t.Fatalf("NewActivation(y) failed: %v", err)
209 }
210
211 tests := []struct {
212 name string
213 setup func() (*ExecutionFrame, func())
214 want Activation
215 }{
216 {
217 name: "base frame has no parent activation",
218 setup: func() (*ExecutionFrame, func()) {
219 f := mustNewExecutionFrame(t, baseAct)
220 return f, func() { f.Close() }
221 },
222 want: nil,
223 },
224 {
225 name: "pushed frame returns parent activation",
226 setup: func() (*ExecutionFrame, func()) {
227 f := mustNewExecutionFrame(t, baseAct)
228 child := f.Push(childAct)
229 return child, func() {
230 child.Pop()
231 f.Close()
232 }
233 },
234 want: baseAct,
235 },
236 }
237
238 for _, tc := range tests {
239 t.Run(tc.name, func(t *testing.T) {
240 frame, cleanup := tc.setup()
241 defer cleanup()
242
243 if got := frame.Parent(); got != tc.want {
244 t.Errorf("Parent() got %v, want %v", got, tc.want)
245 }
246 })
247 }
248}
249
250func TestFrameUnwrap(t *testing.T) {
251 baseAct, err := NewActivation(map[string]any{"x": 1})

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected