diff options
| -rw-r--r-- | docs/superpowers/plans/2026-09-16-conky-lua-dashboard.md | 14 | ||||
| -rw-r--r-- | test/test_layout.lua | 7 |
2 files changed, 18 insertions, 3 deletions
diff --git a/docs/superpowers/plans/2026-09-16-conky-lua-dashboard.md b/docs/superpowers/plans/2026-09-16-conky-lua-dashboard.md index a77c30b..c57bcbc 100644 --- a/docs/superpowers/plans/2026-09-16-conky-lua-dashboard.md +++ b/docs/superpowers/plans/2026-09-16-conky-lua-dashboard.md @@ -1134,7 +1134,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, @@ -1148,7 +1153,12 @@ print('test_layout: all assertions passed') Run: `cd ~/Programming/GIT/conky-theme-udt && lua test/test_layout.lua` -Expected: failure. The last block reads `G.layout`, which Step 1 did not export. +Expected: failure with `dashboard.lua must export layout`. The last block +asserts on `G.layout`, which Step 1 deliberately did not export. + +If this run PASSES, the test is broken, not the code: an `ipairs(G.layout or {})` +would walk an empty table and pass vacuously. Check the assertion is there +before continuing. - [ ] **Step 4: Export the layout too** 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, |
