(t *testing.T)
| 198 | } |
| 199 | |
| 200 | func 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 | |
| 249 | func TestFrameUnwrap(t *testing.T) { |
| 250 | baseAct, err := NewActivation(map[string]any{"x": 1}) |
nothing calls this directly
no test coverage detected