aboutsummaryrefslogtreecommitdiff
path: root/spec/outputs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--spec/outputs/codes_from_doc.lua28
-rw-r--r--spec/outputs/codes_from_doc_zh.lua28
-rw-r--r--spec/outputs/switch.lua71
-rw-r--r--spec/outputs/tables.lua22
-rw-r--r--spec/outputs/with.lua46
5 files changed, 186 insertions, 9 deletions
diff --git a/spec/outputs/codes_from_doc.lua b/spec/outputs/codes_from_doc.lua
index 3ee20bb..55be7df 100644
--- a/spec/outputs/codes_from_doc.lua
+++ b/spec/outputs/codes_from_doc.lua
@@ -339,6 +339,14 @@ func({
339 2, 339 2,
340 3 340 3
341}) 341})
342local f
343f = function()
344 return {
345 1,
346 2,
347 3
348 }
349end
342local tb = { 350local tb = {
343 name = "abc", 351 name = "abc",
344 values = { 352 values = {
@@ -1226,7 +1234,7 @@ if "Robert" == name then
1226elseif "Dan" == name or "Daniel" == name then 1234elseif "Dan" == name or "Daniel" == name then
1227 print("Your name, it's Dan") 1235 print("Your name, it's Dan")
1228else 1236else
1229 print("I don't know about your name") 1237 print("I don't know about you with name " .. tostring(name))
1230end 1238end
1231local b = 1 1239local b = 1
1232local next_number 1240local next_number
@@ -2139,6 +2147,10 @@ do
2139 _with_1["key-name"] = value 2147 _with_1["key-name"] = value
2140end 2148end
2141_with_0[#_with_0 + 1] = "abc" 2149_with_0[#_with_0 + 1] = "abc"
2150local _with_0 = obj
2151if _with_0 ~= nil then
2152 print(obj.name)
2153end
2142do 2154do
2143 local var = "hello" 2155 local var = "hello"
2144 print(var) 2156 print(var)
@@ -2548,6 +2560,14 @@ func({
2548 2, 2560 2,
2549 3 2561 3
2550}) 2562})
2563local f
2564f = function()
2565 return {
2566 1,
2567 2,
2568 3
2569 }
2570end
2551local tb = { 2571local tb = {
2552 name = "abc", 2572 name = "abc",
2553 values = { 2573 values = {
@@ -3434,7 +3454,7 @@ if "Robert" == name then
3434elseif "Dan" == name or "Daniel" == name then 3454elseif "Dan" == name or "Daniel" == name then
3435 print("Your name, it's Dan") 3455 print("Your name, it's Dan")
3436else 3456else
3437 print("I don't know about your name") 3457 print("I don't know about you with name " .. tostring(name))
3438end 3458end
3439local b = 1 3459local b = 1
3440local next_number 3460local next_number
@@ -4347,6 +4367,10 @@ do
4347 _with_1["key-name"] = value 4367 _with_1["key-name"] = value
4348end 4368end
4349_with_0[#_with_0 + 1] = "abc" 4369_with_0[#_with_0 + 1] = "abc"
4370local _with_0 = obj
4371if _with_0 ~= nil then
4372 print(obj.name)
4373end
4350do 4374do
4351 local var = "hello" 4375 local var = "hello"
4352 print(var) 4376 print(var)
diff --git a/spec/outputs/codes_from_doc_zh.lua b/spec/outputs/codes_from_doc_zh.lua
index 52204b7..399f8c1 100644
--- a/spec/outputs/codes_from_doc_zh.lua
+++ b/spec/outputs/codes_from_doc_zh.lua
@@ -339,6 +339,14 @@ func({
339 2, 339 2,
340 3 340 3
341}) 341})
342local f
343f = function()
344 return {
345 1,
346 2,
347 3
348 }
349end
342local tb = { 350local tb = {
343 name = "abc", 351 name = "abc",
344 values = { 352 values = {
@@ -1220,7 +1228,7 @@ if "Robert" == name then
1220elseif "Dan" == name or "Daniel" == name then 1228elseif "Dan" == name or "Daniel" == name then
1221 print("你的名字是Dan") 1229 print("你的名字是Dan")
1222else 1230else
1223 print("我不知道你的名字") 1231 print("我不认识,你的名字" .. tostring(name))
1224end 1232end
1225local b = 1 1233local b = 1
1226local next_number 1234local next_number
@@ -2133,6 +2141,10 @@ do
2133 _with_1["key-name"] = value 2141 _with_1["key-name"] = value
2134end 2142end
2135_with_0[#_with_0 + 1] = "abc" 2143_with_0[#_with_0 + 1] = "abc"
2144local _with_0 = obj
2145if _with_0 ~= nil then
2146 print(obj.name)
2147end
2136do 2148do
2137 local var = "hello" 2149 local var = "hello"
2138 print(var) 2150 print(var)
@@ -2542,6 +2554,14 @@ func({
2542 2, 2554 2,
2543 3 2555 3
2544}) 2556})
2557local f
2558f = function()
2559 return {
2560 1,
2561 2,
2562 3
2563 }
2564end
2545local tb = { 2565local tb = {
2546 name = "abc", 2566 name = "abc",
2547 values = { 2567 values = {
@@ -3422,7 +3442,7 @@ if "Robert" == name then
3422elseif "Dan" == name or "Daniel" == name then 3442elseif "Dan" == name or "Daniel" == name then
3423 print("你的名字是Dan") 3443 print("你的名字是Dan")
3424else 3444else
3425 print("我不知道你的名字") 3445 print("我不认识,你的名字" .. tostring(name))
3426end 3446end
3427local b = 1 3447local b = 1
3428local next_number 3448local next_number
@@ -4335,6 +4355,10 @@ do
4335 _with_1["key-name"] = value 4355 _with_1["key-name"] = value
4336end 4356end
4337_with_0[#_with_0 + 1] = "abc" 4357_with_0[#_with_0 + 1] = "abc"
4358local _with_0 = obj
4359if _with_0 ~= nil then
4360 print(obj.name)
4361end
4338do 4362do
4339 local var = "hello" 4363 local var = "hello"
4340 print(var) 4364 print(var)
diff --git a/spec/outputs/switch.lua b/spec/outputs/switch.lua
index 0f8bba2..204b816 100644
--- a/spec/outputs/switch.lua
+++ b/spec/outputs/switch.lua
@@ -656,4 +656,75 @@ do
656 end 656 end
657 end 657 end
658end 658end
659do
660 local v = "hello"
661 if "hello" == v then
662 print("matched hello")
663 else
664 print("not matched")
665 end
666end
667do
668 local f
669 f = function()
670 return "ok"
671 end
672 local val = f()
673 if "ok" == val then
674 print("it's ok")
675 end
676end
677do
678 local g
679 g = function()
680 return 42
681 end
682 local result = g()
683 if 1 == result or 2 == result then
684 print("small")
685 elseif 42 == result then
686 print("life universe everything")
687 else
688 print("other " .. tostring(result))
689 end
690end
691do
692 local check
693 check = function()
694 if true then
695 return "yes"
696 else
697 return "no"
698 end
699 end
700 local x = check()
701 if "yes" == x then
702 print("affirmative")
703 else
704 print("negative")
705 end
706end
707do
708 local t
709 t = function()
710 local tb = {
711 a = 1
712 }
713 tb.a = 2
714 return tb
715 end
716 local data = t()
717 local _type_0 = type(data)
718 local _tab_0 = "table" == _type_0 or "userdata" == _type_0
719 local _match_0 = false
720 if _tab_0 then
721 if 2 == data.a then
722 _match_0 = true
723 print("matched")
724 end
725 end
726 if not _match_0 then
727 print("not matched")
728 end
729end
659return nil 730return nil
diff --git a/spec/outputs/tables.lua b/spec/outputs/tables.lua
index f358811..3f851de 100644
--- a/spec/outputs/tables.lua
+++ b/spec/outputs/tables.lua
@@ -366,6 +366,28 @@ local menus = {
366 } 366 }
367 } 367 }
368} 368}
369_ = {
370 boolean = {
371 true,
372 false
373 },
374 float = {
375 3.14,
376 -6.8523015e+5
377 },
378 int = {
379 123,
380 -685230
381 },
382 null = {
383 nodeName = 'node',
384 parent = nil
385 },
386 string = {
387 'Hello world',
388 "newline\nnewline2"
389 }
390}
369local tb 391local tb
370do 392do
371 local _tab_0 = { } 393 local _tab_0 = { }
diff --git a/spec/outputs/with.lua b/spec/outputs/with.lua
index 20c5d44..338d51f 100644
--- a/spec/outputs/with.lua
+++ b/spec/outputs/with.lua
@@ -203,15 +203,51 @@ do
203 return _with_0 203 return _with_0
204 end)()) 204 end)())
205 local a 205 local a
206 local _with_0 = tb 206 do
207 local _with_0 = tb
208 do
209 local _accum_0
210 while true do
211 if _with_0.v then
212 _accum_0 = _with_0.a
213 break
214 end
215 end
216 _with_0 = _accum_0
217 end
218 a = _with_0
219 end
207 local _accum_0 220 local _accum_0
208 while true do 221 while true do
209 if _with_0.v then 222 local _with_0 = tb
210 _accum_0 = _with_0.a 223 local _accum_1
224 while true do
225 if _with_0 ~= nil then
226 _accum_1 = 1
227 break
228 end
211 break 229 break
212 end 230 end
231 _with_0 = _accum_1
232 _accum_0 = _with_0
233 break
234 end
235 a = _accum_0
236end
237do
238 local a
239 local _accum_0
240 for i = 1, 100 do
241 local x = tb[i]
242 if x ~= nil then
243 local _des_0 = 1
244 if _des_0 then
245 x.id = _des_0
246 _accum_0 = x
247 break
248 end
249 end
213 end 250 end
214 _with_0 = _accum_0 251 a = _accum_0
215 a = _with_0
216end 252end
217return nil 253return nil