(t *testing.T)
| 381 | } |
| 382 | |
| 383 | func TestFrameLifecycleAndPooling(t *testing.T) { |
| 384 | vars := map[string]any{"a": 1, "b": 2} |
| 385 | frame := mustNewExecutionFrame(t, vars) |
| 386 | val, found := frame.ResolveName("a") |
| 387 | if !found || val != 1 { |
| 388 | t.Errorf("ResolveName('a') got %v, %t; want 1, true", val, found) |
| 389 | } |
| 390 | |
| 391 | // Wrap in a hierarchical activation (e.g. simulating defaultVars setup in program.go) |
| 392 | parentAct, err := NewActivation(map[string]any{"c": 3}) |
| 393 | if err != nil { |
| 394 | t.Fatalf("NewActivation failed: %v", err) |
| 395 | } |
| 396 | frame.Activation = NewHierarchicalActivation(parentAct, frame.Activation) |
| 397 | |
| 398 | val, found = frame.ResolveName("c") |
| 399 | if !found || val != 3 { |
| 400 | t.Errorf("ResolveName('c') got %v, %t; want 3, true", val, found) |
| 401 | } |
| 402 | |
| 403 | val, found = frame.ResolveName("a") |
| 404 | if !found || val != 1 { |
| 405 | t.Errorf("ResolveName('a') got %v, %t; want 1, true", val, found) |
| 406 | } |
| 407 | |
| 408 | // Close the frame. This should release the pooled evalActivation under the hierarchical activation. |
| 409 | frame.Close() |
| 410 | |
| 411 | // Verify that we can obtain a clean frame from the pool. |
| 412 | newFrame := mustNewExecutionFrame(t, map[string]any{"x": 10}) |
| 413 | defer newFrame.Close() |
| 414 | val, found = newFrame.ResolveName("x") |
| 415 | if !found || val != 10 { |
| 416 | t.Errorf("ResolveName('x') got %v, %t; want 10, true", val, found) |
| 417 | } |
| 418 | val, found = newFrame.ResolveName("a") |
| 419 | if found { |
| 420 | t.Errorf("ResolveName('a') found on fresh frame: %v", val) |
| 421 | } |
| 422 | } |
| 423 | |
| 424 | func TestFrameSetContext(t *testing.T) { |
| 425 | ctx := context.Background() |
nothing calls this directly
no test coverage detected