aboutsummaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2025-03-19 14:52:54 +0800
committerLi Jin <dragon-fly@qq.com>2025-03-19 14:52:54 +0800
commit28bae6517f43c384a828df62b727517e26b3af9b (patch)
treed8c54b0f4a43e2b2dce3cafdae869f535f4c85aa /spec
parentcefe5e3e8e9fa33b5f644edb5f34d0bed42ec402 (diff)
downloadyuescript-28bae6517f43c384a828df62b727517e26b3af9b.tar.gz
yuescript-28bae6517f43c384a828df62b727517e26b3af9b.tar.bz2
yuescript-28bae6517f43c384a828df62b727517e26b3af9b.zip
Fixed issue #194, #195.v0.27.1
Diffstat (limited to 'spec')
-rw-r--r--spec/inputs/assign.yue18
-rw-r--r--spec/outputs/assign.lua25
-rw-r--r--spec/outputs/codes_from_doc.lua18
-rw-r--r--spec/outputs/codes_from_doc_zh.lua18
-rw-r--r--spec/outputs/macro.lua24
-rw-r--r--spec/outputs/plus.lua3
-rw-r--r--spec/outputs/unicode/macro.lua6
-rw-r--r--spec/outputs/unicode/plus.lua3
8 files changed, 67 insertions, 48 deletions
diff --git a/spec/inputs/assign.yue b/spec/inputs/assign.yue
index 514aeed..ad1eda3 100644
--- a/spec/inputs/assign.yue
+++ b/spec/inputs/assign.yue
@@ -109,4 +109,22 @@ do
109 val = 123 109 val = 123
110 a = b = c = val 110 a = b = c = val
111 111
112do
113 -- update
114 a ..= "abc"
115 a //= 2
116 a or= def
117 a and= false
118 a >>= 10
119 a <<= 10
120 a.b.c ??= 123
121 a.b.c += 1
122 a.b.c -= 2
123 a.b.c *= 3
124 a.b.c /= 4
125 a.b.c %= 5
126 a &= 6
127 a |= 7
128 a ^= 8
129
112nil 130nil
diff --git a/spec/outputs/assign.lua b/spec/outputs/assign.lua
index 162a563..f889865 100644
--- a/spec/outputs/assign.lua
+++ b/spec/outputs/assign.lua
@@ -181,5 +181,30 @@ return _(function()
181 local b = val 181 local b = val
182 local c = val 182 local c = val
183 end 183 end
184 do
185 local a = a .. "abc"
186 a = a // 2
187 a = a or def
188 a = a and false
189 a = a >> 10
190 a = a << 10
191 local _obj_0 = a.b
192 if _obj_0.c == nil then
193 _obj_0.c = 123
194 end
195 local _obj_1 = a.b
196 _obj_1.c = _obj_1.c + 1
197 local _obj_2 = a.b
198 _obj_2.c = _obj_2.c - 2
199 local _obj_3 = a.b
200 _obj_3.c = _obj_3.c * 3
201 local _obj_4 = a.b
202 _obj_4.c = _obj_4.c / 4
203 local _obj_5 = a.b
204 _obj_5.c = _obj_5.c % 5
205 a = a & 6
206 a = a | 7
207 a = a ^ 8
208 end
184 return nil 209 return nil
185end) 210end)
diff --git a/spec/outputs/codes_from_doc.lua b/spec/outputs/codes_from_doc.lua
index 74db469..a37b459 100644
--- a/spec/outputs/codes_from_doc.lua
+++ b/spec/outputs/codes_from_doc.lua
@@ -467,8 +467,7 @@ local x = f()
467local y = x 467local y = x
468local z = x 468local z = x
469do 469do
470 local a 470 local a = 1
471 a = 1
472 local x, y, z 471 local x, y, z
473 print("forward declare all variables as locals") 472 print("forward declare all variables as locals")
474 x = function() 473 x = function()
@@ -478,8 +477,7 @@ do
478 instance = Item:new() 477 instance = Item:new()
479end 478end
480do 479do
481 local X 480 local X = 1
482 X = 1
483 local B 481 local B
484 print("only forward declare upper case variables") 482 print("only forward declare upper case variables")
485 local a = 1 483 local a = 1
@@ -499,8 +497,7 @@ do
499 print("only declare upper case variables as globals") 497 print("only declare upper case variables as globals")
500 local a = 1 498 local a = 1
501 local B = 2 499 local B = 2
502 local Temp 500 local Temp = "a local value"
503 Temp = "a local value"
504end 501end
505local thing = { 502local thing = {
506 1, 503 1,
@@ -2478,8 +2475,7 @@ local x = f()
2478local y = x 2475local y = x
2479local z = x 2476local z = x
2480do 2477do
2481 local a 2478 local a = 1
2482 a = 1
2483 local x, y, z 2479 local x, y, z
2484 print("forward declare all variables as locals") 2480 print("forward declare all variables as locals")
2485 x = function() 2481 x = function()
@@ -2489,8 +2485,7 @@ do
2489 instance = Item:new() 2485 instance = Item:new()
2490end 2486end
2491do 2487do
2492 local X 2488 local X = 1
2493 X = 1
2494 local B 2489 local B
2495 print("only forward declare upper case variables") 2490 print("only forward declare upper case variables")
2496 local a = 1 2491 local a = 1
@@ -2510,8 +2505,7 @@ do
2510 print("only declare upper case variables as globals") 2505 print("only declare upper case variables as globals")
2511 local a = 1 2506 local a = 1
2512 local B = 2 2507 local B = 2
2513 local Temp 2508 local Temp = "a local value"
2514 Temp = "a local value"
2515end 2509end
2516local thing = { 2510local thing = {
2517 1, 2511 1,
diff --git a/spec/outputs/codes_from_doc_zh.lua b/spec/outputs/codes_from_doc_zh.lua
index 1a10555..a23044d 100644
--- a/spec/outputs/codes_from_doc_zh.lua
+++ b/spec/outputs/codes_from_doc_zh.lua
@@ -467,8 +467,7 @@ local x = f()
467local y = x 467local y = x
468local z = x 468local z = x
469do 469do
470 local a 470 local a = 1
471 a = 1
472 local x, y, z 471 local x, y, z
473 print("预先声明后续所有变量为局部变量") 472 print("预先声明后续所有变量为局部变量")
474 x = function() 473 x = function()
@@ -478,8 +477,7 @@ do
478 instance = Item:new() 477 instance = Item:new()
479end 478end
480do 479do
481 local X 480 local X = 1
482 X = 1
483 local B 481 local B
484 print("只预先声明后续大写的变量为局部变量") 482 print("只预先声明后续大写的变量为局部变量")
485 local a = 1 483 local a = 1
@@ -499,8 +497,7 @@ do
499 print("只预先声明大写的变量为全局变量") 497 print("只预先声明大写的变量为全局变量")
500 local a = 1 498 local a = 1
501 local B = 2 499 local B = 2
502 local Temp 500 local Temp = "一个局部值"
503 Temp = "一个局部值"
504end 501end
505local thing = { 502local thing = {
506 1, 503 1,
@@ -2472,8 +2469,7 @@ local x = f()
2472local y = x 2469local y = x
2473local z = x 2470local z = x
2474do 2471do
2475 local a 2472 local a = 1
2476 a = 1
2477 local x, y, z 2473 local x, y, z
2478 print("预先声明后续所有变量为局部变量") 2474 print("预先声明后续所有变量为局部变量")
2479 x = function() 2475 x = function()
@@ -2483,8 +2479,7 @@ do
2483 instance = Item:new() 2479 instance = Item:new()
2484end 2480end
2485do 2481do
2486 local X 2482 local X = 1
2487 X = 1
2488 local B 2483 local B
2489 print("只预先声明后续大写的变量为局部变量") 2484 print("只预先声明后续大写的变量为局部变量")
2490 local a = 1 2485 local a = 1
@@ -2504,8 +2499,7 @@ do
2504 print("只预先声明大写的变量为全局变量") 2499 print("只预先声明大写的变量为全局变量")
2505 local a = 1 2500 local a = 1
2506 local B = 2 2501 local B = 2
2507 local Temp 2502 local Temp = "一个局部值"
2508 Temp = "一个局部值"
2509end 2503end
2510local thing = { 2504local thing = {
2511 1, 2505 1,
diff --git a/spec/outputs/macro.lua b/spec/outputs/macro.lua
index aa74ed9..4d31574 100644
--- a/spec/outputs/macro.lua
+++ b/spec/outputs/macro.lua
@@ -191,13 +191,11 @@ end
191do 191do
192 local a = 8 192 local a = 8
193 a = (function() 193 a = (function()
194 local a 194 local a = 1
195 a = 1
196 return a + 1 195 return a + 1
197 end)() 196 end)()
198 a = a + (function() 197 a = a + (function()
199 local a 198 local a = 1
200 a = 1
201 return a + 1 199 return a + 1
202 end)() 200 end)()
203 print(a) 201 print(a)
@@ -274,18 +272,12 @@ local result = ((((((origin.transform.root.gameObject:Parents()):Descendants()):
274end)):Destroy() 272end)):Destroy()
275do 273do
276 do 274 do
277 local _1 275 local _1 = origin.transform.root.gameObject:Parents()
278 _1 = origin.transform.root.gameObject:Parents() 276 local _2 = _1:Descendants()
279 local _2 277 local _3 = _2:SelectEnable()
280 _2 = _1:Descendants() 278 local _4 = _3:SelectVisible()
281 local _3 279 local _5 = _4:TagEqual("fx")
282 _3 = _2:SelectEnable() 280 local _6 = _5:Where(function(x)
283 local _4
284 _4 = _3:SelectVisible()
285 local _5
286 _5 = _4:TagEqual("fx")
287 local _6
288 _6 = _5:Where(function(x)
289 return x.name:EndsWith("(Clone)") 281 return x.name:EndsWith("(Clone)")
290 end) 282 end)
291 _6:Destroy() 283 _6:Destroy()
diff --git a/spec/outputs/plus.lua b/spec/outputs/plus.lua
index bd89bfe..dda0660 100644
--- a/spec/outputs/plus.lua
+++ b/spec/outputs/plus.lua
@@ -65,7 +65,6 @@ backpack = {
65local start = { 65local start = {
66 something = "cold" 66 something = "cold"
67} 67}
68local bathe 68local bathe = {
69bathe = {
70 on = "fire" 69 on = "fire"
71} 70}
diff --git a/spec/outputs/unicode/macro.lua b/spec/outputs/unicode/macro.lua
index e2195e4..099080f 100644
--- a/spec/outputs/unicode/macro.lua
+++ b/spec/outputs/unicode/macro.lua
@@ -167,13 +167,11 @@ end
167do 167do
168 local _u53d8_u91cfa = 8 168 local _u53d8_u91cfa = 8
169 _u53d8_u91cfa = (function() 169 _u53d8_u91cfa = (function()
170 local _u53d8_u91cfa 170 local _u53d8_u91cfa = 1
171 _u53d8_u91cfa = 1
172 return _u53d8_u91cfa + 1 171 return _u53d8_u91cfa + 1
173 end)() 172 end)()
174 _u53d8_u91cfa = _u53d8_u91cfa + (function() 173 _u53d8_u91cfa = _u53d8_u91cfa + (function()
175 local _u53d8_u91cfa 174 local _u53d8_u91cfa = 1
176 _u53d8_u91cfa = 1
177 return _u53d8_u91cfa + 1 175 return _u53d8_u91cfa + 1
178 end)() 176 end)()
179 _u6253_u5370(_u53d8_u91cfa) 177 _u6253_u5370(_u53d8_u91cfa)
diff --git a/spec/outputs/unicode/plus.lua b/spec/outputs/unicode/plus.lua
index 75e4aac..adce62e 100644
--- a/spec/outputs/unicode/plus.lua
+++ b/spec/outputs/unicode/plus.lua
@@ -67,7 +67,6 @@ _u80cc_u5305 = {
67local _u5f00_u59cb = { 67local _u5f00_u59cb = {
68 ["东西"] = "冷" 68 ["东西"] = "冷"
69} 69}
70local _u6d17_u6fa1 70local _u6d17_u6fa1 = {
71_u6d17_u6fa1 = {
72 ["在"] = "火" 71 ["在"] = "火"
73} 72}