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

Function TestFrameParent

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

Source from the content-addressed store, hash-verified

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