aboutsummaryrefslogtreecommitdiff
path: root/testes
diff options
context:
space:
mode:
Diffstat (limited to 'testes')
-rw-r--r--testes/locals.lua18
1 files changed, 14 insertions, 4 deletions
diff --git a/testes/locals.lua b/testes/locals.lua
index 50230a27..0de00a98 100644
--- a/testes/locals.lua
+++ b/testes/locals.lua
@@ -177,14 +177,24 @@ do -- constants
177 local <const> a, b, <const> c = 10, 20, 30 177 local <const> a, b, <const> c = 10, 20, 30
178 b = a + c + b -- 'b' is not constant 178 b = a + c + b -- 'b' is not constant
179 assert(a == 10 and b == 60 and c == 30) 179 assert(a == 10 and b == 60 and c == 30)
180 local function checkro (code, name) 180 local function checkro (name, code)
181 local st, msg = load(code) 181 local st, msg = load(code)
182 local gab = string.format("attempt to assign to const variable '%s'", name) 182 local gab = string.format("attempt to assign to const variable '%s'", name)
183 assert(not st and string.find(msg, gab)) 183 assert(not st and string.find(msg, gab))
184 end 184 end
185 checkro("local x, <const> y, z = 10, 20, 30; x = 11; y = 12", "y") 185 checkro("y", "local x, <const> y, z = 10, 20, 30; x = 11; y = 12")
186 checkro("local <const> x, y, <const> z = 10, 20, 30; x = 11", "x") 186 checkro("x", "local <const> x, y, <const> z = 10, 20, 30; x = 11")
187 checkro("local <const> x, y, <const> z = 10, 20, 30; y = 10; z = 11", "z") 187 checkro("z", "local <const> x, y, <const> z = 10, 20, 30; y = 10; z = 11")
188
189 checkro("z", [[
190 local a, <const> z, b = 10;
191 function foo() a = 20; z = 32; end
192 ]])
193
194 checkro("var1", [[
195 local a, <const> var1 = 10;
196 function foo() a = 20; z = function () var1 = 12; end end
197 ]])
188end 198end
189 199
190 200