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

Function TestFrameResolveName

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

Source from the content-addressed store, hash-verified

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