From d93d598d0135d23928d9f3ac3440cf38e5594445 Mon Sep 17 00:00:00 2001 From: Frederic Jung Date: Sun, 1 Nov 2026 19:27:01 +0100 Subject: [PATCH] Tests count calendar months, not 30 days (#257) --- tests/speed.test.js | 4 ++-- tests/standing-orders.test.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/speed.test.js b/tests/speed.test.js index b3ac6f4..dc6a7d3 100644 --- a/tests/speed.test.js +++ b/tests/speed.test.js @@ -228,9 +228,9 @@ test('payday money floaters fade after a long pause instead of piling up', () => run(2000); assert.equal(ev('FLOATS.length'), 0, 'floaters from building the network have faded'); ev('UI.speed=0;__clk+=600000;frame(__clk)'); - ev('while(S.day%30!==29)dayTick();UI.speed=1;acc=DAY_MS'); + ev('while(cal(S.day+1).d!==1)dayTick();UI.speed=1;acc=DAY_MS'); run(16); - assert.equal(ev('S.day%30'), 0); + assert.equal(ev('cal(S.day).d'), 1, 'the first of a month'); assert.ok(ev('FLOATS.length') > 0, 'payday shows the money'); run(2000); assert.equal(ev('FLOATS.length'), 0, 'and it fades within two seconds of play'); diff --git a/tests/standing-orders.test.js b/tests/standing-orders.test.js index 6b6cce6..4d2defa 100644 --- a/tests/standing-orders.test.js +++ b/tests/standing-orders.test.js @@ -193,7 +193,7 @@ test('the monthly budget cap and the cash floor stop the intern; a new month res shift(ev); assert.equal(cash(ev), c1, 'the same month: nothing more'); // The next step (four 100G members to 400G, $16k) never fits a $10k month; the budget still starts again. - ev('S.day+=30;S.ops.cap.transit=50000'); + ev('S.day+=monLen(S.day);S.ops.cap.transit=50000'); shift(ev); assert.ok(cash(ev) < c1, 'a new month, a new budget'); assert.equal(ev('S.ops.spent.transit'), c1 - cash(ev), 'counted from zero'); @@ -545,7 +545,7 @@ test('caches: the cash floor and a running-cost budget hold; the panel and the l assert.match(txt, /each box costs \$400\/mo/); assert.match(txt, /Adds at most: \+\$1\.0k\/mo/); assert.match(txt, /This month: \$0 up front, \+\$800\/mo on the bill/); - ev('S.day+=30;S.ops.cap.caches=0'); shift(ev); + ev('S.day+=monLen(S.day);S.ops.cap.caches=0'); shift(ev); assert.equal(ev('S.ops.addMo.caches'), (ev('S.caches.length') - 2) * 400, 'a new month counts from zero'); assert.deepEqual(errors, []); });