Skip to content

Commit a6c9206

Browse files
committed
tests for new continue keyword
1 parent 99adf93 commit a6c9206

File tree

2 files changed

+139
-1
lines changed

2 files changed

+139
-1
lines changed

tests/inputs/loops.moon

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,34 @@ i = 0
7474
x = while i < 10
7575
i += 1
7676

77+
-- continue
78+
79+
while true
80+
continue if false
81+
print "yes"
82+
break if true
83+
print "no"
84+
85+
86+
for x=1,10
87+
continue if x > 3 and x < 7
88+
print x
89+
90+
91+
list = for x=1,10
92+
continue if x > 3 and x < 7
93+
x
94+
95+
96+
for a in *{1,2,3,4,5,6}
97+
continue if a == 1
98+
continue if a == 3
99+
print a
100+
101+
102+
103+
for x=1,10
104+
continue if x % 2 == 0
105+
for y = 2,12
106+
continue if y % 3 == 0
77107

tests/outputs/loops.lua

Lines changed: 109 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,112 @@ x = (function()
142142
end
143143
end
144144
return _accum_0
145-
end)()
145+
end)()
146+
while true do
147+
local _continue_0 = false
148+
repeat
149+
if false then
150+
_continue_0 = true
151+
break
152+
end
153+
print("yes")
154+
if true then
155+
break
156+
end
157+
print("no")
158+
_continue_0 = true
159+
until true
160+
if not _continue_0 then
161+
break
162+
end
163+
end
164+
for x = 1, 10 do
165+
local _continue_0 = false
166+
repeat
167+
if x > 3 and x < 7 then
168+
_continue_0 = true
169+
break
170+
end
171+
print(x)
172+
_continue_0 = true
173+
until true
174+
if not _continue_0 then
175+
break
176+
end
177+
end
178+
local list = (function()
179+
local _accum_0 = { }
180+
local _len_0 = 0
181+
for x = 1, 10 do
182+
local _continue_0 = false
183+
repeat
184+
if x > 3 and x < 7 then
185+
_continue_0 = true
186+
break
187+
end
188+
local _value_0 = x
189+
if _value_0 ~= nil then
190+
_len_0 = _len_0 + 1
191+
_accum_0[_len_0] = _value_0
192+
end
193+
_continue_0 = true
194+
until true
195+
if not _continue_0 then
196+
break
197+
end
198+
end
199+
return _accum_0
200+
end)()
201+
local _list_1 = {
202+
1,
203+
2,
204+
3,
205+
4,
206+
5,
207+
6
208+
}
209+
for _index_0 = 1, #_list_1 do
210+
local _continue_0 = false
211+
repeat
212+
local a = _list_1[_index_0]
213+
if a == 1 then
214+
_continue_0 = true
215+
break
216+
end
217+
if a == 3 then
218+
_continue_0 = true
219+
break
220+
end
221+
print(a)
222+
_continue_0 = true
223+
until true
224+
if not _continue_0 then
225+
break
226+
end
227+
end
228+
for x = 1, 10 do
229+
local _continue_0 = false
230+
repeat
231+
if x % 2 == 0 then
232+
_continue_0 = true
233+
break
234+
end
235+
for y = 2, 12 do
236+
local _continue_1 = false
237+
repeat
238+
if y % 3 == 0 then
239+
_continue_1 = true
240+
break
241+
end
242+
_continue_1 = true
243+
until true
244+
if not _continue_1 then
245+
break
246+
end
247+
end
248+
_continue_0 = true
249+
until true
250+
if not _continue_0 then
251+
break
252+
end
253+
end

0 commit comments

Comments
 (0)