aboutsummaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2025-01-31 23:17:45 +0800
committerLi Jin <dragon-fly@qq.com>2025-01-31 23:19:02 +0800
commitd1878f2b8eb1644205c5e0b641fd092e8b222766 (patch)
tree17f1108e35d845364f928e8f9c2178c7d2d0d902 /spec
parent8124020b3827a8f86970ef8f1efb164e5e110755 (diff)
downloadyuescript-d1878f2b8eb1644205c5e0b641fd092e8b222766.tar.gz
yuescript-d1878f2b8eb1644205c5e0b641fd092e8b222766.tar.bz2
yuescript-d1878f2b8eb1644205c5e0b641fd092e8b222766.zip
Aligned Lua inserter macro behavior with common Yue macro.v0.27.0
Diffstat (limited to 'spec')
-rw-r--r--spec/outputs/ambiguous.lua4
-rw-r--r--spec/outputs/codes_from_doc.lua18
-rw-r--r--spec/outputs/codes_from_doc_zh.lua14
-rw-r--r--spec/outputs/macro.lua18
-rw-r--r--spec/outputs/unicode/ambiguous.lua4
-rw-r--r--spec/outputs/unicode/macro.lua14
6 files changed, 64 insertions, 8 deletions
diff --git a/spec/outputs/ambiguous.lua b/spec/outputs/ambiguous.lua
index 3c82a03..fc43d63 100644
--- a/spec/outputs/ambiguous.lua
+++ b/spec/outputs/ambiguous.lua
@@ -39,9 +39,11 @@ end
39do 39do
40 print() 40 print()
41 async_fn(function() 41 async_fn(function()
42 print(); 42 print()
43 do
43--[[a comment to insert]] 44--[[a comment to insert]]
44 (haha)() 45 (haha)()
46 end
45 return nil 47 return nil
46 end) 48 end)
47end 49end
diff --git a/spec/outputs/codes_from_doc.lua b/spec/outputs/codes_from_doc.lua
index 5c262d3..74db469 100644
--- a/spec/outputs/codes_from_doc.lua
+++ b/spec/outputs/codes_from_doc.lua
@@ -59,16 +59,21 @@ do
59end 59end
60local funcA 60local funcA
61funcA = function() 61funcA = function()
62 return "fail to assign to the Yue defined variable" 62 return "fail to assign to the Yue macro defined variable"
63end 63end
64do
64local function funcB() end 65local function funcB() end
66end
67local funcB
65funcB = function() 68funcB = function()
66 return "assign to the Lua defined variable" 69 return "fail to assign to the Lua macro defined variable"
67end 70end
71do
68-- raw Lua codes insertion 72-- raw Lua codes insertion
69if cond then 73if cond then
70 print("output") 74 print("output")
71end 75end
76end
72print("yuescript") 77print("yuescript")
73print(3) 78print(3)
74print("Valid enum type:", "Static") 79print("Valid enum type:", "Static")
@@ -2065,16 +2070,21 @@ do
2065end 2070end
2066local funcA 2071local funcA
2067funcA = function() 2072funcA = function()
2068 return "fail to assign to the Yue defined variable" 2073 return "fail to assign to the Yue macro defined variable"
2069end 2074end
2075do
2070local function funcB() end 2076local function funcB() end
2077end
2078local funcB
2071funcB = function() 2079funcB = function()
2072 return "assign to the Lua defined variable" 2080 return "fail to assign to the Lua macro defined variable"
2073end 2081end
2082do
2074-- raw Lua codes insertion 2083-- raw Lua codes insertion
2075if cond then 2084if cond then
2076 print("output") 2085 print("output")
2077end 2086end
2087end
2078print("yuescript") 2088print("yuescript")
2079print(3) 2089print(3)
2080print("Valid enum type:", "Static") 2090print("Valid enum type:", "Static")
diff --git a/spec/outputs/codes_from_doc_zh.lua b/spec/outputs/codes_from_doc_zh.lua
index c6d5388..1a10555 100644
--- a/spec/outputs/codes_from_doc_zh.lua
+++ b/spec/outputs/codes_from_doc_zh.lua
@@ -61,14 +61,19 @@ local funcA
61funcA = function() 61funcA = function()
62 return "无法访问宏生成月之脚本里定义的变量" 62 return "无法访问宏生成月之脚本里定义的变量"
63end 63end
64do
64local function funcB() end 65local function funcB() end
66end
67local funcB
65funcB = function() 68funcB = function()
66 return "访问宏生成Lua代码里定义的变量" 69 return "无法访问宏生成 Lua 代码里定义的变量"
67end 70end
71do
68-- 插入原始Lua代码 72-- 插入原始Lua代码
69if cond then 73if cond then
70 print("输出") 74 print("输出")
71end 75end
76end
72print("yuescript") 77print("yuescript")
73print(3) 78print(3)
74print("有效的枚举类型:", "Static") 79print("有效的枚举类型:", "Static")
@@ -2061,14 +2066,19 @@ local funcA
2061funcA = function() 2066funcA = function()
2062 return "无法访问宏生成月之脚本里定义的变量" 2067 return "无法访问宏生成月之脚本里定义的变量"
2063end 2068end
2069do
2064local function funcB() end 2070local function funcB() end
2071end
2072local funcB
2065funcB = function() 2073funcB = function()
2066 return "访问宏生成Lua代码里定义的变量" 2074 return "无法访问宏生成 Lua 代码里定义的变量"
2067end 2075end
2076do
2068-- 插入原始Lua代码 2077-- 插入原始Lua代码
2069if cond then 2078if cond then
2070 print("输出") 2079 print("输出")
2071end 2080end
2081end
2072print("yuescript") 2082print("yuescript")
2073print(3) 2083print(3)
2074print("有效的枚举类型:", "Static") 2084print("有效的枚举类型:", "Static")
diff --git a/spec/outputs/macro.lua b/spec/outputs/macro.lua
index 7163077..aa74ed9 100644
--- a/spec/outputs/macro.lua
+++ b/spec/outputs/macro.lua
@@ -5,7 +5,9 @@ do
5 end 5 end
6 print(456) 6 print(456)
7 do 7 do
8 do
8-- TODO: "todo in a do block" 9-- TODO: "todo in a do block"
10 end
9 end 11 end
10end 12end
11do 13do
@@ -201,13 +203,17 @@ do
201 print(a) 203 print(a)
202end 204end
203local x = 0 205local x = 0
206do
204local function f(a) 207local function f(a)
205 return a + 1 208 return a + 1
206end 209end
207x = x + f(3) 210x = x + f(3)
211end
212do
208function tb:func() 213function tb:func()
209 print(123) 214 print(123)
210end 215end
216end
211print(x) 217print(x)
212local sel 218local sel
213sel = function(a, b, c) 219sel = function(a, b, c)
@@ -217,6 +223,7 @@ sel = function(a, b, c)
217 return c 223 return c
218 end 224 end
219end 225end
226do
220local function sel(a, b, c) 227local function sel(a, b, c)
221 if a then 228 if a then
222 return b 229 return b
@@ -224,10 +231,15 @@ local function sel(a, b, c)
224 return c 231 return c
225 end 232 end
226end 233end
234end
235do
227local function dummy() 236local function dummy()
228 237
229end 238end
239end
240do
230-- a comment here 241-- a comment here
242end
231local _ = require('underscore') 243local _ = require('underscore')
232local a = ((((_({ 244local a = ((((_({
233 1, 245 1,
@@ -279,9 +291,11 @@ do
279 _6:Destroy() 291 _6:Destroy()
280 end 292 end
281end 293end
294do
282origin.transform.root.gameObject:Parents():Descendants():SelectEnable():SelectVisible():TagEqual("fx"):Where(function(x) 295origin.transform.root.gameObject:Parents():Descendants():SelectEnable():SelectVisible():TagEqual("fx"):Where(function(x)
283 return x.name:EndsWith("(Clone)") 296 return x.name:EndsWith("(Clone)")
284end):Destroy() 297end):Destroy()
298end
285print((setmetatable({ 299print((setmetatable({
286 'abc', 300 'abc',
287 a = 123, 301 a = 123,
@@ -313,7 +327,9 @@ print((setmetatable({
313})) 327}))
314print("current line: " .. tostring(323)) 328print("current line: " .. tostring(323))
315do 329do
330 do
316-- TODO 331-- TODO
332 end
317end 333end
318do 334do
319 print(1) 335 print(1)
@@ -336,7 +352,9 @@ do
336 end 352 end
337 local f1 353 local f1
338 f1 = function() 354 f1 = function()
355 do
339tb:func(123) 356tb:func(123)
357 end
340 return 358 return
341 end 359 end
342end 360end
diff --git a/spec/outputs/unicode/ambiguous.lua b/spec/outputs/unicode/ambiguous.lua
index ac90016..704b311 100644
--- a/spec/outputs/unicode/ambiguous.lua
+++ b/spec/outputs/unicode/ambiguous.lua
@@ -39,9 +39,11 @@ end
39do 39do
40 _u6253_u5370() 40 _u6253_u5370()
41 _u5f02_u6b65_u51fd_u6570(function() 41 _u5f02_u6b65_u51fd_u6570(function()
42 _u6253_u5370(); 42 _u6253_u5370()
43 do
43--[[a comment to insert]] 44--[[a comment to insert]]
44 (haha)() 45 (haha)()
46 end
45 return nil 47 return nil
46 end) 48 end)
47end 49end
diff --git a/spec/outputs/unicode/macro.lua b/spec/outputs/unicode/macro.lua
index 069f429..e2195e4 100644
--- a/spec/outputs/unicode/macro.lua
+++ b/spec/outputs/unicode/macro.lua
@@ -179,13 +179,17 @@ do
179 _u6253_u5370(_u53d8_u91cfa) 179 _u6253_u5370(_u53d8_u91cfa)
180end 180end
181local _u53d8_u91cfx = 0 181local _u53d8_u91cfx = 0
182do
182local function f(a) 183local function f(a)
183 return a + 1 184 return a + 1
184end 185end
185x = x + f(3) 186x = x + f(3)
187end
188do
186function tb:func() 189function tb:func()
187 print(123) 190 print(123)
188end 191end
192end
189_u6253_u5370(_u53d8_u91cfx) 193_u6253_u5370(_u53d8_u91cfx)
190local sel 194local sel
191sel = function(_u53c2_u6570a, _u53c2_u6570b, _u53c2_u6570c) 195sel = function(_u53c2_u6570a, _u53c2_u6570b, _u53c2_u6570c)
@@ -195,6 +199,7 @@ sel = function(_u53c2_u6570a, _u53c2_u6570b, _u53c2_u6570c)
195 return _u53c2_u6570c 199 return _u53c2_u6570c
196 end 200 end
197end 201end
202do
198local function sel(a, b, c) 203local function sel(a, b, c)
199 if a then 204 if a then
200 return b 205 return b
@@ -202,10 +207,15 @@ local function sel(a, b, c)
202 return c 207 return c
203 end 208 end
204end 209end
210end
211do
205local function dummy() 212local function dummy()
206 213
207end 214end
215end
216do
208-- 这有个注释 217-- 这有个注释
218end
209local _ = require('下划线') 219local _ = require('下划线')
210local _call_0 = (_({ 220local _call_0 = (_({
211 1, 221 1,
@@ -275,11 +285,13 @@ do
275 _6["摧毁"](_6) 285 _6["摧毁"](_6)
276 end 286 end
277end 287end
288do
278local _call_0 = _u539f_u70b9["变换"]["根节点"]["游戏对象"] 289local _call_0 = _u539f_u70b9["变换"]["根节点"]["游戏对象"]
279_call_0["父节点"](_call_0):_u540e_u4ee3():_u9009_u62e9_u542f_u7528():_u9009_u62e9_u53ef_u89c1():_u6807_u7b7e_u7b49_u4e8e("fx"):_u5176_u4e2d(function(x) 290_call_0["父节点"](_call_0):_u540e_u4ee3():_u9009_u62e9_u542f_u7528():_u9009_u62e9_u53ef_u89c1():_u6807_u7b7e_u7b49_u4e8e("fx"):_u5176_u4e2d(function(x)
280 local _call_0 = x["名称"] 291 local _call_0 = x["名称"]
281 return _call_0["结尾为"](_call_0, "(克隆)") 292 return _call_0["结尾为"](_call_0, "(克隆)")
282end):_u6467_u6bc1() 293end):_u6467_u6bc1()
294end
283_u6253_u5370((setmetatable({ 295_u6253_u5370((setmetatable({
284 'abc', 296 'abc',
285 ["字段a"] = 123, 297 ["字段a"] = 123,
@@ -311,7 +323,9 @@ _u6253_u5370((setmetatable({
311})) 323}))
312_u6253_u5370("当前代码行数: " .. tostring(268)) 324_u6253_u5370("当前代码行数: " .. tostring(268))
313do 325do
326 do
314-- 待实现 327-- 待实现
328 end
315end 329end
316do 330do
317 _u6253_u5370(1) 331 _u6253_u5370(1)