diff options
| author | Li Jin <dragon-fly@qq.com> | 2023-05-17 09:19:20 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2023-05-17 09:19:20 +0800 |
| commit | 78d5e6f44c06ac24aee667b5f9a9e642dcc6208d (patch) | |
| tree | 78913f601c44a1d85e275a30e4a1272fee00c4cb /spec | |
| parent | a8c4737494818e6591cac2191bf3a49cbe990173 (diff) | |
| download | yuescript-78d5e6f44c06ac24aee667b5f9a9e642dcc6208d.tar.gz yuescript-78d5e6f44c06ac24aee667b5f9a9e642dcc6208d.tar.bz2 yuescript-78d5e6f44c06ac24aee667b5f9a9e642dcc6208d.zip | |
fix issue #133.
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/inputs/export.yue | 6 | ||||
| -rw-r--r-- | spec/inputs/syntax.yue | 2 | ||||
| -rw-r--r-- | spec/inputs/try-catch.yue | 3 | ||||
| -rw-r--r-- | spec/outputs/assign.lua | 6 | ||||
| -rw-r--r-- | spec/outputs/attrib.lua | 18 | ||||
| -rw-r--r-- | spec/outputs/do.lua | 6 | ||||
| -rw-r--r-- | spec/outputs/export.lua | 13 | ||||
| -rw-r--r-- | spec/outputs/syntax.lua | 8 | ||||
| -rw-r--r-- | spec/outputs/try-catch.lua | 11 |
9 files changed, 43 insertions, 30 deletions
diff --git a/spec/inputs/export.yue b/spec/inputs/export.yue index 15ffbcb..66e6736 100644 --- a/spec/inputs/export.yue +++ b/spec/inputs/export.yue | |||
| @@ -29,7 +29,7 @@ export cbVal = do | |||
| 29 | (x)<- f | 29 | (x)<- f |
| 30 | return x h | 30 | return x h |
| 31 | 31 | ||
| 32 | export y = -> | 32 | export yy = -> |
| 33 | h = 100 | 33 | h = 100 |
| 34 | k = 100 | 34 | k = 100 |
| 35 | 35 | ||
| @@ -84,3 +84,7 @@ export v2 = 2 | |||
| 84 | export v3 = class v4 | 84 | export v3 = class v4 |
| 85 | v5 = 5 | 85 | v5 = 5 |
| 86 | 86 | ||
| 87 | export.<"abc"> = 1 | ||
| 88 | export.<name> = "export" | ||
| 89 | export.<call> = => {} | ||
| 90 | export["a-b-c-x"] = 123 | ||
diff --git a/spec/inputs/syntax.yue b/spec/inputs/syntax.yue index 4f693d4..d60a145 100644 --- a/spec/inputs/syntax.yue +++ b/spec/inputs/syntax.yue | |||
| @@ -214,7 +214,7 @@ tb[] = 2 | |||
| 214 | tb[] = 3 | 214 | tb[] = 3 |
| 215 | 215 | ||
| 216 | x = 0 | 216 | x = 0 |
| 217 | _ = (if ntype(v) == "fndef" then x += 1) for v in *values | 217 | _ = (if ntype(v) == "fndef" then x + 1) for v in *values |
| 218 | 218 | ||
| 219 | 219 | ||
| 220 | hello = | 220 | hello = |
diff --git a/spec/inputs/try-catch.yue b/spec/inputs/try-catch.yue index 7287c33..e38cbef 100644 --- a/spec/inputs/try-catch.yue +++ b/spec/inputs/try-catch.yue | |||
| @@ -23,6 +23,7 @@ try tb.func | |||
| 23 | try tb.func! | 23 | try tb.func! |
| 24 | try tb.func() | 24 | try tb.func() |
| 25 | try (tb.func!) | 25 | try (tb.func!) |
| 26 | try (tb\func(1, 2, 3)) | ||
| 26 | 27 | ||
| 27 | try tb.func 1 | 28 | try tb.func 1 |
| 28 | try tb.func(1) | 29 | try tb.func(1) |
| @@ -32,7 +33,7 @@ catch err | |||
| 32 | print err) | 33 | print err) |
| 33 | print "OK" | 34 | print "OK" |
| 34 | 35 | ||
| 35 | if try func 1 | 36 | if try (func 1) |
| 36 | catch err | 37 | catch err |
| 37 | print err | 38 | print err |
| 38 | print "OK" | 39 | print "OK" |
diff --git a/spec/outputs/assign.lua b/spec/outputs/assign.lua index d939769..228e859 100644 --- a/spec/outputs/assign.lua +++ b/spec/outputs/assign.lua | |||
| @@ -36,10 +36,10 @@ local x | |||
| 36 | do | 36 | do |
| 37 | local f = getHandler() | 37 | local f = getHandler() |
| 38 | if f then | 38 | if f then |
| 39 | x = ((function() | 39 | do |
| 40 | f() | 40 | f() |
| 41 | return 123 | 41 | x = 123 |
| 42 | end)()) | 42 | end |
| 43 | end | 43 | end |
| 44 | end | 44 | end |
| 45 | return _(function() | 45 | return _(function() |
diff --git a/spec/outputs/attrib.lua b/spec/outputs/attrib.lua index aed549d..fbac28e 100644 --- a/spec/outputs/attrib.lua +++ b/spec/outputs/attrib.lua | |||
| @@ -32,21 +32,17 @@ do | |||
| 32 | end)() | 32 | end)() |
| 33 | local b <close> = (function() | 33 | local b <close> = (function() |
| 34 | if not false then | 34 | if not false then |
| 35 | return ((function() | 35 | if x then |
| 36 | if x then | 36 | return 1 |
| 37 | return 1 | 37 | end |
| 38 | end | ||
| 39 | end)()) | ||
| 40 | end | 38 | end |
| 41 | end)() | 39 | end)() |
| 42 | local c <const> = (function() | 40 | local c <const> = (function() |
| 43 | if true then | 41 | if true then |
| 44 | return ((function() | 42 | local _exp_0 = x |
| 45 | local _exp_0 = x | 43 | if "abc" == _exp_0 then |
| 46 | if "abc" == _exp_0 then | 44 | return 998 |
| 47 | return 998 | 45 | end |
| 48 | end | ||
| 49 | end)()) | ||
| 50 | end | 46 | end |
| 51 | end)() | 47 | end)() |
| 52 | local d <close> = (function() | 48 | local d <close> = (function() |
diff --git a/spec/outputs/do.lua b/spec/outputs/do.lua index 96d1022..6473e03 100644 --- a/spec/outputs/do.lua +++ b/spec/outputs/do.lua | |||
| @@ -32,10 +32,10 @@ local t = { | |||
| 32 | } | 32 | } |
| 33 | return function(y, k) | 33 | return function(y, k) |
| 34 | if y == nil then | 34 | if y == nil then |
| 35 | y = ((function() | 35 | do |
| 36 | x = 10 + 2 | 36 | x = 10 + 2 |
| 37 | return x | 37 | y = x |
| 38 | end)()) | 38 | end |
| 39 | end | 39 | end |
| 40 | if k == nil then | 40 | if k == nil then |
| 41 | do | 41 | do |
diff --git a/spec/outputs/export.lua b/spec/outputs/export.lua index 962f18c..f1beeee 100644 --- a/spec/outputs/export.lua +++ b/spec/outputs/export.lua | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | local _module_0 = { } | 1 | local _module_0 = setmetatable({ }, { }) |
| 2 | local a, b, c = 223, 343, 123 | 2 | local a, b, c = 223, 343, 123 |
| 3 | _module_0["a"], _module_0["b"], _module_0["c"] = a, b, c | 3 | _module_0["a"], _module_0["b"], _module_0["c"] = a, b, c |
| 4 | local cool = "dad" | 4 | local cool = "dad" |
| @@ -62,11 +62,12 @@ do | |||
| 62 | end) | 62 | end) |
| 63 | end | 63 | end |
| 64 | _module_0["cbVal"] = cbVal | 64 | _module_0["cbVal"] = cbVal |
| 65 | y = function() | 65 | local yy |
| 66 | yy = function() | ||
| 66 | local h = 100 | 67 | local h = 100 |
| 67 | local k = 100 | 68 | local k = 100 |
| 68 | end | 69 | end |
| 69 | _module_0["y"] = y | 70 | _module_0["yy"] = yy |
| 70 | do | 71 | do |
| 71 | local _exp_0 = h | 72 | local _exp_0 = h |
| 72 | if 100 == _exp_0 or 150 == _exp_0 then | 73 | if 100 == _exp_0 or 150 == _exp_0 then |
| @@ -322,4 +323,10 @@ do | |||
| 322 | end | 323 | end |
| 323 | _module_0["v3"] = v3 | 324 | _module_0["v3"] = v3 |
| 324 | v5 = 5 | 325 | v5 = 5 |
| 326 | getmetatable(_module_0)["abc"] = 1 | ||
| 327 | getmetatable(_module_0).__name = "export" | ||
| 328 | getmetatable(_module_0).__call = function(self) | ||
| 329 | return { } | ||
| 330 | end | ||
| 331 | _module_0["a-b-c-x"] = 123 | ||
| 325 | return _module_0 | 332 | return _module_0 |
diff --git a/spec/outputs/syntax.lua b/spec/outputs/syntax.lua index 990083f..2afadbb 100644 --- a/spec/outputs/syntax.lua +++ b/spec/outputs/syntax.lua | |||
| @@ -239,11 +239,9 @@ x = 0 | |||
| 239 | local _list_0 = values | 239 | local _list_0 = values |
| 240 | for _index_0 = 1, #_list_0 do | 240 | for _index_0 = 1, #_list_0 do |
| 241 | local v = _list_0[_index_0] | 241 | local v = _list_0[_index_0] |
| 242 | _ = ((function() | 242 | if ntype(v) == "fndef" then |
| 243 | if ntype(v) == "fndef" then | 243 | _ = x + 1 |
| 244 | x = x + 1 | 244 | end |
| 245 | end | ||
| 246 | end)()) | ||
| 247 | end | 245 | end |
| 248 | hello = { | 246 | hello = { |
| 249 | something = world, | 247 | something = world, |
diff --git a/spec/outputs/try-catch.lua b/spec/outputs/try-catch.lua index 692905e..129d412 100644 --- a/spec/outputs/try-catch.lua +++ b/spec/outputs/try-catch.lua | |||
| @@ -21,7 +21,14 @@ end | |||
| 21 | pcall(tb.func) | 21 | pcall(tb.func) |
| 22 | pcall(tb.func) | 22 | pcall(tb.func) |
| 23 | pcall(tb.func) | 23 | pcall(tb.func) |
| 24 | pcall((tb.func())) | 24 | pcall((tb.func)) |
| 25 | pcall(((function() | ||
| 26 | local _base_0 = tb | ||
| 27 | local _fn_0 = _base_0.func | ||
| 28 | return _fn_0 and function(...) | ||
| 29 | return _fn_0(_base_0, ...) | ||
| 30 | end | ||
| 31 | end)()), 1, 2, 3) | ||
| 25 | pcall(tb.func, 1) | 32 | pcall(tb.func, 1) |
| 26 | pcall(tb.func, 1) | 33 | pcall(tb.func, 1) |
| 27 | if (xpcall(func, function(err) | 34 | if (xpcall(func, function(err) |
| @@ -29,7 +36,7 @@ if (xpcall(func, function(err) | |||
| 29 | end, 1)) then | 36 | end, 1)) then |
| 30 | print("OK") | 37 | print("OK") |
| 31 | end | 38 | end |
| 32 | if xpcall(func, function(err) | 39 | if xpcall((func), function(err) |
| 33 | return print(err) | 40 | return print(err) |
| 34 | end, 1) then | 41 | end, 1) then |
| 35 | print("OK") | 42 | print("OK") |
