aboutsummaryrefslogtreecommitdiff
path: root/testes/constructs.lua
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-07-30 12:18:19 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-07-30 12:18:19 -0300
commit0d529138042563baf260366e19a7aa2c60a07174 (patch)
treeea8699a57a9b26e620a2ed6bc2a11c9e49dee780 /testes/constructs.lua
parentb80077b8f3e27a94c6afa895b41a9f8b52c42e61 (diff)
downloadlua-0d529138042563baf260366e19a7aa2c60a07174.tar.gz
lua-0d529138042563baf260366e19a7aa2c60a07174.tar.bz2
lua-0d529138042563baf260366e19a7aa2c60a07174.zip
Change in the syntax of attributes
Attributes changed to posfixed ('x <const>', instead of '<const> x'), and "toclose" renamed to "close". Posfixed attributes seem to make it clearer that it applies to only one variable when there are multiple variables.
Diffstat (limited to 'testes/constructs.lua')
-rw-r--r--testes/constructs.lua16
1 files changed, 8 insertions, 8 deletions
diff --git a/testes/constructs.lua b/testes/constructs.lua
index 8a549e10..a74a8c04 100644
--- a/testes/constructs.lua
+++ b/testes/constructs.lua
@@ -211,15 +211,15 @@ assert(a==1 and b==nil)
211print'+'; 211print'+';
212 212
213do -- testing constants 213do -- testing constants
214 local <const> prog = [[local <XXX> x = 10]] 214 local prog <const> = [[local x <XXX> = 10]]
215 checkload(prog, "unknown attribute 'XXX'") 215 checkload(prog, "unknown attribute 'XXX'")
216 216
217 checkload([[local <const> xxx = 20; xxx = 10]], 217 checkload([[local xxx <const> = 20; xxx = 10]],
218 ":1: attempt to assign to const variable 'xxx'") 218 ":1: attempt to assign to const variable 'xxx'")
219 219
220 checkload([[ 220 checkload([[
221 local xx; 221 local xx;
222 local <const> xxx = 20; 222 local xxx <const> = 20;
223 local yyy; 223 local yyy;
224 local function foo () 224 local function foo ()
225 local abc = xx + yyy + xxx; 225 local abc = xx + yyy + xxx;
@@ -228,7 +228,7 @@ do -- testing constants
228 ]], ":6: attempt to assign to const variable 'xxx'") 228 ]], ":6: attempt to assign to const variable 'xxx'")
229 229
230 checkload([[ 230 checkload([[
231 local <toclose> x = nil 231 local x <close> = nil
232 x = io.open() 232 x = io.open()
233 ]], ":2: attempt to assign to const variable 'x'") 233 ]], ":2: attempt to assign to const variable 'x'")
234end 234end
@@ -304,7 +304,7 @@ if _ENV.GLOB1 == 0 then
304 basiccases[2][1] = "F" -- constant false 304 basiccases[2][1] = "F" -- constant false
305 305
306 prog = [[ 306 prog = [[
307 local <const> F = false 307 local F <const> = false
308 if %s then IX = true end 308 if %s then IX = true end
309 return %s 309 return %s
310]] 310]]
@@ -312,7 +312,7 @@ else
312 basiccases[4][1] = "k10" -- constant 10 312 basiccases[4][1] = "k10" -- constant 10
313 313
314 prog = [[ 314 prog = [[
315 local <const> k10 = 10 315 local k10 <const> = 10
316 if %s then IX = true end 316 if %s then IX = true end
317 return %s 317 return %s
318 ]] 318 ]]
@@ -322,12 +322,12 @@ print('testing short-circuit optimizations (' .. _ENV.GLOB1 .. ')')
322 322
323 323
324-- operators with their respective values 324-- operators with their respective values
325local <const> binops = { 325local binops <const> = {
326 {" and ", function (a,b) if not a then return a else return b end end}, 326 {" and ", function (a,b) if not a then return a else return b end end},
327 {" or ", function (a,b) if a then return a else return b end end}, 327 {" or ", function (a,b) if a then return a else return b end end},
328} 328}
329 329
330local <const> cases = {} 330local cases <const> = {}
331 331
332-- creates all combinations of '(cases[i] op cases[n-i])' plus 332-- creates all combinations of '(cases[i] op cases[n-i])' plus
333-- 'not(cases[i] op cases[n-i])' (syntax + value) 333-- 'not(cases[i] op cases[n-i])' (syntax + value)