From a6c920641e187ace8b7a04677b4ee445f99947c2 Mon Sep 17 00:00:00 2001 From: leaf corcoran Date: Sun, 28 Oct 2012 02:05:12 -0700 Subject: [PATCH] tests for new continue keyword --- tests/inputs/loops.moon | 30 +++++++++++ tests/outputs/loops.lua | 110 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 139 insertions(+), 1 deletion(-) diff --git a/tests/inputs/loops.moon b/tests/inputs/loops.moon index fe0f0cd..c827470 100644 --- a/tests/inputs/loops.moon +++ b/tests/inputs/loops.moon @@ -74,4 +74,34 @@ i = 0 x = while i < 10 i += 1 +-- continue + +while true + continue if false + print "yes" + break if true + print "no" + + +for x=1,10 + continue if x > 3 and x < 7 + print x + + +list = for x=1,10 + continue if x > 3 and x < 7 + x + + +for a in *{1,2,3,4,5,6} + continue if a == 1 + continue if a == 3 + print a + + + +for x=1,10 + continue if x % 2 == 0 + for y = 2,12 + continue if y % 3 == 0 diff --git a/tests/outputs/loops.lua b/tests/outputs/loops.lua index fa3cdf6..18b70e6 100644 --- a/tests/outputs/loops.lua +++ b/tests/outputs/loops.lua @@ -142,4 +142,112 @@ x = (function() end end return _accum_0 -end)() \ No newline at end of file +end)() +while true do + local _continue_0 = false + repeat + if false then + _continue_0 = true + break + end + print("yes") + if true then + break + end + print("no") + _continue_0 = true + until true + if not _continue_0 then + break + end +end +for x = 1, 10 do + local _continue_0 = false + repeat + if x > 3 and x < 7 then + _continue_0 = true + break + end + print(x) + _continue_0 = true + until true + if not _continue_0 then + break + end +end +local list = (function() + local _accum_0 = { } + local _len_0 = 0 + for x = 1, 10 do + local _continue_0 = false + repeat + if x > 3 and x < 7 then + _continue_0 = true + break + end + local _value_0 = x + if _value_0 ~= nil then + _len_0 = _len_0 + 1 + _accum_0[_len_0] = _value_0 + end + _continue_0 = true + until true + if not _continue_0 then + break + end + end + return _accum_0 +end)() +local _list_1 = { + 1, + 2, + 3, + 4, + 5, + 6 +} +for _index_0 = 1, #_list_1 do + local _continue_0 = false + repeat + local a = _list_1[_index_0] + if a == 1 then + _continue_0 = true + break + end + if a == 3 then + _continue_0 = true + break + end + print(a) + _continue_0 = true + until true + if not _continue_0 then + break + end +end +for x = 1, 10 do + local _continue_0 = false + repeat + if x % 2 == 0 then + _continue_0 = true + break + end + for y = 2, 12 do + local _continue_1 = false + repeat + if y % 3 == 0 then + _continue_1 = true + break + end + _continue_1 = true + until true + if not _continue_1 then + break + end + end + _continue_0 = true + until true + if not _continue_0 then + break + end +end \ No newline at end of file