diff options
| author | Li Jin <dragon-fly@qq.com> | 2021-10-12 10:04:44 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2021-10-12 10:04:44 +0800 |
| commit | 60a979e224f26117f5be82bfca757a2483cef0fd (patch) | |
| tree | 7c6af44f6dcada1f23979b820ba830251997b161 /spec/outputs/pipe.lua | |
| parent | a19b242cbaf53721b20a3163dd06f43e9ef2b487 (diff) | |
| download | yuescript-60a979e224f26117f5be82bfca757a2483cef0fd.tar.gz yuescript-60a979e224f26117f5be82bfca757a2483cef0fd.tar.bz2 yuescript-60a979e224f26117f5be82bfca757a2483cef0fd.zip | |
fix test.
Diffstat (limited to 'spec/outputs/pipe.lua')
| -rw-r--r-- | spec/outputs/pipe.lua | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/spec/outputs/pipe.lua b/spec/outputs/pipe.lua new file mode 100644 index 0000000..bf517ae --- /dev/null +++ b/spec/outputs/pipe.lua | |||
| @@ -0,0 +1,116 @@ | |||
| 1 | foreach({ | ||
| 2 | "abc", | ||
| 3 | 123, | ||
| 4 | 998 | ||
| 5 | }, print) | ||
| 6 | print(reduce(filter(map({ | ||
| 7 | 1, | ||
| 8 | 2, | ||
| 9 | 3 | ||
| 10 | }, function(x) | ||
| 11 | return x * 2 | ||
| 12 | end), function(x) | ||
| 13 | return x > 4 | ||
| 14 | end), 0, function(a, b) | ||
| 15 | return a + b | ||
| 16 | end)) | ||
| 17 | print(table.concat((function() | ||
| 18 | local _accum_0 = { } | ||
| 19 | local _len_0 = 1 | ||
| 20 | for i = 0, 10 do | ||
| 21 | _accum_0[_len_0] = tostring(i) | ||
| 22 | _len_0 = _len_0 + 1 | ||
| 23 | end | ||
| 24 | return _accum_0 | ||
| 25 | end)(), ",")) | ||
| 26 | local b = 1 + 2 + (print(tostring(4), 1) or 123) | ||
| 27 | do | ||
| 28 | local x = math.max(233, 998) | ||
| 29 | if x then | ||
| 30 | print(x) | ||
| 31 | end | ||
| 32 | end | ||
| 33 | do | ||
| 34 | local _with_0 | ||
| 35 | if create ~= nil then | ||
| 36 | _with_0 = create(b, "new") | ||
| 37 | end | ||
| 38 | _with_0.value = 123 | ||
| 39 | print(_with_0:work()) | ||
| 40 | end | ||
| 41 | if f ~= nil then | ||
| 42 | f(123) | ||
| 43 | end | ||
| 44 | if f2 ~= nil then | ||
| 45 | f2((function() | ||
| 46 | if f1 ~= nil then | ||
| 47 | return f1("abc") | ||
| 48 | end | ||
| 49 | return nil | ||
| 50 | end)()) | ||
| 51 | end | ||
| 52 | local c | ||
| 53 | if f2 ~= nil then | ||
| 54 | c = f2((function() | ||
| 55 | if f1 ~= nil then | ||
| 56 | return f1("abc") | ||
| 57 | end | ||
| 58 | return nil | ||
| 59 | end)()) | ||
| 60 | end | ||
| 61 | local f | ||
| 62 | f = function() | ||
| 63 | local _obj_0 = x.y | ||
| 64 | if _obj_0 ~= nil then | ||
| 65 | return _obj_0["if"](_obj_0, arg) | ||
| 66 | end | ||
| 67 | return nil | ||
| 68 | end | ||
| 69 | func2(998, "abc", func1(func0(233))) | ||
| 70 | func2(func1(func0(998, "abc", 233))) | ||
| 71 | f(1, 2, 3, 4, 5) | ||
| 72 | f(1, val(2), 3, 4, 5) | ||
| 73 | f(1, 2, arr[3], 4, 5) | ||
| 74 | local a = f2(1, f1(1, 2, 3, tonumber(table.concat({ | ||
| 75 | "1", | ||
| 76 | "2", | ||
| 77 | "3" | ||
| 78 | }, ""))), 3) | ||
| 79 | print(render(emit(parse(extract(readFile("example.txt"), language, { }), language)))) | ||
| 80 | print(render(emit(parse(extract(readFile("example.txt"), language, { }), language)))) | ||
| 81 | print(render(emit(parse(extract(readFile("example.txt"), language, { }), language)))) | ||
| 82 | f(not func(123)) | ||
| 83 | do | ||
| 84 | local _1 = abc(123, -func(list({ | ||
| 85 | "abc", | ||
| 86 | "xyz", | ||
| 87 | "123" | ||
| 88 | }):map("#"):value()), "x") | ||
| 89 | _2, _3, _4 = 1, 2, f(3) | ||
| 90 | local _5 | ||
| 91 | _5 = f4(f3(f2(f1(v, 1), 2), 3), 4) | ||
| 92 | end | ||
| 93 | local x = b(a(123)) or d(c(456)) or (function() | ||
| 94 | local _call_0 = a["if"] | ||
| 95 | return _call_0["then"](_call_0, "abc") | ||
| 96 | end)() or (function() | ||
| 97 | if a ~= nil then | ||
| 98 | local _obj_0 = a.b | ||
| 99 | local _obj_1 = _obj_0.c | ||
| 100 | if _obj_1 ~= nil then | ||
| 101 | return _obj_1(_obj_0, 123) | ||
| 102 | end | ||
| 103 | return nil | ||
| 104 | end | ||
| 105 | return nil | ||
| 106 | end)() or (function() | ||
| 107 | local _base_0 = x | ||
| 108 | local _fn_0 = _base_0.y | ||
| 109 | return _fn_0 and function(...) | ||
| 110 | return _fn_0(_base_0, ...) | ||
| 111 | end | ||
| 112 | end)() | ||
| 113 | local x1 = 3 * f(-4) | ||
| 114 | local x2 = 3 * f(-2 ^ 2) | ||
| 115 | local y = 1 + b(3, (a ^ c)(not #2)) * f1(f(4 ^ -123)) or 123 | ||
| 116 | return nil | ||
