(t *testing.T)
| 114 | } |
| 115 | |
| 116 | func TestMemoryTrackingConcurrentEval(t *testing.T) { |
| 117 | env := testEnv(t, Variable("a", ListType(IntType))) |
| 118 | ast, iss := env.Compile(`a + a`) |
| 119 | if iss.Err() != nil { |
| 120 | t.Fatalf("env.Compile() failed: %v", iss.Err()) |
| 121 | } |
| 122 | program, err := env.Program(ast, MemoryTracking()) |
| 123 | if err != nil { |
| 124 | t.Fatalf("env.Program() failed: %v", err) |
| 125 | } |
| 126 | ctx, cancel := context.WithCancel(context.Background()) |
| 127 | defer cancel() |
| 128 | res := <-program.ConcurrentEval(ctx, map[string]any{"a": []int64{1, 2}}) |
| 129 | if res.Err != nil { |
| 130 | t.Fatalf("program.ConcurrentEval() failed: %v", res.Err) |
| 131 | } |
| 132 | peak := res.EvalDetails.PeakMemory() |
| 133 | if peak == nil { |
| 134 | t.Fatal("EvalDetails.PeakMemory() got nil, wanted non-nil peak") |
| 135 | } |
| 136 | if *peak != 6 { |
| 137 | t.Errorf("EvalDetails.PeakMemory() got %d, wanted 6", *peak) |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | func TestMemoryTrackingDisabled(t *testing.T) { |
| 142 | env := testEnv(t, Variable("a", ListType(IntType))) |
nothing calls this directly
no test coverage detected