diff options
| author | ruki <[email protected]> | 2026-04-15 00:56:47 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2026-04-15 00:56:47 +0800 |
| commit | dbed1aee901ec9cbb22b45ff22bb112cc0c26c0a (patch) | |
| tree | 55dd2c42312e512cd80f34f88cdda35b8bf3486a /tests | |
| parent | 03133fa624c9f27554b0c393e9151213cc99996e (diff) | |
fix test
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/modules/for_loop/test.lua | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/tests/modules/for_loop/test.lua b/tests/modules/for_loop/test.lua index 42217ed40..51d5f075a 100644 --- a/tests/modules/for_loop/test.lua +++ b/tests/modules/for_loop/test.lua @@ -31,13 +31,23 @@ import("core.base.list") import("core.base.hashset") function test_numeric_for_reassign(t) - -- Just needs to compile & run without "attempt to assign to const". - local sum = 0 + -- The point of this test is purely compile-time: without the + -- RDKCONST->VDKREG replace in core/src/lua/xmake.lua the write to + -- `i` would raise "attempt to assign to const variable" and this + -- file wouldn't even parse. + -- + -- We do NOT assert on the value of `i` during iteration. Lua 5.4 + -- merges the numeric-for control slot with the user's first loop + -- variable while 5.5 splits them, so the observable sequence of + -- `i` values after a reassignment differs between versions. The + -- iteration count lives in its own slot and stays stable, so that + -- is what we pin. + local n = 0 for i = 1, 5 do i = i * 10 - sum = sum + i + n = n + 1 end - t:require(sum == 10 + 20 + 30 + 40 + 50) + t:require(n == 5) end function test_generic_for_reassign_key(t) |
