diff options
author | Li Jin <dragon-fly@qq.com> | 2021-04-19 18:10:08 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2021-04-19 18:10:08 +0800 |
commit | 7ac784e73b026ce7e17babb2f0b819864fd898b0 (patch) | |
tree | 244a39123a4789a04fb577d6956bdb461509a153 /spec | |
parent | ce9f6632635222b38ef0b37b4b1273da4a1877b4 (diff) | |
download | yuescript-7ac784e73b026ce7e17babb2f0b819864fd898b0.tar.gz yuescript-7ac784e73b026ce7e17babb2f0b819864fd898b0.tar.bz2 yuescript-7ac784e73b026ce7e17babb2f0b819864fd898b0.zip |
rename BackcallOperator to PipeOperator.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/inputs/backcall.yue | 84 | ||||
-rw-r--r-- | spec/inputs/loops.yue | 2 | ||||
-rw-r--r-- | spec/inputs/pipe.yue | 84 |
3 files changed, 87 insertions, 83 deletions
diff --git a/spec/inputs/backcall.yue b/spec/inputs/backcall.yue index bad3a56..d7ed0dd 100644 --- a/spec/inputs/backcall.yue +++ b/spec/inputs/backcall.yue | |||
@@ -1,77 +1,3 @@ | |||
1 | |||
2 | {"abc", 123, 998} |> foreach print | ||
3 | |||
4 | {1,2,3} | ||
5 | |> map (x)-> x * 2 | ||
6 | |> filter (x)-> x > 4 | ||
7 | |> reduce 0, (a,b)-> a + b | ||
8 | |||
9 | |||
10 | [i |> tostring for i = 0,10] |> table.concat(",") |> print | ||
11 | |||
12 | b = 1 + 2 + (4 |> tostring |> print(1) or 123) | ||
13 | |||
14 | if x = 233 |> math.max 998 | ||
15 | print x | ||
16 | |||
17 | with b |> create? "new" | ||
18 | .value = 123 | ||
19 | print \work! | ||
20 | |||
21 | 123 |> f? | ||
22 | |||
23 | "abc" |> f1? |> f2? | ||
24 | |||
25 | c = "abc" |> f1? |> f2? | ||
26 | |||
27 | f = -> | ||
28 | arg |> x.y?\if | ||
29 | |||
30 | 998 |> func2 "abc", 233 |> func0 |> func1 | ||
31 | 998 |> func0("abc", 233) |> func1 |> func2 | ||
32 | |||
33 | 1 |> f 2, 3, 4, 5 | ||
34 | val(2) |> f 1, _, 3, 4, 5 | ||
35 | arr[3] |> f 1, 2, _, 4, 5 | ||
36 | |||
37 | a = {"1","2","3"} |> table.concat("") |> tonumber |> f1(1, 2, 3, _) |> f2(1, _, 3) | ||
38 | |||
39 | readFile("example.txt") |> | ||
40 | extract(_, language, {}) |> | ||
41 | parse(_, language) |> | ||
42 | emit |> | ||
43 | render |> | ||
44 | |||
45 | |||
46 | readFile("example.txt") \ | ||
47 | |> extract(_, language, {}) \ | ||
48 | |> parse(_, language) \ | ||
49 | |> emit \ | ||
50 | |> render \ | ||
51 | |||
52 | |||
53 | readFile "example.txt" | ||
54 | |> extract _, language, {} | ||
55 | |> parse _, language | ||
56 | |> emit | ||
57 | |> render | ||
58 | |||
59 | |||
60 | 123 |> not func! |> f | ||
61 | |||
62 | do | ||
63 | _1 = list{"abc","xyz","123"}\map"#"\value! | ||
64 | |> -func! | ||
65 | |> abc 123, _, "x" | ||
66 | |||
67 | global _2,_3,_4 = 1,2,3 | ||
68 | |> f | ||
69 | |||
70 | local _5 = v |> f1 1 | ||
71 | |> f2 2 | ||
72 | |> f3 3 | ||
73 | |> f4 4 | ||
74 | |||
75 | do | 1 | do |
76 | (x)<- map {1,2,3} | 2 | (x)<- map {1,2,3} |
77 | x * 2 | 3 | x * 2 |
@@ -96,7 +22,7 @@ do | |||
96 | 22 | ||
97 | do | 23 | do |
98 | <- syncStatus | 24 | <- syncStatus |
99 | (err,data="nil")<- loadAsync "file.moon" | 25 | (err, data="nil")<- loadAsync "file.yue" |
100 | if err | 26 | if err |
101 | print err | 27 | print err |
102 | return | 28 | return |
@@ -141,13 +67,5 @@ propB = do | |||
141 | 67 | ||
142 | alert "hi" | 68 | alert "hi" |
143 | 69 | ||
144 | x = 123 |> a |> b or 456 |> c |> d or a.if\then("abc") or a?.b\c?(123) or x\y | ||
145 | |||
146 | x1 = 3 * -4 |> f | ||
147 | |||
148 | x2 = 3 * -2 ^ 2 |> f | ||
149 | |||
150 | y = 1 + not # 2 |> (a ^ c) |> b(3,_) * 4 ^ -123 |> f |> f1 or 123 | ||
151 | |||
152 | nil | 70 | nil |
153 | 71 | ||
diff --git a/spec/inputs/loops.yue b/spec/inputs/loops.yue index 8946a2f..5708809 100644 --- a/spec/inputs/loops.yue +++ b/spec/inputs/loops.yue | |||
@@ -30,6 +30,8 @@ for x in y, z | |||
30 | for x in y, z, k | 30 | for x in y, z, k |
31 | print x | 31 | print x |
32 | 32 | ||
33 | for name, members in *modules | ||
34 | print name, member | ||
33 | 35 | ||
34 | x = -> | 36 | x = -> |
35 | for x in y | 37 | for x in y |
diff --git a/spec/inputs/pipe.yue b/spec/inputs/pipe.yue new file mode 100644 index 0000000..7e33422 --- /dev/null +++ b/spec/inputs/pipe.yue | |||
@@ -0,0 +1,84 @@ | |||
1 | |||
2 | {"abc", 123, 998} |> foreach print | ||
3 | |||
4 | {1,2,3} | ||
5 | |> map (x)-> x * 2 | ||
6 | |> filter (x)-> x > 4 | ||
7 | |> reduce 0, (a,b)-> a + b | ||
8 | |||
9 | |||
10 | [i |> tostring for i = 0,10] |> table.concat(",") |> print | ||
11 | |||
12 | b = 1 + 2 + (4 |> tostring |> print(1) or 123) | ||
13 | |||
14 | if x = 233 |> math.max 998 | ||
15 | print x | ||
16 | |||
17 | with b |> create? "new" | ||
18 | .value = 123 | ||
19 | print \work! | ||
20 | |||
21 | 123 |> f? | ||
22 | |||
23 | "abc" |> f1? |> f2? | ||
24 | |||
25 | c = "abc" |> f1? |> f2? | ||
26 | |||
27 | f = -> | ||
28 | arg |> x.y?\if | ||
29 | |||
30 | 998 |> func2 "abc", 233 |> func0 |> func1 | ||
31 | 998 |> func0("abc", 233) |> func1 |> func2 | ||
32 | |||
33 | 1 |> f 2, 3, 4, 5 | ||
34 | val(2) |> f 1, _, 3, 4, 5 | ||
35 | arr[3] |> f 1, 2, _, 4, 5 | ||
36 | |||
37 | a = {"1","2","3"} |> table.concat("") |> tonumber |> f1(1, 2, 3, _) |> f2(1, _, 3) | ||
38 | |||
39 | readFile("example.txt") |> | ||
40 | extract(_, language, {}) |> | ||
41 | parse(_, language) |> | ||
42 | emit |> | ||
43 | render |> | ||
44 | |||
45 | |||
46 | readFile("example.txt") \ | ||
47 | |> extract(_, language, {}) \ | ||
48 | |> parse(_, language) \ | ||
49 | |> emit \ | ||
50 | |> render \ | ||
51 | |||
52 | |||
53 | readFile "example.txt" | ||
54 | |> extract _, language, {} | ||
55 | |> parse _, language | ||
56 | |> emit | ||
57 | |> render | ||
58 | |||
59 | |||
60 | 123 |> not func! |> f | ||
61 | |||
62 | do | ||
63 | _1 = list{"abc","xyz","123"}\map"#"\value! | ||
64 | |> -func! | ||
65 | |> abc 123, _, "x" | ||
66 | |||
67 | global _2,_3,_4 = 1,2,3 | ||
68 | |> f | ||
69 | |||
70 | local _5 = v |> f1 1 | ||
71 | |> f2 2 | ||
72 | |> f3 3 | ||
73 | |> f4 4 | ||
74 | |||
75 | x = 123 |> a |> b or 456 |> c |> d or a.if\then("abc") or a?.b\c?(123) or x\y | ||
76 | |||
77 | x1 = 3 * -4 |> f | ||
78 | |||
79 | x2 = 3 * -2 ^ 2 |> f | ||
80 | |||
81 | y = 1 + not # 2 |> (a ^ c) |> b(3,_) * 4 ^ -123 |> f |> f1 or 123 | ||
82 | |||
83 | nil | ||
84 | |||