aboutsummaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/inputs/switch.yue14
-rw-r--r--spec/inputs/whitespace.yue47
-rw-r--r--spec/outputs/codes_from_doc_de.lua4
-rw-r--r--spec/outputs/codes_from_doc_en.lua4
-rw-r--r--spec/outputs/codes_from_doc_id-id.lua4
-rw-r--r--spec/outputs/codes_from_doc_pt-br.lua4
-rw-r--r--spec/outputs/codes_from_doc_zh.lua4
-rw-r--r--spec/outputs/macro.lua8
-rw-r--r--spec/outputs/metatable.lua2
-rw-r--r--spec/outputs/switch.lua44
-rw-r--r--spec/outputs/test/attrib_spec.lua4
-rw-r--r--spec/outputs/test/close_attribute_spec.lua2
-rw-r--r--spec/outputs/test/in_expression_spec.lua6
-rw-r--r--spec/outputs/test/tables_advanced_spec.lua2
-rw-r--r--spec/outputs/unicode/macro.lua8
-rw-r--r--spec/outputs/unicode/metatable.lua2
-rw-r--r--spec/outputs/whitespace.lua43
17 files changed, 175 insertions, 27 deletions
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
289 289
290 handlePath ["admin", "logs", "view"] 290 handlePath ["admin", "logs", "view"]
291 291
292do
293 _check_cond_expr = (iftyp, n, args) ->
294 sw = { ct: iftyp, op: op }
295 why = switch sw
296 -- woo
297 when ct: 'if', op: '=='
298 'never'
299 when ct: 'if', op: '!='
300 'always'
301 when ct: 'unless', op: '=='
302 'always'
303 when ct: 'unless', op: '!='
304 'never'
305
292nil 306nil
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
198 -- two 198 -- two
199 b: -> -- 2 199 b: -> -- 2
200 200
201do
202 tb = {
203
204 -- hello
205 print 123
206 -- abc
207
208
209
210
211
212
213
214 abc: 1
215
216
217 -- xyz
218 c: ""
219
220
221 z: 998
222
223 <close>: ->
224
225 -- hello
226 <eq>: ->
227 --[[OK]] --[[OK]]--good
228 <call>: ->
229 }
230
231 class CY
232 -- init xa
233 xa = 1
234 -- init xb
235 local xb = 2
236
237 -- new
238 new: => print xa, xb, xc, xd
239
240
241 -- init xc
242 const xc = 3
243
244 -- wait
245
246 -- init xd
247 close xd = <close>: =>
201 248
202nil 249nil
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)
2820 return a + b 2820 return a + b
2821end)) 2821end))
2822local apple = setmetatable({ 2822local apple = setmetatable({
2823 size = 15, 2823 size = 15
2824}, { 2824}, {
2825 __index = { 2825 __index = {
2826 color = 0x00ffff 2826 color = 0x00ffff
@@ -2898,7 +2898,7 @@ end), 0, function(a, b)
2898 return a + b 2898 return a + b
2899end)) 2899end))
2900local apple = setmetatable({ 2900local apple = setmetatable({
2901 size = 15, 2901 size = 15
2902}, { 2902}, {
2903 __index = { 2903 __index = {
2904 color = 0x00ffff 2904 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)
2820 return a + b 2820 return a + b
2821end)) 2821end))
2822local apple = setmetatable({ 2822local apple = setmetatable({
2823 size = 15, 2823 size = 15
2824}, { 2824}, {
2825 __index = { 2825 __index = {
2826 color = 0x00ffff 2826 color = 0x00ffff
@@ -2898,7 +2898,7 @@ end), 0, function(a, b)
2898 return a + b 2898 return a + b
2899end)) 2899end))
2900local apple = setmetatable({ 2900local apple = setmetatable({
2901 size = 15, 2901 size = 15
2902}, { 2902}, {
2903 __index = { 2903 __index = {
2904 color = 0x00ffff 2904 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)
2820 return a + b 2820 return a + b
2821end)) 2821end))
2822local apple = setmetatable({ 2822local apple = setmetatable({
2823 size = 15, 2823 size = 15
2824}, { 2824}, {
2825 __index = { 2825 __index = {
2826 color = 0x00ffff 2826 color = 0x00ffff
@@ -2898,7 +2898,7 @@ end), 0, function(a, b)
2898 return a + b 2898 return a + b
2899end)) 2899end))
2900local apple = setmetatable({ 2900local apple = setmetatable({
2901 size = 15, 2901 size = 15
2902}, { 2902}, {
2903 __index = { 2903 __index = {
2904 color = 0x00ffff 2904 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)
2820 return a + b 2820 return a + b
2821end)) 2821end))
2822local apple = setmetatable({ 2822local apple = setmetatable({
2823 size = 15, 2823 size = 15
2824}, { 2824}, {
2825 __index = { 2825 __index = {
2826 color = 0x00ffff 2826 color = 0x00ffff
@@ -2898,7 +2898,7 @@ end), 0, function(a, b)
2898 return a + b 2898 return a + b
2899end)) 2899end))
2900local apple = setmetatable({ 2900local apple = setmetatable({
2901 size = 15, 2901 size = 15
2902}, { 2902}, {
2903 __index = { 2903 __index = {
2904 color = 0x00ffff 2904 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)
2820 return a + b 2820 return a + b
2821end)) 2821end))
2822local apple = setmetatable({ 2822local apple = setmetatable({
2823 size = 15, 2823 size = 15
2824}, { 2824}, {
2825 __index = { 2825 __index = {
2826 color = 0x00ffff 2826 color = 0x00ffff
@@ -2898,7 +2898,7 @@ end), 0, function(a, b)
2898 return a + b 2898 return a + b
2899end)) 2899end))
2900local apple = setmetatable({ 2900local apple = setmetatable({
2901 size = 15, 2901 size = 15
2902}, { 2902}, {
2903 __index = { 2903 __index = {
2904 color = 0x00ffff 2904 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()
301end 301end
302print((setmetatable({ 302print((setmetatable({
303 'abc', 303 'abc',
304 a = 123, 304 a = 123
305}, { 305}, {
306 __call = function(self) 306 __call = function(self)
307 return 998 307 return 998
308 end 308 end
309}))[1], (setmetatable({ 309}))[1], (setmetatable({
310 'abc', 310 'abc',
311 a = 123, 311 a = 123
312}, { 312}, {
313 __call = function(self) 313 __call = function(self)
314 return 998 314 return 998
315 end 315 end
316})).a, (setmetatable({ 316})).a, (setmetatable({
317 'abc', 317 'abc',
318 a = 123, 318 a = 123
319}, { 319}, {
320 __call = function(self) 320 __call = function(self)
321 return 998 321 return 998
322 end 322 end
323}))(), setmetatable({ 323}))(), setmetatable({
324 'abc', 324 'abc',
325 a = 123, 325 a = 123
326}, { 326}, {
327 __call = function(self) 327 __call = function(self)
328 return 998 328 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 @@
1local a = setmetatable({ 1local a = setmetatable({
2 close = true, 2 close = true
3}, { 3}, {
4 __close = function(self) 4 __close = function(self)
5 return print("out of scope") 5 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
777 "view" 777 "view"
778 }) 778 })
779end 779end
780do
781 local _check_cond_expr
782 _check_cond_expr = function(iftyp, n, args)
783 local sw = {
784 ct = iftyp,
785 op = op
786 }
787 local why
788 local _type_0 = type(sw)
789 local _tab_0 = "table" == _type_0 or "userdata" == _type_0
790 local _match_0 = false
791 if _tab_0 then
792 if 'if' == sw.ct and '==' == sw.op then
793 _match_0 = true
794 why = 'never'
795 end
796 end
797 if not _match_0 then
798 local _match_1 = false
799 if _tab_0 then
800 if 'if' == sw.ct and '!=' == sw.op then
801 _match_1 = true
802 why = 'always'
803 end
804 end
805 if not _match_1 then
806 local _match_2 = false
807 if _tab_0 then
808 if 'unless' == sw.ct and '==' == sw.op then
809 _match_2 = true
810 why = 'always'
811 end
812 end
813 if not _match_2 then
814 if _tab_0 then
815 if 'unless' == sw.ct and '!=' == sw.op then
816 why = 'never'
817 end
818 end
819 end
820 end
821 end
822 end
823end
780return nil 824return 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()
78 local result 78 local result
79 if true then 79 if true then
80 result = setmetatable({ 80 result = setmetatable({
81 value = 42, 81 value = 42
82 }, { 82 }, {
83 __close = function() end 83 __close = function() end
84 }) 84 })
85 else 85 else
86 result = setmetatable({ 86 result = setmetatable({
87 value = 0, 87 value = 0
88 }, { 88 }, {
89 __close = function() end 89 __close = function() end
90 }) 90 })
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()
72 it("should work with fat arrow", function() 72 it("should work with fat arrow", function()
73 local closed = false 73 local closed = false
74 local obj = setmetatable({ 74 local obj = setmetatable({
75 value = 10, 75 value = 10
76 }, { 76 }, {
77 __close = function(self) 77 __close = function(self)
78 closed = true 78 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()
341 local nested = { 341 local nested = {
342 setmetatable({ 342 setmetatable({
343 1, 343 1,
344 2, 344 2
345 }, { 345 }, {
346 __eq = eq 346 __eq = eq
347 }), 347 }),
348 setmetatable({ 348 setmetatable({
349 3, 349 3,
350 4, 350 4
351 }, { 351 }, {
352 __eq = eq 352 __eq = eq
353 }), 353 }),
354 setmetatable({ 354 setmetatable({
355 5, 355 5,
356 6, 356 6
357 }, { 357 }, {
358 __eq = eq 358 __eq = eq
359 }) 359 })
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()
214 item = "test", 214 item = "test",
215 new = function() 215 new = function()
216 return "created" 216 return "created"
217 end, 217 end
218 }, { 218 }, {
219 __close = function() 219 __close = function()
220 return "closed" 220 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()
319end 319end
320_u6253_u5370((setmetatable({ 320_u6253_u5370((setmetatable({
321 'abc', 321 'abc',
322 ["字段a"] = 123, 322 ["字段a"] = 123
323}, { 323}, {
324 __call = function(self) 324 __call = function(self)
325 return 998 325 return 998
326 end 326 end
327}))[1], (setmetatable({ 327}))[1], (setmetatable({
328 'abc', 328 'abc',
329 ["字段a"] = 123, 329 ["字段a"] = 123
330}, { 330}, {
331 __call = function(self) 331 __call = function(self)
332 return 998 332 return 998
333 end 333 end
334}))["字段a"], (setmetatable({ 334}))["字段a"], (setmetatable({
335 'abc', 335 'abc',
336 ["字段a"] = 123, 336 ["字段a"] = 123
337}, { 337}, {
338 __call = function(self) 338 __call = function(self)
339 return 998 339 return 998
340 end 340 end
341}))(), setmetatable({ 341}))(), setmetatable({
342 'abc', 342 'abc',
343 ["字段a"] = 123, 343 ["字段a"] = 123
344}, { 344}, {
345 __call = function(self) 345 __call = function(self)
346 return 998 346 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 @@
1local _u53d8_u91cfa = setmetatable({ 1local _u53d8_u91cfa = setmetatable({
2 ["关闭"] = true, 2 ["关闭"] = true
3}, { 3}, {
4 __close = function(self) 4 __close = function(self)
5 return _u6253_u5370("离开作用域") 5 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
140 _base_0.__class = _class_0 140 _base_0.__class = _class_0
141 tb3 = _class_0 141 tb3 = _class_0
142end 142end
143do
144 local tb = setmetatable({
145 print(123),
146 abc = 1,
147 c = "",
148 z = 998
149 }, {
150 __close = function() end,
151 __eq = function() end,
152 __call = function() end
153 })
154 local CY
155 local _class_0
156 local xa, xb, xc, xd
157 local _base_0 = { }
158 if _base_0.__index == nil then
159 _base_0.__index = _base_0
160 end
161 _class_0 = setmetatable({
162 __init = function(self)
163 return print(xa, xb, xc, xd)
164 end,
165 __base = _base_0,
166 __name = "CY"
167 }, {
168 __index = _base_0,
169 __call = function(cls, ...)
170 local _self_0 = setmetatable({ }, _base_0)
171 cls.__init(_self_0, ...)
172 return _self_0
173 end
174 })
175 _base_0.__class = _class_0
176 local self = _class_0;
177 xa = 1
178 xb = 2
179 xc = 3
180 xd = setmetatable({ }, {
181 __close = function(self) end
182 })
183 local _close_0 <close> = xd
184 CY = _class_0
185end
143return nil 186return nil