aboutsummaryrefslogtreecommitdiff
path: root/spec/outputs/5.1/test/loops_spec.lua
blob: bad17a637e64022f25e29cbe9a422bfbae2446b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
return describe("loops", function()
	it("should continue", function()
		local input = {
			1,
			2,
			3,
			4,
			5,
			6
		}
		local output
		do
			local _accum_0 = { }
			local _len_0 = 1
			for _index_0 = 1, #input do
				local x = input[_index_0]
				local _continue_0 = false
				repeat
					if x % 2 == 1 then
						_continue_0 = true
						break
					end
					_accum_0[_len_0] = x
					_len_0 = _len_0 + 1
					_continue_0 = true
				until true
				if not _continue_0 then
					break
				end
			end
			output = _accum_0
		end
		return assert.same({
			2,
			4,
			6
		}, output)
	end)
	return it("continue in repeat", function()
		local output = { }
		local a = 0
		repeat
			local _cond_0 = false
			local _continue_0 = false
			repeat
				a = a + 1
				if a == 3 then
					_cond_0 = a == 8
					_continue_0 = true
					break
				end
				if a == 5 then
					break
				end
				output[#output + 1] = a
				_cond_0 = a == 8
				_continue_0 = true
			until true
			if not _continue_0 then
				break
			end
		until _cond_0
		return assert.same({
			1,
			2,
			4
		}, output)
	end)
end)