(t *testing.T)
| 271 | } |
| 272 | |
| 273 | func TestFrameAsPartialActivation(t *testing.T) { |
| 274 | baseAct, err := NewActivation(map[string]any{"x": 1}) |
| 275 | if err != nil { |
| 276 | t.Fatalf("NewActivation(x) failed: %v", err) |
| 277 | } |
| 278 | partAct, err := NewPartialActivation(map[string]any{"y": 2}) |
| 279 | if err != nil { |
| 280 | t.Fatalf("NewPartialActivation(y) failed: %v", err) |
| 281 | } |
| 282 | |
| 283 | tests := []struct { |
| 284 | name string |
| 285 | setup func() *ExecutionFrame |
| 286 | wantFound bool |
| 287 | }{ |
| 288 | { |
| 289 | name: "non-partial activation returns false", |
| 290 | setup: func() *ExecutionFrame { |
| 291 | return mustNewExecutionFrame(t, baseAct) |
| 292 | }, |
| 293 | wantFound: false, |
| 294 | }, |
| 295 | { |
| 296 | name: "partial activation returns true", |
| 297 | setup: func() *ExecutionFrame { |
| 298 | return mustNewExecutionFrame(t, partAct) |
| 299 | }, |
| 300 | wantFound: true, |
| 301 | }, |
| 302 | { |
| 303 | name: "hierarchical activation wrapping partial activation returns true", |
| 304 | setup: func() *ExecutionFrame { |
| 305 | f := mustNewExecutionFrame(t, partAct) |
| 306 | return f.Push(baseAct) |
| 307 | }, |
| 308 | wantFound: true, |
| 309 | }, |
| 310 | } |
| 311 | |
| 312 | for _, tc := range tests { |
| 313 | t.Run(tc.name, func(t *testing.T) { |
| 314 | frame := tc.setup() |
| 315 | defer func() { |
| 316 | curr := frame |
| 317 | for curr.parent != nil { |
| 318 | curr = curr.Pop() |
| 319 | } |
| 320 | curr.Close() |
| 321 | }() |
| 322 | |
| 323 | gotAct, gotFound := frame.AsPartialActivation() |
| 324 | if gotFound != tc.wantFound { |
| 325 | t.Errorf("AsPartialActivation() got found=%t, want found=%t", gotFound, tc.wantFound) |
| 326 | } |
| 327 | if tc.wantFound && gotAct == nil { |
| 328 | t.Errorf("AsPartialActivation() returned nil for found partial activation") |
| 329 | } |
| 330 | }) |
nothing calls this directly
no test coverage detected