aboutsummaryrefslogtreecommitdiff
path: root/testes/constructs.lua
diff options
context:
space:
mode:
Diffstat (limited to 'testes/constructs.lua')
-rw-r--r--testes/constructs.lua24
1 files changed, 21 insertions, 3 deletions
diff --git a/testes/constructs.lua b/testes/constructs.lua
index fe4db2cb..8a549e10 100644
--- a/testes/constructs.lua
+++ b/testes/constructs.lua
@@ -287,7 +287,7 @@ a,b = F(nil)==nil; assert(a == true and b == nil)
287------------------------------------------------------------------ 287------------------------------------------------------------------
288 288
289-- sometimes will be 0, sometimes will not... 289-- sometimes will be 0, sometimes will not...
290_ENV.GLOB1 = math.floor(os.time()) % 2 290_ENV.GLOB1 = math.random(0, 1)
291 291
292-- basic expressions with their respective values 292-- basic expressions with their respective values
293local basiccases = { 293local basiccases = {
@@ -298,6 +298,26 @@ local basiccases = {
298 {"(0==_ENV.GLOB1)", 0 == _ENV.GLOB1}, 298 {"(0==_ENV.GLOB1)", 0 == _ENV.GLOB1},
299} 299}
300 300
301local prog
302
303if _ENV.GLOB1 == 0 then
304 basiccases[2][1] = "F" -- constant false
305
306 prog = [[
307 local <const> F = false
308 if %s then IX = true end
309 return %s
310]]
311else
312 basiccases[4][1] = "k10" -- constant 10
313
314 prog = [[
315 local <const> k10 = 10
316 if %s then IX = true end
317 return %s
318 ]]
319end
320
301print('testing short-circuit optimizations (' .. _ENV.GLOB1 .. ')') 321print('testing short-circuit optimizations (' .. _ENV.GLOB1 .. ')')
302 322
303 323
@@ -337,8 +357,6 @@ cases[1] = basiccases
337for i = 2, level do cases[i] = createcases(i) end 357for i = 2, level do cases[i] = createcases(i) end
338print("+") 358print("+")
339 359
340local prog = [[if %s then IX = true end; return %s]]
341
342local i = 0 360local i = 0
343for n = 1, level do 361for n = 1, level do
344 for _, v in pairs(cases[n]) do 362 for _, v in pairs(cases[n]) do