diff options
Diffstat (limited to 'spec/outputs/syntax.lua')
| -rw-r--r-- | spec/outputs/syntax.lua | 94 |
1 files changed, 92 insertions, 2 deletions
diff --git a/spec/outputs/syntax.lua b/spec/outputs/syntax.lua index 040a325..eb4543c 100644 --- a/spec/outputs/syntax.lua +++ b/spec/outputs/syntax.lua | |||
| @@ -5,9 +5,9 @@ func(arg1, arg2, another, arg3) | |||
| 5 | local we | 5 | local we |
| 6 | here, we = function() end, yeah | 6 | here, we = function() end, yeah |
| 7 | local the, different | 7 | local the, different |
| 8 | the, different = function() | 8 | the, different = (function() |
| 9 | return approach | 9 | return approach |
| 10 | end, yeah | 10 | end), yeah |
| 11 | dad() | 11 | dad() |
| 12 | dad(lord) | 12 | dad(lord) |
| 13 | hello(one, two)(); | 13 | hello(one, two)(); |
| @@ -430,4 +430,94 @@ do | |||
| 430 | local f2 | 430 | local f2 |
| 431 | f2 = function() end | 431 | f2 = function() end |
| 432 | end | 432 | end |
| 433 | do | ||
| 434 | if res ~= "" then | ||
| 435 | return res | ||
| 436 | end | ||
| 437 | end | ||
| 438 | do | ||
| 439 | return res((function() | ||
| 440 | if res ~= "" then | ||
| 441 | end | ||
| 442 | end)()) | ||
| 443 | end | ||
| 444 | do | ||
| 445 | x = 1 | ||
| 446 | y = 2 | ||
| 447 | i = i + 1 | ||
| 448 | j = j + 1 | ||
| 449 | if condition then | ||
| 450 | setup() | ||
| 451 | run() | ||
| 452 | cleanup() | ||
| 453 | end | ||
| 454 | a = 1 | ||
| 455 | local b = 2 | ||
| 456 | local c = a + b | ||
| 457 | print(a) | ||
| 458 | print(b) | ||
| 459 | print(c) | ||
| 460 | f = function() | ||
| 461 | a = 1 | ||
| 462 | b = 2 | ||
| 463 | return a + b | ||
| 464 | end | ||
| 465 | a = 1 | ||
| 466 | b = 2 | ||
| 467 | local success, result = pcall(function() | ||
| 468 | return func() | ||
| 469 | end) | ||
| 470 | if success then | ||
| 471 | print(result) | ||
| 472 | end | ||
| 473 | local value = "foo" | ||
| 474 | print(value) | ||
| 475 | value = value .. "bar" | ||
| 476 | print(value) | ||
| 477 | do | ||
| 478 | if ok then | ||
| 479 | print("ok!") | ||
| 480 | end | ||
| 481 | return 42 | ||
| 482 | end | ||
| 483 | for i = 1, 3 do | ||
| 484 | print(i) | ||
| 485 | goto _continue_0 | ||
| 486 | ::_continue_0:: | ||
| 487 | end | ||
| 488 | local n = 0 | ||
| 489 | while n < 2 do | ||
| 490 | print("n=", n) | ||
| 491 | n = n + 1 | ||
| 492 | end | ||
| 493 | local obj = { } | ||
| 494 | obj:set(10) | ||
| 495 | obj:get() | ||
| 496 | print("done") | ||
| 497 | do | ||
| 498 | local _with_0 = tbl | ||
| 499 | _with_0:push(1) | ||
| 500 | print("push") | ||
| 501 | end | ||
| 502 | a = 5 | ||
| 503 | if a > 3 then | ||
| 504 | print("big") | ||
| 505 | b = a * 2 | ||
| 506 | print(b) | ||
| 507 | else | ||
| 508 | print("small") | ||
| 509 | b = a | ||
| 510 | end | ||
| 511 | xpcall(function() | ||
| 512 | x = 1 | ||
| 513 | y = 2 | ||
| 514 | return print(x + y) | ||
| 515 | end, function(err) | ||
| 516 | return print("error:", err) | ||
| 517 | end) | ||
| 518 | end | ||
| 519 | local q = 1 | ||
| 520 | local w = 2 | ||
| 521 | local e = 3 | ||
| 522 | print(q, w, e) | ||
| 433 | return nil | 523 | return nil |
