diff options
author | Li Jin <dragon-fly@qq.com> | 2022-05-24 10:06:53 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2022-05-24 10:06:53 +0800 |
commit | 30a11b0023ad1bc59662d1ead279ba92f6f57cdc (patch) | |
tree | 0a871f2eb1819a2689ea931a0a07004be909465c /spec/outputs/test/loops_spec.lua | |
parent | ac2f4ff4cdd3286ecaf31aec47d9d8aadfa75b0f (diff) | |
download | yuescript-0.10.23.tar.gz yuescript-0.10.23.tar.bz2 yuescript-0.10.23.zip |
add favicon and tests.v0.10.23
Diffstat (limited to 'spec/outputs/test/loops_spec.lua')
-rw-r--r-- | spec/outputs/test/loops_spec.lua | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/outputs/test/loops_spec.lua b/spec/outputs/test/loops_spec.lua new file mode 100644 index 0000000..3fc0332 --- /dev/null +++ b/spec/outputs/test/loops_spec.lua | |||
@@ -0,0 +1,39 @@ | |||
1 | return describe("loops", function() | ||
2 | return it("should continue", function() | ||
3 | local input = { | ||
4 | 1, | ||
5 | 2, | ||
6 | 3, | ||
7 | 4, | ||
8 | 5, | ||
9 | 6 | ||
10 | } | ||
11 | local output | ||
12 | do | ||
13 | local _accum_0 = { } | ||
14 | local _len_0 = 1 | ||
15 | for _index_0 = 1, #input do | ||
16 | local x = input[_index_0] | ||
17 | local _continue_0 = false | ||
18 | repeat | ||
19 | if x % 2 == 1 then | ||
20 | _continue_0 = true | ||
21 | break | ||
22 | end | ||
23 | _accum_0[_len_0] = x | ||
24 | _len_0 = _len_0 + 1 | ||
25 | _continue_0 = true | ||
26 | until true | ||
27 | if not _continue_0 then | ||
28 | break | ||
29 | end | ||
30 | end | ||
31 | output = _accum_0 | ||
32 | end | ||
33 | return assert.same(output, { | ||
34 | 2, | ||
35 | 4, | ||
36 | 6 | ||
37 | }) | ||
38 | end) | ||
39 | end) | ||