aboutsummaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2023-12-07 23:49:48 +0800
committerLi Jin <dragon-fly@qq.com>2023-12-07 23:55:16 +0800
commit514b9f97febe8920a78d6078b092fe84b859a963 (patch)
tree8c76ba7579f69db7e2c899e4713009b910e0fa89 /spec
parenta1d719e3bbfe8cd39c05d2a8f49143b9e814f876 (diff)
downloadyuescript-514b9f97febe8920a78d6078b092fe84b859a963.tar.gz
yuescript-514b9f97febe8920a78d6078b092fe84b859a963.tar.bz2
yuescript-514b9f97febe8920a78d6078b092fe84b859a963.zip
changed the if-assignment syntax to prevent some errors.v0.21.0
Diffstat (limited to 'spec')
-rw-r--r--spec/inputs/assign.yue2
-rw-r--r--spec/inputs/compile_doc.yue4
-rw-r--r--spec/inputs/cond.yue28
-rw-r--r--spec/inputs/destructure.yue8
-rw-r--r--spec/inputs/existential.yue2
-rw-r--r--spec/inputs/macro_teal.yue2
-rw-r--r--spec/inputs/pipe.yue2
-rw-r--r--spec/inputs/plus.yue8
-rw-r--r--spec/inputs/try_catch.yue4
-rw-r--r--spec/inputs/unicode/assign.yue2
-rw-r--r--spec/inputs/unicode/cond.yue28
-rw-r--r--spec/inputs/unicode/destructure.yue8
-rw-r--r--spec/inputs/unicode/existential.yue2
-rw-r--r--spec/inputs/unicode/pipe.yue2
-rw-r--r--spec/inputs/unicode/plus.yue8
-rw-r--r--spec/inputs/unicode/try_catch.yue4
16 files changed, 57 insertions, 57 deletions
diff --git a/spec/inputs/assign.yue b/spec/inputs/assign.yue
index 8ae5cac..2c89a99 100644
--- a/spec/inputs/assign.yue
+++ b/spec/inputs/assign.yue
@@ -30,7 +30,7 @@ c, d = 1, 2 if true
30 30
31x = (do 31x = (do
32 f! 32 f!
33 123) if f = getHandler! 33 123) if f := getHandler!
34 34
35(using nil) <- _ 35(using nil) <- _
36 36
diff --git a/spec/inputs/compile_doc.yue b/spec/inputs/compile_doc.yue
index 4ce2b13..64d7d40 100644
--- a/spec/inputs/compile_doc.yue
+++ b/spec/inputs/compile_doc.yue
@@ -8,13 +8,13 @@ for [compiledFile, docFile] in *[
8 text = \read "*a" 8 text = \read "*a"
9 codes = [] 9 codes = []
10 for code in text\gmatch "```moonscript(.-)```" 10 for code in text\gmatch "```moonscript(.-)```"
11 if result, err = to_lua code, implicit_return_root: false, reserve_line_number: false 11 if result, err := to_lua code, implicit_return_root: false, reserve_line_number: false
12 codes[] = result 12 codes[] = result
13 elseif not err\match "macro exporting module only accepts macro definition" 13 elseif not err\match "macro exporting module only accepts macro definition"
14 print err 14 print err
15 os.exit 1 15 os.exit 1
16 for code in text\gmatch "<pre>(.-)</pre>" 16 for code in text\gmatch "<pre>(.-)</pre>"
17 if result, err = to_lua code\gsub("&lt;", "<")\gsub("&gt;", ">"), implicit_return_root: false, reserve_line_number: false 17 if result, err := to_lua code\gsub("&lt;", "<")\gsub("&gt;", ">"), implicit_return_root: false, reserve_line_number: false
18 codes[] = result 18 codes[] = result
19 else 19 else
20 print err 20 print err
diff --git a/spec/inputs/cond.yue b/spec/inputs/cond.yue
index 5bc6c9b..cce96df 100644
--- a/spec/inputs/cond.yue
+++ b/spec/inputs/cond.yue
@@ -52,18 +52,18 @@ elseif "just us"
52 52
53-- 53--
54 54
55if something = 10 55if something := 10
56 print something 56 print something
57else 57else
58 print "else" 58 print "else"
59 59
60hello = if something = 10 60hello = if something := 10
61 print something 61 print something
62else 62else
63 print "else" 63 print "else"
64 64
65 65
66hello = 5 + if something = 10 66hello = 5 + if something := 10
67 print something 67 print something
68 68
69--- 69---
@@ -72,9 +72,9 @@ z = false
72 72
73_ = if false 73_ = if false
74 one 74 one
75elseif x = true 75elseif x := true
76 two 76 two
77elseif z = true 77elseif z := true
78 three 78 three
79else 79else
80 four 80 four
@@ -82,17 +82,17 @@ else
82 82
83out = if false 83out = if false
84 one 84 one
85elseif x = true 85elseif x := true
86 two 86 two
87elseif z = true 87elseif z := true
88 three 88 three
89else 89else
90 four 90 four
91 91
92kzy = -> 92kzy = ->
93 if something = true 93 if something := true
94 1 94 1
95 elseif another = false 95 elseif another := false
96 2 96 2
97 97
98--- 98---
@@ -152,7 +152,7 @@ dddd = {1,2,3} unless value
152 152
153do 153do
154 j = 100 154 j = 100
155 unless j = hi! 155 unless j := hi!
156 error "not j!" 156 error "not j!"
157 157
158---------------- 158----------------
@@ -200,22 +200,22 @@ do
200 elseif c 200 elseif c
201 d: e = tb 201 d: e = tb
202 202
203if :pi = math 203if :pi := math
204 print pi 204 print pi
205 205
206do 206do
207 local math 207 local math
208 if :pi = math 208 if :pi := math
209 print pi 209 print pi
210 210
211do 211do
212 if _M = {} 212 if _M := {}
213 :Thing = _M 213 :Thing = _M
214 :a, :b = _M 214 :a, :b = _M
215 215
216do 216do
217 global _M 217 global _M
218 if _M = {} 218 if _M := {}
219 :Thing = _M 219 :Thing = _M
220 :a, :b = _M 220 :a, :b = _M
221 221
diff --git a/spec/inputs/destructure.yue b/spec/inputs/destructure.yue
index 73e4d33..5017ee1 100644
--- a/spec/inputs/destructure.yue
+++ b/spec/inputs/destructure.yue
@@ -94,18 +94,18 @@ do
94 94
95do 95do
96 thing = nil 96 thing = nil
97 if {a} = thing 97 if {a} := thing
98 print a 98 print a
99 else 99 else
100 print "nothing" 100 print "nothing"
101 101
102 thang = {1,2} 102 thang = {1,2}
103 if {a,b} = thang 103 if {a,b} := thang
104 print a,b 104 print a,b
105 105
106 if {a,b} = thing 106 if {a,b} := thing
107 print a,b 107 print a,b
108 elseif {c,d} = thang 108 elseif {c,d} := thang
109 print c,d 109 print c,d
110 else 110 else
111 print "NO" 111 print "NO"
diff --git a/spec/inputs/existential.yue b/spec/inputs/existential.yue
index 27891dc..ec38897 100644
--- a/spec/inputs/existential.yue
+++ b/spec/inputs/existential.yue
@@ -16,7 +16,7 @@ with abc?!\func?!
16 if \p? "abc" 16 if \p? "abc"
17 return 123 17 return 123
18 18
19if {:x} = a?.if?\then?(123)? @?\function 998 19if {:x} := a?.if?\then?(123)? @?\function 998
20 print x 20 print x
21 21
22res = b.function\do!\while?("OK")\if("def",998)\f? 22res = b.function\do!\while?("OK")\if("def",998)\f?
diff --git a/spec/inputs/macro_teal.yue b/spec/inputs/macro_teal.yue
index a443614..0cfd862 100644
--- a/spec/inputs/macro_teal.yue
+++ b/spec/inputs/macro_teal.yue
@@ -8,7 +8,7 @@ macro to_lua = (code)->
8 "require('yue').to_lua(#{code}, reserve_line_number:false, same_module:true)" 8 "require('yue').to_lua(#{code}, reserve_line_number:false, same_module:true)"
9 9
10macro trim = (name)-> 10macro trim = (name)->
11 "if result = #{name}\\match '[\\'\"](.*)[\\'\"]' then result else #{name}" 11 "if result := #{name}\\match '[\\'\"](.*)[\\'\"]' then result else #{name}"
12 12
13export macro local = (decl, value = nil)-> 13export macro local = (decl, value = nil)->
14 import "yue" as {options:{:tl_enabled}} 14 import "yue" as {options:{:tl_enabled}}
diff --git a/spec/inputs/pipe.yue b/spec/inputs/pipe.yue
index 02f87a3..b5bae1d 100644
--- a/spec/inputs/pipe.yue
+++ b/spec/inputs/pipe.yue
@@ -11,7 +11,7 @@
11 11
12b = 1 + 2 + (4 |> tostring |> print(1) or 123) 12b = 1 + 2 + (4 |> tostring |> print(1) or 123)
13 13
14if x = 233 |> math.max 998 14if x := 233 |> math.max 998
15 print x 15 print x
16 16
17with b |> create? "new" 17with b |> create? "new"
diff --git a/spec/inputs/plus.yue b/spec/inputs/plus.yue
index e387090..9c500a4 100644
--- a/spec/inputs/plus.yue
+++ b/spec/inputs/plus.yue
@@ -8,13 +8,13 @@ c.repeat.if\then("xyz")\else res
8 8
9print @for,@@function 123 9print @for,@@function 123
10 10
11if fcolor = message\match "<%w*>" then message = message\gsub "<%->", fcolor 11if fcolor := message\match "<%w*>" then message = message\gsub "<%->", fcolor
12 12
13message = message\gsub "<%->", fcolor if fcolor = message\match "<%w*>" 13message = message\gsub "<%->", fcolor if fcolor := message\match "<%w*>"
14 14
15valA = func! if func = getfunc! 15valA = func! if func := getfunc!
16 16
17local valA = func! if func = getfunc! 17local valA = func! if func := getfunc!
18 18
19valB = do 19valB = do
20 func = getfunc! 20 func = getfunc!
diff --git a/spec/inputs/try_catch.yue b/spec/inputs/try_catch.yue
index 96a87fc..ccb3f52 100644
--- a/spec/inputs/try_catch.yue
+++ b/spec/inputs/try_catch.yue
@@ -39,14 +39,14 @@ catch err
39 print "OK" 39 print "OK"
40 40
41do 41do
42 if success, result = try func "abc", 123 42 if success, result := try func "abc", 123
43 print result 43 print result
44 44
45 success, result = try func "abc", 123 45 success, result = try func "abc", 123
46 catch err 46 catch err
47 print err 47 print err
48 48
49 print result if success, result = try func "abc", 123 49 print result if success, result := try func "abc", 123
50 catch err 50 catch err
51 print err 51 print err
52 52
diff --git a/spec/inputs/unicode/assign.yue b/spec/inputs/unicode/assign.yue
index 5392a92..6c03f86 100644
--- a/spec/inputs/unicode/assign.yue
+++ b/spec/inputs/unicode/assign.yue
@@ -30,7 +30,7 @@ else
30 30
31变量x = (do 31变量x = (do
32 函数! 32 函数!
33 123) if 函数 = 获取处理函数! 33 123) if 函数 := 获取处理函数!
34 34
35(using nil) <- _无效变量 35(using nil) <- _无效变量
36 36
diff --git a/spec/inputs/unicode/cond.yue b/spec/inputs/unicode/cond.yue
index fca6d60..dde5c99 100644
--- a/spec/inputs/unicode/cond.yue
+++ b/spec/inputs/unicode/cond.yue
@@ -52,18 +52,18 @@ elseif "只有我们"
52 52
53-- 53--
54 54
55if 某东西 = 10 55if 某东西 := 10
56 打印 某东西 56 打印 某东西
57else 57else
58 打印 "其它" 58 打印 "其它"
59 59
60你好 = if 某东西 = 10 60你好 = if 某东西 := 10
61 打印 某东西 61 打印 某东西
62else 62else
63 打印 "其它" 63 打印 "其它"
64 64
65 65
66你好 = 5 + if 某东西 = 10 66你好 = 5 + if 某东西 := 10
67 打印 某东西 67 打印 某东西
68 68
69--- 69---
@@ -72,9 +72,9 @@ z变量 = false
72 72
73_无效变量 = if false 73_无效变量 = if false
74 74
75elseif 条件x = true 75elseif 条件x := true
76 76
77elseif 条件z = true 77elseif 条件z := true
78 78
79else 79else
80 80
@@ -82,17 +82,17 @@ else
82 82
83输出 = if false 83输出 = if false
84 84
85elseif 条件x = true 85elseif 条件x := true
86 86
87elseif 条件z = true 87elseif 条件z := true
88 88
89else 89else
90 90
91 91
92变量 = -> 92变量 = ->
93 if 某东西 = true 93 if 某东西 := true
94 1 94 1
95 elseif 另一个 = false 95 elseif 另一个 := false
96 2 96 2
97 97
98--- 98---
@@ -152,7 +152,7 @@ else
152 152
153do 153do
154 j变量 = 100 154 j变量 = 100
155 unless j变量 = 嗨! 155 unless j变量 := 嗨!
156 错误 "不是 j变量!" 156 错误 "不是 j变量!"
157 157
158---------------- 158----------------
@@ -200,22 +200,22 @@ do
200 elseif 条件c 200 elseif 条件c
201 字段d: 变量e = 变量tb 201 字段d: 变量e = 变量tb
202 202
203if :派 = 数学库 203if :派 := 数学库
204 打印 派 204 打印 派
205 205
206do 206do
207 local 数学库 207 local 数学库
208 if :派 = 数学库 208 if :派 := 数学库
209 打印 派 209 打印 派
210 210
211do 211do
212 if _模块 = {} 212 if _模块 := {}
213 :东西 = _模块 213 :东西 = _模块
214 :a功能, :b功能 = _模块 214 :a功能, :b功能 = _模块
215 215
216do 216do
217 global _模块 217 global _模块
218 if _模块 = {} 218 if _模块 := {}
219 :东西 = _模块 219 :东西 = _模块
220 :a功能, :b功能 = _模块 220 :a功能, :b功能 = _模块
221 221
diff --git a/spec/inputs/unicode/destructure.yue b/spec/inputs/unicode/destructure.yue
index 5efdf82..3c3a369 100644
--- a/spec/inputs/unicode/destructure.yue
+++ b/spec/inputs/unicode/destructure.yue
@@ -92,18 +92,18 @@ do
92 92
93do 93do
94 东西 = nil 94 东西 = nil
95 if {元素a} = 东西 95 if {元素a} := 东西
96 打印 元素a 96 打印 元素a
97 else 97 else
98 打印 "没东西" 98 打印 "没东西"
99 99
100 东东 = {1,2} 100 东东 = {1,2}
101 if {元素a,元素b} = 东东 101 if {元素a,元素b} := 东东
102 打印 元素a,元素b 102 打印 元素a,元素b
103 103
104 if {元素a,元素b} = 东西 104 if {元素a,元素b} := 东西
105 打印 元素a,元素b 105 打印 元素a,元素b
106 elseif {元素c,元素d} = 东东 106 elseif {元素c,元素d} := 东东
107 打印 元素c,元素d 107 打印 元素c,元素d
108 else 108 else
109 打印 "不" 109 打印 "不"
diff --git a/spec/inputs/unicode/existential.yue b/spec/inputs/unicode/existential.yue
index 0e35a39..de65027 100644
--- a/spec/inputs/unicode/existential.yue
+++ b/spec/inputs/unicode/existential.yue
@@ -16,7 +16,7 @@ with 对象abc?!\函数?!
16 if \函数p? "abc" 16 if \函数p? "abc"
17 return 123 17 return 123
18 18
19if {:x字段} = 对象a?.如果?\然后?(123)? @?\方法 998 19if {:x字段} := 对象a?.如果?\然后?(123)? @?\方法 998
20 打印 x字段 20 打印 x字段
21 21
22结果 = 对象b.方法\执行!\当?("没问题")\如果("默认",998)\函数? 22结果 = 对象b.方法\执行!\当?("没问题")\如果("默认",998)\函数?
diff --git a/spec/inputs/unicode/pipe.yue b/spec/inputs/unicode/pipe.yue
index 2cd41ee..085a2cf 100644
--- a/spec/inputs/unicode/pipe.yue
+++ b/spec/inputs/unicode/pipe.yue
@@ -11,7 +11,7 @@
11 11
12变量b = 1 + 2 + (4 |> tostring |> 打印(1) or 123) 12变量b = 1 + 2 + (4 |> tostring |> 打印(1) or 123)
13 13
14if 变量x = 233 |> math.max 998 14if 变量x := 233 |> math.max 998
15 打印 变量x 15 打印 变量x
16 16
17with 变量b |> 创建? "new" 17with 变量b |> 创建? "new"
diff --git a/spec/inputs/unicode/plus.yue b/spec/inputs/unicode/plus.yue
index b08974f..70b57bb 100644
--- a/spec/inputs/unicode/plus.yue
+++ b/spec/inputs/unicode/plus.yue
@@ -8,13 +8,13 @@
8 8
9打印 @循环, @@函数 123 9打印 @循环, @@函数 123
10 10
11if 颜色 = 消息\匹配 "<%w*>" then 消息 = 消息\替换 "<%->", 颜色 11if 颜色 := 消息\匹配 "<%w*>" then 消息 = 消息\替换 "<%->", 颜色
12 12
13消息 = 消息\替换 "<%->", 颜色 if 颜色 = 消息\匹配 "<%w*>" 13消息 = 消息\替换 "<%->", 颜色 if 颜色 := 消息\匹配 "<%w*>"
14 14
15数值A = 方法! if 方法 = 获取方法! 15数值A = 方法! if 方法 := 获取方法!
16 16
17local 数值A = 方法! if 方法 = 获取方法! 17local 数值A = 方法! if 方法 := 获取方法!
18 18
19数值B = do 19数值B = do
20 方法 = 获取方法! 20 方法 = 获取方法!
diff --git a/spec/inputs/unicode/try_catch.yue b/spec/inputs/unicode/try_catch.yue
index 71e03ee..1156d8e 100644
--- a/spec/inputs/unicode/try_catch.yue
+++ b/spec/inputs/unicode/try_catch.yue
@@ -39,14 +39,14 @@ catch 错误
39 打印 "好的" 39 打印 "好的"
40 40
41do 41do
42 if 成功, 结果 = try 函数 "abc", 123 42 if 成功, 结果 := try 函数 "abc", 123
43 打印 结果 43 打印 结果
44 44
45 成功, 结果 = try 函数 "abc", 123 45 成功, 结果 = try 函数 "abc", 123
46 catch 错误 46 catch 错误
47 打印 错误 47 打印 错误
48 48
49 打印 结果 if 成功, 结果 = try 函数 "abc", 123 49 打印 结果 if 成功, 结果 := try 函数 "abc", 123
50 catch 错误 50 catch 错误
51 打印 错误 51 打印 错误
52 52