aboutsummaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2023-05-17 09:19:20 +0800
committerLi Jin <dragon-fly@qq.com>2023-05-17 09:19:20 +0800
commit78d5e6f44c06ac24aee667b5f9a9e642dcc6208d (patch)
tree78913f601c44a1d85e275a30e4a1272fee00c4cb /spec
parenta8c4737494818e6591cac2191bf3a49cbe990173 (diff)
downloadyuescript-78d5e6f44c06ac24aee667b5f9a9e642dcc6208d.tar.gz
yuescript-78d5e6f44c06ac24aee667b5f9a9e642dcc6208d.tar.bz2
yuescript-78d5e6f44c06ac24aee667b5f9a9e642dcc6208d.zip
fix issue #133.
Diffstat (limited to 'spec')
-rw-r--r--spec/inputs/export.yue6
-rw-r--r--spec/inputs/syntax.yue2
-rw-r--r--spec/inputs/try-catch.yue3
-rw-r--r--spec/outputs/assign.lua6
-rw-r--r--spec/outputs/attrib.lua18
-rw-r--r--spec/outputs/do.lua6
-rw-r--r--spec/outputs/export.lua13
-rw-r--r--spec/outputs/syntax.lua8
-rw-r--r--spec/outputs/try-catch.lua11
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
32export y = -> 32export yy = ->
33 h = 100 33 h = 100
34 k = 100 34 k = 100
35 35
@@ -84,3 +84,7 @@ export v2 = 2
84export v3 = class v4 84export v3 = class v4
85v5 = 5 85v5 = 5
86 86
87export.<"abc"> = 1
88export.<name> = "export"
89export.<call> = => {}
90export["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
214tb[] = 3 214tb[] = 3
215 215
216x = 0 216x = 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
220hello = 220hello =
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
23try tb.func! 23try tb.func!
24try tb.func() 24try tb.func()
25try (tb.func!) 25try (tb.func!)
26try (tb\func(1, 2, 3))
26 27
27try tb.func 1 28try tb.func 1
28try tb.func(1) 29try tb.func(1)
@@ -32,7 +33,7 @@ catch err
32 print err) 33 print err)
33 print "OK" 34 print "OK"
34 35
35if try func 1 36if try (func 1)
36catch err 37catch 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
36do 36do
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
44end 44end
45return _(function() 45return _(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}
33return function(y, k) 33return 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 @@
1local _module_0 = { } 1local _module_0 = setmetatable({ }, { })
2local a, b, c = 223, 343, 123 2local 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
4local cool = "dad" 4local cool = "dad"
@@ -62,11 +62,12 @@ do
62 end) 62 end)
63end 63end
64_module_0["cbVal"] = cbVal 64_module_0["cbVal"] = cbVal
65y = function() 65local yy
66yy = function()
66 local h = 100 67 local h = 100
67 local k = 100 68 local k = 100
68end 69end
69_module_0["y"] = y 70_module_0["yy"] = yy
70do 71do
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
322end 323end
323_module_0["v3"] = v3 324_module_0["v3"] = v3
324v5 = 5 325v5 = 5
326getmetatable(_module_0)["abc"] = 1
327getmetatable(_module_0).__name = "export"
328getmetatable(_module_0).__call = function(self)
329 return { }
330end
331_module_0["a-b-c-x"] = 123
325return _module_0 332return _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
239local _list_0 = values 239local _list_0 = values
240for _index_0 = 1, #_list_0 do 240for _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)())
247end 245end
248hello = { 246hello = {
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
21pcall(tb.func) 21pcall(tb.func)
22pcall(tb.func) 22pcall(tb.func)
23pcall(tb.func) 23pcall(tb.func)
24pcall((tb.func())) 24pcall((tb.func))
25pcall(((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
31end)()), 1, 2, 3)
25pcall(tb.func, 1) 32pcall(tb.func, 1)
26pcall(tb.func, 1) 33pcall(tb.func, 1)
27if (xpcall(func, function(err) 34if (xpcall(func, function(err)
@@ -29,7 +36,7 @@ if (xpcall(func, function(err)
29end, 1)) then 36end, 1)) then
30 print("OK") 37 print("OK")
31end 38end
32if xpcall(func, function(err) 39if xpcall((func), function(err)
33 return print(err) 40 return print(err)
34end, 1) then 41end, 1) then
35 print("OK") 42 print("OK")