diff options
author | Li Jin <dragon-fly@qq.com> | 2023-07-28 11:53:04 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2023-07-28 11:53:04 +0800 |
commit | 5497775534d20ba06ab9c13bc4db1c5bee877513 (patch) | |
tree | be68d03cf0928efca4a579125e4ba15ef3ab9325 /spec | |
parent | f415df9617d251abd802257d9750618ccc71ca93 (diff) | |
download | yuescript-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.lua | 71 | ||||
-rw-r--r-- | spec/inputs/macro.yue | 4 | ||||
-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 @@ | |||
1 | xpcall(function() | ||
2 | return func(1, 2, 3) | ||
3 | end, function(err) | ||
4 | return print(err) | ||
5 | end) | ||
6 | xpcall(function() | ||
7 | return func(1, 2, 3) | ||
8 | end, function(err) | ||
9 | return print(err) | ||
10 | end) | ||
11 | pcall(function() | ||
12 | print("trying") | ||
13 | return func(1, 2, 3) | ||
14 | end) | ||
15 | do | ||
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) | ||
22 | end | ||
23 | pcall(tb.func) | ||
24 | pcall(tb.func) | ||
25 | pcall(tb.func) | ||
26 | pcall((tb.func)) | ||
27 | pcall(((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 | ||
33 | end)()), 1, 2, 3) | ||
34 | pcall(tb.func, 1) | ||
35 | pcall(tb.func, 1) | ||
36 | if (xpcall(function() | ||
37 | return func(1) | ||
38 | end, function(err) | ||
39 | return print(err) | ||
40 | end)) then | ||
41 | print("OK") | ||
42 | end | ||
43 | if xpcall(function() | ||
44 | return func(1) | ||
45 | end, function(err) | ||
46 | return print(err) | ||
47 | end) then | ||
48 | print("OK") | ||
49 | end | ||
50 | do | ||
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 | ||
70 | end | ||
71 | return 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 @@ | |||
1 | import "macro-export" as { | 1 | import "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 | ||
6 | import "macro-todo" as $ | 6 | import "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 @@ | |||
1 | import "macro-todo" as $ | 1 | import "macro_todo" as $ |
2 | 2 | ||
3 | import "macro-todo" as {$, :$todo} | 3 | import "macro_todo" as {$, :$todo} |
4 | 4 | ||
5 | export macro config = (debugging = true)-> | 5 | export 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 @@ | |||
1 | import "macro-teal" as $ | 1 | import "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 | |||