| 591 | } |
| 592 | } |
| 593 | if !sawTask { |
| 594 | t.Fatalf("original task must stay anchored even when a nudge is the newest message: %+v", r.Messages) |
| 595 | } |
| 596 | } |
| 597 | |
| 598 | func TestBudget(t *testing.T) { |
| 599 | // Reference the constants directly so a future FixedSystem/FixedTools/headroom |
| 600 | // tweak doesn't trip a magic-number mismatch absent a real regression. |
| 601 | // 65k: ctxSize/8 = 8192, just above the 8k floor. |
| 602 | if raw := 65536 - FixedSystem - FixedTools - 8192; Budget(65536) != raw-raw/budgetHeadroomDivisor { |
| 603 | t.Fatalf("budget wrong at 65k: %d", Budget(65536)) |
| 604 | } |
| 605 | // 262k: ctxSize/8 = 32768, matches a common thinking-mode default. |
| 606 | if raw := 262144 - FixedSystem - FixedTools - 32768; Budget(262144) != raw-raw/budgetHeadroomDivisor { |
| 607 | t.Fatalf("budget wrong at 262k: %d", Budget(262144)) |
| 608 | } |
| 609 | if Budget(1000) != 0 { |
| 610 | t.Fatal("budget must floor at 0") |