diff options
| author | Li Jin <dragon-fly@qq.com> | 2026-01-22 15:03:12 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2026-01-22 15:03:12 +0800 |
| commit | f1454bbbd13a71da2005ff789cde2da0e9eb81f6 (patch) | |
| tree | 37131187f4218dd3ebec049101c28a161e7ca289 /spec/outputs/test/comprehension_spec.lua | |
| parent | 604a8e5e53cdc7391a502fcabf07e8f1cc2a778c (diff) | |
| download | yuescript-f1454bbbd13a71da2005ff789cde2da0e9eb81f6.tar.gz yuescript-f1454bbbd13a71da2005ff789cde2da0e9eb81f6.tar.bz2 yuescript-f1454bbbd13a71da2005ff789cde2da0e9eb81f6.zip | |
Diffstat (limited to 'spec/outputs/test/comprehension_spec.lua')
| -rw-r--r-- | spec/outputs/test/comprehension_spec.lua | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/outputs/test/comprehension_spec.lua b/spec/outputs/test/comprehension_spec.lua new file mode 100644 index 0000000..a4682d5 --- /dev/null +++ b/spec/outputs/test/comprehension_spec.lua | |||
| @@ -0,0 +1,31 @@ | |||
| 1 | return describe("comprehension", function() | ||
| 2 | return it("nested with filter", function() | ||
| 3 | local list = { | ||
| 4 | 1, | ||
| 5 | 2, | ||
| 6 | 3 | ||
| 7 | } | ||
| 8 | local out | ||
| 9 | do | ||
| 10 | local _accum_0 = { } | ||
| 11 | local _len_0 = 1 | ||
| 12 | for _index_0 = 1, #list do | ||
| 13 | local i = list[_index_0] | ||
| 14 | if i % 2 == 1 then | ||
| 15 | for _index_1 = 1, #list do | ||
| 16 | local j = list[_index_1] | ||
| 17 | if j > i then | ||
| 18 | _accum_0[_len_0] = tostring(i) .. "-" .. tostring(j) | ||
| 19 | _len_0 = _len_0 + 1 | ||
| 20 | end | ||
| 21 | end | ||
| 22 | end | ||
| 23 | end | ||
| 24 | out = _accum_0 | ||
| 25 | end | ||
| 26 | return assert.same(out, { | ||
| 27 | "1-2", | ||
| 28 | "1-3" | ||
| 29 | }) | ||
| 30 | end) | ||
| 31 | end) | ||
