summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2021-04-19 18:10:08 +0800
committerLi Jin <dragon-fly@qq.com>2021-04-19 18:10:08 +0800
commit7ac784e73b026ce7e17babb2f0b819864fd898b0 (patch)
tree244a39123a4789a04fb577d6956bdb461509a153 /spec
parentce9f6632635222b38ef0b37b4b1273da4a1877b4 (diff)
downloadyuescript-7ac784e73b026ce7e17babb2f0b819864fd898b0.tar.gz
yuescript-7ac784e73b026ce7e17babb2f0b819864fd898b0.tar.bz2
yuescript-7ac784e73b026ce7e17babb2f0b819864fd898b0.zip
rename BackcallOperator to PipeOperator.
Diffstat (limited to 'spec')
-rw-r--r--spec/inputs/backcall.yue84
-rw-r--r--spec/inputs/loops.yue2
-rw-r--r--spec/inputs/pipe.yue84
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 |> print
9
10[i |> tostring for i = 0,10] |> table.concat(",") |> print
11
12b = 1 + 2 + (4 |> tostring |> print(1) or 123)
13
14if x = 233 |> math.max 998
15 print x
16
17with b |> create? "new"
18 .value = 123
19 print \work!
20
21123 |> f?
22
23"abc" |> f1? |> f2?
24
25c = "abc" |> f1? |> f2?
26
27f = ->
28 arg |> x.y?\if
29
30998 |> func2 "abc", 233 |> func0 |> func1
31998 |> func0("abc", 233) |> func1 |> func2
32
331 |> f 2, 3, 4, 5
34val(2) |> f 1, _, 3, 4, 5
35arr[3] |> f 1, 2, _, 4, 5
36
37a = {"1","2","3"} |> table.concat("") |> tonumber |> f1(1, 2, 3, _) |> f2(1, _, 3)
38
39readFile("example.txt") |>
40 extract(_, language, {}) |>
41 parse(_, language) |>
42 emit |>
43 render |>
44 print
45
46readFile("example.txt") \
47 |> extract(_, language, {}) \
48 |> parse(_, language) \
49 |> emit \
50 |> render \
51 |> print
52
53readFile "example.txt"
54 |> extract _, language, {}
55 |> parse _, language
56 |> emit
57 |> render
58 |> print
59
60123 |> not func! |> f
61
62do
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
75do 1do
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
97do 23do
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
142alert "hi" 68alert "hi"
143 69
144x = 123 |> a |> b or 456 |> c |> d or a.if\then("abc") or a?.b\c?(123) or x\y
145
146x1 = 3 * -4 |> f
147
148x2 = 3 * -2 ^ 2 |> f
149
150y = 1 + not # 2 |> (a ^ c) |> b(3,_) * 4 ^ -123 |> f |> f1 or 123
151
152nil 70nil
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
30for x in y, z, k 30for x in y, z, k
31 print x 31 print x
32 32
33for name, members in *modules
34 print name, member
33 35
34x = -> 36x = ->
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 |> print
9
10[i |> tostring for i = 0,10] |> table.concat(",") |> print
11
12b = 1 + 2 + (4 |> tostring |> print(1) or 123)
13
14if x = 233 |> math.max 998
15 print x
16
17with b |> create? "new"
18 .value = 123
19 print \work!
20
21123 |> f?
22
23"abc" |> f1? |> f2?
24
25c = "abc" |> f1? |> f2?
26
27f = ->
28 arg |> x.y?\if
29
30998 |> func2 "abc", 233 |> func0 |> func1
31998 |> func0("abc", 233) |> func1 |> func2
32
331 |> f 2, 3, 4, 5
34val(2) |> f 1, _, 3, 4, 5
35arr[3] |> f 1, 2, _, 4, 5
36
37a = {"1","2","3"} |> table.concat("") |> tonumber |> f1(1, 2, 3, _) |> f2(1, _, 3)
38
39readFile("example.txt") |>
40 extract(_, language, {}) |>
41 parse(_, language) |>
42 emit |>
43 render |>
44 print
45
46readFile("example.txt") \
47 |> extract(_, language, {}) \
48 |> parse(_, language) \
49 |> emit \
50 |> render \
51 |> print
52
53readFile "example.txt"
54 |> extract _, language, {}
55 |> parse _, language
56 |> emit
57 |> render
58 |> print
59
60123 |> not func! |> f
61
62do
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
75x = 123 |> a |> b or 456 |> c |> d or a.if\then("abc") or a?.b\c?(123) or x\y
76
77x1 = 3 * -4 |> f
78
79x2 = 3 * -2 ^ 2 |> f
80
81y = 1 + not # 2 |> (a ^ c) |> b(3,_) * 4 ^ -123 |> f |> f1 or 123
82
83nil
84