aboutsummaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2023-07-28 11:53:04 +0800
committerLi Jin <dragon-fly@qq.com>2023-07-28 11:53:04 +0800
commit5497775534d20ba06ab9c13bc4db1c5bee877513 (patch)
treebe68d03cf0928efca4a579125e4ba15ef3ab9325 /spec
parentf415df9617d251abd802257d9750618ccc71ca93 (diff)
downloadyuescript-5497775534d20ba06ab9c13bc4db1c5bee877513.tar.gz
yuescript-5497775534d20ba06ab9c13bc4db1c5bee877513.tar.bz2
yuescript-5497775534d20ba06ab9c13bc4db1c5bee877513.zip
fix xpcall usages in different Lua version.
Diffstat (limited to 'spec')
-rw-r--r--spec/generated/5.1/try_catch.lua71
-rw-r--r--spec/inputs/macro.yue4
-rw-r--r--spec/inputs/macro_export.yue (renamed from spec/inputs/macro-export.yue)4
-rw-r--r--spec/inputs/macro_teal.yue (renamed from spec/inputs/macro-teal.yue)0
-rw-r--r--spec/inputs/macro_todo.yue (renamed from spec/inputs/macro-todo.yue)0
-rw-r--r--spec/inputs/teal_lang.yue (renamed from spec/inputs/teal-lang.yue)2
-rw-r--r--spec/inputs/try_catch.yue (renamed from spec/inputs/try-catch.yue)0
-rw-r--r--spec/outputs/teal_lang.lua (renamed from spec/outputs/teal-lang.lua)0
-rw-r--r--spec/outputs/teal_lang.tl (renamed from spec/outputs/teal-lang.tl)0
-rw-r--r--spec/outputs/try_catch.lua (renamed from spec/outputs/try-catch.lua)0
10 files changed, 76 insertions, 5 deletions
diff --git a/spec/generated/5.1/try_catch.lua b/spec/generated/5.1/try_catch.lua
new file mode 100644
index 0000000..577df16
--- /dev/null
+++ b/spec/generated/5.1/try_catch.lua
@@ -0,0 +1,71 @@
1xpcall(function()
2 return func(1, 2, 3)
3end, function(err)
4 return print(err)
5end)
6xpcall(function()
7 return func(1, 2, 3)
8end, function(err)
9 return print(err)
10end)
11pcall(function()
12 print("trying")
13 return func(1, 2, 3)
14end)
15do
16 local success, result = xpcall(function()
17 return func(1, 2, 3)
18 end, function(err)
19 return print(err)
20 end)
21 success, result = pcall(func, 1, 2, 3)
22end
23pcall(tb.func)
24pcall(tb.func)
25pcall(tb.func)
26pcall((tb.func))
27pcall(((function()
28 local _base_0 = tb
29 local _fn_0 = _base_0.func
30 return _fn_0 and function(...)
31 return _fn_0(_base_0, ...)
32 end
33end)()), 1, 2, 3)
34pcall(tb.func, 1)
35pcall(tb.func, 1)
36if (xpcall(function()
37 return func(1)
38end, function(err)
39 return print(err)
40end)) then
41 print("OK")
42end
43if xpcall(function()
44 return func(1)
45end, function(err)
46 return print(err)
47end) then
48 print("OK")
49end
50do
51 do
52 local success, result = pcall(func, "abc", 123)
53 if success then
54 print(result)
55 end
56 end
57 local success, result = xpcall(function()
58 return func("abc", 123)
59 end, function(err)
60 return print(err)
61 end)
62 success, result = xpcall(function()
63 return func("abc", 123)
64 end, function(err)
65 return print(err)
66 end)
67 if success then
68 print(result)
69 end
70end
71return nil
diff --git a/spec/inputs/macro.yue b/spec/inputs/macro.yue
index ac51d85..ae14f53 100644
--- a/spec/inputs/macro.yue
+++ b/spec/inputs/macro.yue
@@ -1,9 +1,9 @@
1import "macro-export" as { 1import "macro_export" as {
2 $, -- import all macros 2 $, -- import all macros
3 $config: $myconfig, -- rename macro $config to $myconfig 3 $config: $myconfig, -- rename macro $config to $myconfig
4} 4}
5 5
6import "macro-todo" as $ 6import "macro_todo" as $
7 7
8$asserts item == nil 8$asserts item == nil
9 9
diff --git a/spec/inputs/macro-export.yue b/spec/inputs/macro_export.yue
index ff0d273..eec5848 100644
--- a/spec/inputs/macro-export.yue
+++ b/spec/inputs/macro_export.yue
@@ -1,6 +1,6 @@
1import "macro-todo" as $ 1import "macro_todo" as $
2 2
3import "macro-todo" as {$, :$todo} 3import "macro_todo" as {$, :$todo}
4 4
5export macro config = (debugging = true)-> 5export macro config = (debugging = true)->
6 global debugMode = debugging == "true" 6 global debugMode = debugging == "true"
diff --git a/spec/inputs/macro-teal.yue b/spec/inputs/macro_teal.yue
index a443614..a443614 100644
--- a/spec/inputs/macro-teal.yue
+++ b/spec/inputs/macro_teal.yue
diff --git a/spec/inputs/macro-todo.yue b/spec/inputs/macro_todo.yue
index 752c9cb..752c9cb 100644
--- a/spec/inputs/macro-todo.yue
+++ b/spec/inputs/macro_todo.yue
diff --git a/spec/inputs/teal-lang.yue b/spec/inputs/teal_lang.yue
index b28c915..e01682f 100644
--- a/spec/inputs/teal-lang.yue
+++ b/spec/inputs/teal_lang.yue
@@ -1,4 +1,4 @@
1import "macro-teal" as $ 1import "macro_teal" as $
2 2
3$local "a:{string:number}", {value:123} 3$local "a:{string:number}", {value:123}
4$local "b:number", a.value 4$local "b:number", a.value
diff --git a/spec/inputs/try-catch.yue b/spec/inputs/try_catch.yue
index e38cbef..e38cbef 100644
--- a/spec/inputs/try-catch.yue
+++ b/spec/inputs/try_catch.yue
diff --git a/spec/outputs/teal-lang.lua b/spec/outputs/teal_lang.lua
index 28ba6f8..28ba6f8 100644
--- a/spec/outputs/teal-lang.lua
+++ b/spec/outputs/teal_lang.lua
diff --git a/spec/outputs/teal-lang.tl b/spec/outputs/teal_lang.tl
index 0dc25a1..0dc25a1 100644
--- a/spec/outputs/teal-lang.tl
+++ b/spec/outputs/teal_lang.tl
diff --git a/spec/outputs/try-catch.lua b/spec/outputs/try_catch.lua
index 129d412..129d412 100644
--- a/spec/outputs/try-catch.lua
+++ b/spec/outputs/try_catch.lua