(t *testing.T)
| 88 | } |
| 89 | |
| 90 | func TestMemoryTrackingComprehension(t *testing.T) { |
| 91 | env := testEnv(t, Variable("a", ListType(IntType))) |
| 92 | ast, iss := env.Compile(`a.map(x, x * 2)`) |
| 93 | if iss.Err() != nil { |
| 94 | t.Fatalf("env.Compile() failed: %v", iss.Err()) |
| 95 | } |
| 96 | program, err := env.Program(ast, MemoryTracking()) |
| 97 | if err != nil { |
| 98 | t.Fatalf("env.Program() failed: %v", err) |
| 99 | } |
| 100 | in := map[string]any{"a": []int64{1, 2, 3, 4, 5}} |
| 101 | _, details, err := program.Eval(in) |
| 102 | if err != nil { |
| 103 | t.Fatalf("program.Eval() failed: %v", err) |
| 104 | } |
| 105 | peak := details.PeakMemory() |
| 106 | if peak == nil { |
| 107 | t.Fatal("EvalDetails.PeakMemory() got nil, wanted non-nil peak") |
| 108 | } |
| 109 | // The comprehension result is 1 (container) + 5 elements; the peak must be at least as |
| 110 | // large since the final accumulation observes the input alongside the built list. |
| 111 | if *peak < 6 { |
| 112 | t.Errorf("EvalDetails.PeakMemory() got %d, wanted at least 6", *peak) |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | func TestMemoryTrackingConcurrentEval(t *testing.T) { |
| 117 | env := testEnv(t, Variable("a", ListType(IntType))) |
nothing calls this directly
no test coverage detected