(t *testing.T)
| 399 | } |
| 400 | |
| 401 | func TestFrameLifecycleAndPooling(t *testing.T) { |
| 402 | vars := map[string]any{"a": 1, "b": 2} |
| 403 | frame := mustNewExecutionFrame(t, vars) |
| 404 | val, found := frame.ResolveName("a") |
| 405 | if !found || val != 1 { |
| 406 | t.Errorf("ResolveName('a') got %v, %t; want 1, true", val, found) |
| 407 | } |
| 408 | |
| 409 | // Wrap in a hierarchical activation (e.g. simulating defaultVars setup in program.go) |
| 410 | parentAct, err := NewActivation(map[string]any{"c": 3}) |
| 411 | if err != nil { |
| 412 | t.Fatalf("NewActivation failed: %v", err) |
| 413 | } |
| 414 | if err := frame.SetDefaultVars(parentAct); err != nil { |
| 415 | t.Fatalf("SetDefaultVars failed: %v", err) |
| 416 | } |
| 417 | |
| 418 | val, found = frame.ResolveName("c") |
| 419 | if !found || val != 3 { |
| 420 | t.Errorf("ResolveName('c') got %v, %t; want 3, true", val, found) |
| 421 | } |
| 422 | |
| 423 | val, found = frame.ResolveName("a") |
| 424 | if !found || val != 1 { |
| 425 | t.Errorf("ResolveName('a') got %v, %t; want 1, true", val, found) |
| 426 | } |
| 427 | |
| 428 | // Close the frame. This should release the pooled evalActivation under the hierarchical activation. |
| 429 | frame.Close() |
| 430 | |
| 431 | // Verify that we can obtain a clean frame from the pool. |
| 432 | newFrame := mustNewExecutionFrame(t, map[string]any{"x": 10}) |
| 433 | defer newFrame.Close() |
| 434 | val, found = newFrame.ResolveName("x") |
| 435 | if !found || val != 10 { |
| 436 | t.Errorf("ResolveName('x') got %v, %t; want 10, true", val, found) |
| 437 | } |
| 438 | val, found = newFrame.ResolveName("a") |
| 439 | if found { |
| 440 | t.Errorf("ResolveName('a') found on fresh frame: %v", val) |
| 441 | } |
| 442 | } |
| 443 | |
| 444 | func TestFrameSetContext(t *testing.T) { |
| 445 | ctx := context.Background() |
nothing calls this directly
no test coverage detected