diff options
Diffstat (limited to 'spec/outputs/test/break_multiple_values_spec.lua')
| -rw-r--r-- | spec/outputs/test/break_multiple_values_spec.lua | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/spec/outputs/test/break_multiple_values_spec.lua b/spec/outputs/test/break_multiple_values_spec.lua index ba14a64..7a8bc87 100644 --- a/spec/outputs/test/break_multiple_values_spec.lua +++ b/spec/outputs/test/break_multiple_values_spec.lua | |||
| @@ -1676,7 +1676,7 @@ return describe("break with multiple values", function() | |||
| 1676 | assert.is_nil(x) | 1676 | assert.is_nil(x) |
| 1677 | return assert.is_nil(y) | 1677 | return assert.is_nil(y) |
| 1678 | end) | 1678 | end) |
| 1679 | return it("should mix break continue and value break with value break winning", function() | 1679 | it("should mix break continue and value break with value break winning", function() |
| 1680 | local x, y | 1680 | local x, y |
| 1681 | for i = 1, 9 do | 1681 | for i = 1, 9 do |
| 1682 | if i % 2 == 0 then | 1682 | if i % 2 == 0 then |
| @@ -1694,4 +1694,53 @@ return describe("break with multiple values", function() | |||
| 1694 | assert.same(x, 5) | 1694 | assert.same(x, 5) |
| 1695 | return assert.same(y, 15) | 1695 | return assert.same(y, 15) |
| 1696 | end) | 1696 | end) |
| 1697 | it("should allow nesting do and for", function() | ||
| 1698 | local x, y | ||
| 1699 | do | ||
| 1700 | repeat | ||
| 1701 | local min, max = 1, 10 | ||
| 1702 | if max > min then | ||
| 1703 | for j = min, max do | ||
| 1704 | if j > 5 then | ||
| 1705 | x, y = j, j * 10 | ||
| 1706 | break | ||
| 1707 | end | ||
| 1708 | end | ||
| 1709 | break | ||
| 1710 | end | ||
| 1711 | x, y = 0, 0 | ||
| 1712 | break | ||
| 1713 | until true | ||
| 1714 | end | ||
| 1715 | assert.same(x, 6) | ||
| 1716 | return assert.same(y, 60) | ||
| 1717 | end) | ||
| 1718 | return it("should allow nesting do and with", function() | ||
| 1719 | local x | ||
| 1720 | do | ||
| 1721 | local _with_0 = { | ||
| 1722 | a = 123, | ||
| 1723 | b = true | ||
| 1724 | } | ||
| 1725 | repeat | ||
| 1726 | do | ||
| 1727 | if _with_0.b then | ||
| 1728 | local _with_1 = { | ||
| 1729 | a = _with_0.a, | ||
| 1730 | b = _with_0.b, | ||
| 1731 | c = "ok" | ||
| 1732 | } | ||
| 1733 | repeat | ||
| 1734 | if _with_1.b and _with_1.c == "ok" then | ||
| 1735 | x = _with_1.a | ||
| 1736 | break | ||
| 1737 | end | ||
| 1738 | until true | ||
| 1739 | break | ||
| 1740 | end | ||
| 1741 | end | ||
| 1742 | until true | ||
| 1743 | end | ||
| 1744 | return assert.same(x, 123) | ||
| 1745 | end) | ||
| 1697 | end) | 1746 | end) |
