diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-07-30 12:18:19 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-07-30 12:18:19 -0300 |
commit | 0d529138042563baf260366e19a7aa2c60a07174 (patch) | |
tree | ea8699a57a9b26e620a2ed6bc2a11c9e49dee780 /testes/constructs.lua | |
parent | b80077b8f3e27a94c6afa895b41a9f8b52c42e61 (diff) | |
download | lua-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.lua | 16 |
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) | |||
211 | print'+'; | 211 | print'+'; |
212 | 212 | ||
213 | do -- testing constants | 213 | do -- 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'") |
234 | end | 234 | end |
@@ -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 |
325 | local <const> binops = { | 325 | local 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 | ||
330 | local <const> cases = {} | 330 | local 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) |