From 0526541133e1d4cc2c4b7f291897734b120e7ebc Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Wed, 16 Sep 2026 19:42:30 +0200 Subject: test: make the layout assertion actually able to fail The out-of-grid check iterated `G.layout or {}`. With layout unexported that walks an empty table, so the block passed vacuously and the test could never detect the very condition it existed to check. Confirmed by unexporting layout and watching the suite still pass. Drops the fallback and asserts the export first. Verified by mutation: unexporting layout now fails with "dashboard.lua must export layout", and moving the clock to col=5 fails with "layout entry out of columns", so both paths have teeth. The plan's Step 3 expected a failure that could not happen; it now says what the failure looks like and warns that a pass there means the test is broken rather than the code. Co-Authored-By: Claude Opus 5 --- test/test_layout.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/test_layout.lua b/test/test_layout.lua index f3f47e3..976f78f 100644 --- a/test/test_layout.lua +++ b/test/test_layout.lua @@ -50,7 +50,12 @@ assert(math.abs(span.w - (a.w * 2 + G.GAP)) < 0.01, 'span must absorb the gap') -- The shipped layout must not place anything outside the declared grid, which -- is the mistake a user editing the table will actually make. -for _, e in ipairs(G.layout or {}) do +-- +-- No `or {}` fallback here: with one, an unexported layout makes ipairs walk an +-- empty table and the whole block passes vacuously, which is exactly the bug +-- this assertion is supposed to catch. +assert(G.layout, 'dashboard.lua must export layout') +for _, e in ipairs(G.layout) do assert(e.col >= 1 and e.col + (e.w or 1) - 1 <= G.COLS, 'layout entry out of columns: ' .. tostring(e.widget)) assert(e.row >= 1 and e.row + (e.h or 1) - 1 <= G.ROWS, -- cgit v1.2.3