From 0ccf4408271c8a0d147e3cf25689810862e8c1db Mon Sep 17 00:00:00 2001 From: Li Jin Date: Tue, 24 Feb 2026 12:24:10 +0800 Subject: Cleaned up and fixed more comment reserving codes. --- spec/inputs/switch.yue | 14 +++++++++ spec/inputs/whitespace.yue | 47 ++++++++++++++++++++++++++++++ spec/outputs/codes_from_doc_de.lua | 4 +-- spec/outputs/codes_from_doc_en.lua | 4 +-- spec/outputs/codes_from_doc_id-id.lua | 4 +-- spec/outputs/codes_from_doc_pt-br.lua | 4 +-- spec/outputs/codes_from_doc_zh.lua | 4 +-- spec/outputs/macro.lua | 8 ++--- spec/outputs/metatable.lua | 2 +- spec/outputs/switch.lua | 44 ++++++++++++++++++++++++++++ spec/outputs/test/attrib_spec.lua | 4 +-- spec/outputs/test/close_attribute_spec.lua | 2 +- spec/outputs/test/in_expression_spec.lua | 6 ++-- spec/outputs/test/tables_advanced_spec.lua | 2 +- spec/outputs/unicode/macro.lua | 8 ++--- spec/outputs/unicode/metatable.lua | 2 +- spec/outputs/whitespace.lua | 43 +++++++++++++++++++++++++++ 17 files changed, 175 insertions(+), 27 deletions(-) (limited to 'spec') diff --git a/spec/inputs/switch.yue b/spec/inputs/switch.yue index 2b0669c..b969a17 100644 --- a/spec/inputs/switch.yue +++ b/spec/inputs/switch.yue @@ -289,4 +289,18 @@ do handlePath ["admin", "logs", "view"] +do + _check_cond_expr = (iftyp, n, args) -> + sw = { ct: iftyp, op: op } + why = switch sw + -- woo + when ct: 'if', op: '==' + 'never' + when ct: 'if', op: '!=' + 'always' + when ct: 'unless', op: '==' + 'always' + when ct: 'unless', op: '!=' + 'never' + nil diff --git a/spec/inputs/whitespace.yue b/spec/inputs/whitespace.yue index a999143..d0acdde 100644 --- a/spec/inputs/whitespace.yue +++ b/spec/inputs/whitespace.yue @@ -198,5 +198,52 @@ do -- two b: -> -- 2 +do + tb = { + + -- hello + print 123 + -- abc + + + + + + + + abc: 1 + + + -- xyz + c: "" + + + z: 998 + + : -> + + -- hello + : -> + --[[OK]] --[[OK]]--good + : -> + } + + class CY + -- init xa + xa = 1 + -- init xb + local xb = 2 + + -- new + new: => print xa, xb, xc, xd + + + -- init xc + const xc = 3 + + -- wait + + -- init xd + close xd = : => nil diff --git a/spec/outputs/codes_from_doc_de.lua b/spec/outputs/codes_from_doc_de.lua index 385dbae..70783f1 100644 --- a/spec/outputs/codes_from_doc_de.lua +++ b/spec/outputs/codes_from_doc_de.lua @@ -2820,7 +2820,7 @@ end), 0, function(a, b) return a + b end)) local apple = setmetatable({ - size = 15, + size = 15 }, { __index = { color = 0x00ffff @@ -2898,7 +2898,7 @@ end), 0, function(a, b) return a + b end)) local apple = setmetatable({ - size = 15, + size = 15 }, { __index = { color = 0x00ffff diff --git a/spec/outputs/codes_from_doc_en.lua b/spec/outputs/codes_from_doc_en.lua index 2d9c8cf..4cfcaee 100644 --- a/spec/outputs/codes_from_doc_en.lua +++ b/spec/outputs/codes_from_doc_en.lua @@ -2820,7 +2820,7 @@ end), 0, function(a, b) return a + b end)) local apple = setmetatable({ - size = 15, + size = 15 }, { __index = { color = 0x00ffff @@ -2898,7 +2898,7 @@ end), 0, function(a, b) return a + b end)) local apple = setmetatable({ - size = 15, + size = 15 }, { __index = { color = 0x00ffff diff --git a/spec/outputs/codes_from_doc_id-id.lua b/spec/outputs/codes_from_doc_id-id.lua index 7af01b7..a960fd6 100644 --- a/spec/outputs/codes_from_doc_id-id.lua +++ b/spec/outputs/codes_from_doc_id-id.lua @@ -2820,7 +2820,7 @@ end), 0, function(a, b) return a + b end)) local apple = setmetatable({ - size = 15, + size = 15 }, { __index = { color = 0x00ffff @@ -2898,7 +2898,7 @@ end), 0, function(a, b) return a + b end)) local apple = setmetatable({ - size = 15, + size = 15 }, { __index = { color = 0x00ffff diff --git a/spec/outputs/codes_from_doc_pt-br.lua b/spec/outputs/codes_from_doc_pt-br.lua index dfe0108..d047596 100644 --- a/spec/outputs/codes_from_doc_pt-br.lua +++ b/spec/outputs/codes_from_doc_pt-br.lua @@ -2820,7 +2820,7 @@ end), 0, function(a, b) return a + b end)) local apple = setmetatable({ - size = 15, + size = 15 }, { __index = { color = 0x00ffff @@ -2898,7 +2898,7 @@ end), 0, function(a, b) return a + b end)) local apple = setmetatable({ - size = 15, + size = 15 }, { __index = { color = 0x00ffff diff --git a/spec/outputs/codes_from_doc_zh.lua b/spec/outputs/codes_from_doc_zh.lua index 6db4a43..2065307 100644 --- a/spec/outputs/codes_from_doc_zh.lua +++ b/spec/outputs/codes_from_doc_zh.lua @@ -2820,7 +2820,7 @@ end), 0, function(a, b) return a + b end)) local apple = setmetatable({ - size = 15, + size = 15 }, { __index = { color = 0x00ffff @@ -2898,7 +2898,7 @@ end), 0, function(a, b) return a + b end)) local apple = setmetatable({ - size = 15, + size = 15 }, { __index = { color = 0x00ffff diff --git a/spec/outputs/macro.lua b/spec/outputs/macro.lua index 89c6e63..91048e6 100644 --- a/spec/outputs/macro.lua +++ b/spec/outputs/macro.lua @@ -301,28 +301,28 @@ end):Destroy() end print((setmetatable({ 'abc', - a = 123, + a = 123 }, { __call = function(self) return 998 end }))[1], (setmetatable({ 'abc', - a = 123, + a = 123 }, { __call = function(self) return 998 end })).a, (setmetatable({ 'abc', - a = 123, + a = 123 }, { __call = function(self) return 998 end }))(), setmetatable({ 'abc', - a = 123, + a = 123 }, { __call = function(self) return 998 diff --git a/spec/outputs/metatable.lua b/spec/outputs/metatable.lua index 974a6e4..eda5dee 100644 --- a/spec/outputs/metatable.lua +++ b/spec/outputs/metatable.lua @@ -1,5 +1,5 @@ local a = setmetatable({ - close = true, + close = true }, { __close = function(self) return print("out of scope") diff --git a/spec/outputs/switch.lua b/spec/outputs/switch.lua index 7c1004b..fb674e9 100644 --- a/spec/outputs/switch.lua +++ b/spec/outputs/switch.lua @@ -777,4 +777,48 @@ do "view" }) end +do + local _check_cond_expr + _check_cond_expr = function(iftyp, n, args) + local sw = { + ct = iftyp, + op = op + } + local why + local _type_0 = type(sw) + local _tab_0 = "table" == _type_0 or "userdata" == _type_0 + local _match_0 = false + if _tab_0 then + if 'if' == sw.ct and '==' == sw.op then + _match_0 = true + why = 'never' + end + end + if not _match_0 then + local _match_1 = false + if _tab_0 then + if 'if' == sw.ct and '!=' == sw.op then + _match_1 = true + why = 'always' + end + end + if not _match_1 then + local _match_2 = false + if _tab_0 then + if 'unless' == sw.ct and '==' == sw.op then + _match_2 = true + why = 'always' + end + end + if not _match_2 then + if _tab_0 then + if 'unless' == sw.ct and '!=' == sw.op then + why = 'never' + end + end + end + end + end + end +end return nil diff --git a/spec/outputs/test/attrib_spec.lua b/spec/outputs/test/attrib_spec.lua index d459bbb..7408fa7 100644 --- a/spec/outputs/test/attrib_spec.lua +++ b/spec/outputs/test/attrib_spec.lua @@ -78,13 +78,13 @@ return describe("attrib", function() local result if true then result = setmetatable({ - value = 42, + value = 42 }, { __close = function() end }) else result = setmetatable({ - value = 0, + value = 0 }, { __close = function() end }) diff --git a/spec/outputs/test/close_attribute_spec.lua b/spec/outputs/test/close_attribute_spec.lua index cc64da8..40a3a0d 100644 --- a/spec/outputs/test/close_attribute_spec.lua +++ b/spec/outputs/test/close_attribute_spec.lua @@ -72,7 +72,7 @@ return describe("close attribute", function() it("should work with fat arrow", function() local closed = false local obj = setmetatable({ - value = 10, + value = 10 }, { __close = function(self) closed = true diff --git a/spec/outputs/test/in_expression_spec.lua b/spec/outputs/test/in_expression_spec.lua index e5af45b..83c542c 100644 --- a/spec/outputs/test/in_expression_spec.lua +++ b/spec/outputs/test/in_expression_spec.lua @@ -341,19 +341,19 @@ return describe("in expression", function() local nested = { setmetatable({ 1, - 2, + 2 }, { __eq = eq }), setmetatable({ 3, - 4, + 4 }, { __eq = eq }), setmetatable({ 5, - 6, + 6 }, { __eq = eq }) diff --git a/spec/outputs/test/tables_advanced_spec.lua b/spec/outputs/test/tables_advanced_spec.lua index de36953..9723313 100644 --- a/spec/outputs/test/tables_advanced_spec.lua +++ b/spec/outputs/test/tables_advanced_spec.lua @@ -214,7 +214,7 @@ return describe("advanced tables", function() item = "test", new = function() return "created" - end, + end }, { __close = function() return "closed" diff --git a/spec/outputs/unicode/macro.lua b/spec/outputs/unicode/macro.lua index b4e78cd..e7e3ada 100644 --- a/spec/outputs/unicode/macro.lua +++ b/spec/outputs/unicode/macro.lua @@ -319,28 +319,28 @@ end):_u6467_u6bc1() end _u6253_u5370((setmetatable({ 'abc', - ["字段a"] = 123, + ["字段a"] = 123 }, { __call = function(self) return 998 end }))[1], (setmetatable({ 'abc', - ["字段a"] = 123, + ["字段a"] = 123 }, { __call = function(self) return 998 end }))["字段a"], (setmetatable({ 'abc', - ["字段a"] = 123, + ["字段a"] = 123 }, { __call = function(self) return 998 end }))(), setmetatable({ 'abc', - ["字段a"] = 123, + ["字段a"] = 123 }, { __call = function(self) return 998 diff --git a/spec/outputs/unicode/metatable.lua b/spec/outputs/unicode/metatable.lua index 970e52c..4419634 100644 --- a/spec/outputs/unicode/metatable.lua +++ b/spec/outputs/unicode/metatable.lua @@ -1,5 +1,5 @@ local _u53d8_u91cfa = setmetatable({ - ["关闭"] = true, + ["关闭"] = true }, { __close = function(self) return _u6253_u5370("离开作用域") diff --git a/spec/outputs/whitespace.lua b/spec/outputs/whitespace.lua index 60e98bb..a0d225f 100644 --- a/spec/outputs/whitespace.lua +++ b/spec/outputs/whitespace.lua @@ -140,4 +140,47 @@ do _base_0.__class = _class_0 tb3 = _class_0 end +do + local tb = setmetatable({ + print(123), + abc = 1, + c = "", + z = 998 + }, { + __close = function() end, + __eq = function() end, + __call = function() end + }) + local CY + local _class_0 + local xa, xb, xc, xd + local _base_0 = { } + if _base_0.__index == nil then + _base_0.__index = _base_0 + end + _class_0 = setmetatable({ + __init = function(self) + return print(xa, xb, xc, xd) + end, + __base = _base_0, + __name = "CY" + }, { + __index = _base_0, + __call = function(cls, ...) + local _self_0 = setmetatable({ }, _base_0) + cls.__init(_self_0, ...) + return _self_0 + end + }) + _base_0.__class = _class_0 + local self = _class_0; + xa = 1 + xb = 2 + xc = 3 + xd = setmetatable({ }, { + __close = function(self) end + }) + local _close_0 = xd + CY = _class_0 +end return nil -- cgit v1.2.3-55-g6feb