diff options
Diffstat (limited to '')
-rw-r--r-- | spec/outputs/codes_from_doc.lua | 28 | ||||
-rw-r--r-- | spec/outputs/codes_from_doc_zh.lua | 28 | ||||
-rw-r--r-- | spec/outputs/switch.lua | 71 | ||||
-rw-r--r-- | spec/outputs/tables.lua | 22 | ||||
-rw-r--r-- | spec/outputs/with.lua | 46 |
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 | }) |
342 | local f | ||
343 | f = function() | ||
344 | return { | ||
345 | 1, | ||
346 | 2, | ||
347 | 3 | ||
348 | } | ||
349 | end | ||
342 | local tb = { | 350 | local tb = { |
343 | name = "abc", | 351 | name = "abc", |
344 | values = { | 352 | values = { |
@@ -1226,7 +1234,7 @@ if "Robert" == name then | |||
1226 | elseif "Dan" == name or "Daniel" == name then | 1234 | elseif "Dan" == name or "Daniel" == name then |
1227 | print("Your name, it's Dan") | 1235 | print("Your name, it's Dan") |
1228 | else | 1236 | else |
1229 | print("I don't know about your name") | 1237 | print("I don't know about you with name " .. tostring(name)) |
1230 | end | 1238 | end |
1231 | local b = 1 | 1239 | local b = 1 |
1232 | local next_number | 1240 | local next_number |
@@ -2139,6 +2147,10 @@ do | |||
2139 | _with_1["key-name"] = value | 2147 | _with_1["key-name"] = value |
2140 | end | 2148 | end |
2141 | _with_0[#_with_0 + 1] = "abc" | 2149 | _with_0[#_with_0 + 1] = "abc" |
2150 | local _with_0 = obj | ||
2151 | if _with_0 ~= nil then | ||
2152 | print(obj.name) | ||
2153 | end | ||
2142 | do | 2154 | do |
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 | }) |
2563 | local f | ||
2564 | f = function() | ||
2565 | return { | ||
2566 | 1, | ||
2567 | 2, | ||
2568 | 3 | ||
2569 | } | ||
2570 | end | ||
2551 | local tb = { | 2571 | local tb = { |
2552 | name = "abc", | 2572 | name = "abc", |
2553 | values = { | 2573 | values = { |
@@ -3434,7 +3454,7 @@ if "Robert" == name then | |||
3434 | elseif "Dan" == name or "Daniel" == name then | 3454 | elseif "Dan" == name or "Daniel" == name then |
3435 | print("Your name, it's Dan") | 3455 | print("Your name, it's Dan") |
3436 | else | 3456 | else |
3437 | print("I don't know about your name") | 3457 | print("I don't know about you with name " .. tostring(name)) |
3438 | end | 3458 | end |
3439 | local b = 1 | 3459 | local b = 1 |
3440 | local next_number | 3460 | local next_number |
@@ -4347,6 +4367,10 @@ do | |||
4347 | _with_1["key-name"] = value | 4367 | _with_1["key-name"] = value |
4348 | end | 4368 | end |
4349 | _with_0[#_with_0 + 1] = "abc" | 4369 | _with_0[#_with_0 + 1] = "abc" |
4370 | local _with_0 = obj | ||
4371 | if _with_0 ~= nil then | ||
4372 | print(obj.name) | ||
4373 | end | ||
4350 | do | 4374 | do |
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 | }) |
342 | local f | ||
343 | f = function() | ||
344 | return { | ||
345 | 1, | ||
346 | 2, | ||
347 | 3 | ||
348 | } | ||
349 | end | ||
342 | local tb = { | 350 | local tb = { |
343 | name = "abc", | 351 | name = "abc", |
344 | values = { | 352 | values = { |
@@ -1220,7 +1228,7 @@ if "Robert" == name then | |||
1220 | elseif "Dan" == name or "Daniel" == name then | 1228 | elseif "Dan" == name or "Daniel" == name then |
1221 | print("你的名字是Dan") | 1229 | print("你的名字是Dan") |
1222 | else | 1230 | else |
1223 | print("我不知道你的名字") | 1231 | print("我不认识你,你的名字是" .. tostring(name)) |
1224 | end | 1232 | end |
1225 | local b = 1 | 1233 | local b = 1 |
1226 | local next_number | 1234 | local next_number |
@@ -2133,6 +2141,10 @@ do | |||
2133 | _with_1["key-name"] = value | 2141 | _with_1["key-name"] = value |
2134 | end | 2142 | end |
2135 | _with_0[#_with_0 + 1] = "abc" | 2143 | _with_0[#_with_0 + 1] = "abc" |
2144 | local _with_0 = obj | ||
2145 | if _with_0 ~= nil then | ||
2146 | print(obj.name) | ||
2147 | end | ||
2136 | do | 2148 | do |
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 | }) |
2557 | local f | ||
2558 | f = function() | ||
2559 | return { | ||
2560 | 1, | ||
2561 | 2, | ||
2562 | 3 | ||
2563 | } | ||
2564 | end | ||
2545 | local tb = { | 2565 | local tb = { |
2546 | name = "abc", | 2566 | name = "abc", |
2547 | values = { | 2567 | values = { |
@@ -3422,7 +3442,7 @@ if "Robert" == name then | |||
3422 | elseif "Dan" == name or "Daniel" == name then | 3442 | elseif "Dan" == name or "Daniel" == name then |
3423 | print("你的名字是Dan") | 3443 | print("你的名字是Dan") |
3424 | else | 3444 | else |
3425 | print("我不知道你的名字") | 3445 | print("我不认识你,你的名字是" .. tostring(name)) |
3426 | end | 3446 | end |
3427 | local b = 1 | 3447 | local b = 1 |
3428 | local next_number | 3448 | local next_number |
@@ -4335,6 +4355,10 @@ do | |||
4335 | _with_1["key-name"] = value | 4355 | _with_1["key-name"] = value |
4336 | end | 4356 | end |
4337 | _with_0[#_with_0 + 1] = "abc" | 4357 | _with_0[#_with_0 + 1] = "abc" |
4358 | local _with_0 = obj | ||
4359 | if _with_0 ~= nil then | ||
4360 | print(obj.name) | ||
4361 | end | ||
4338 | do | 4362 | do |
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 |
658 | end | 658 | end |
659 | do | ||
660 | local v = "hello" | ||
661 | if "hello" == v then | ||
662 | print("matched hello") | ||
663 | else | ||
664 | print("not matched") | ||
665 | end | ||
666 | end | ||
667 | do | ||
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 | ||
676 | end | ||
677 | do | ||
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 | ||
690 | end | ||
691 | do | ||
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 | ||
706 | end | ||
707 | do | ||
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 | ||
729 | end | ||
659 | return nil | 730 | return 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 | } | ||
369 | local tb | 391 | local tb |
370 | do | 392 | do |
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 | ||
236 | end | ||
237 | do | ||
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 | ||
216 | end | 252 | end |
217 | return nil | 253 | return nil |