aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2024-03-19 16:28:06 +0800
committerLi Jin <dragon-fly@qq.com>2024-03-19 16:28:06 +0800
commit80b65520da432843f0c63431a1867bd2620bc4ac (patch)
tree75b4a23bd6add2d358bdfba60630e9b444baa65b
parent2733fe565c405f7b382fb7c02c69f78fb65d2f20 (diff)
downloadyuescript-0.23.0.tar.gz
yuescript-0.23.0.tar.bz2
yuescript-0.23.0.zip
more test cases.v0.23.0
-rw-r--r--spec/inputs/test/format_spec.yue1
-rw-r--r--spec/inputs/upvalue_func.yue18
-rw-r--r--spec/outputs/test/format_spec.lua1
-rw-r--r--spec/outputs/upvalue_func.lua43
4 files changed, 62 insertions, 1 deletions
diff --git a/spec/inputs/test/format_spec.yue b/spec/inputs/test/format_spec.yue
index 5076445..cbd9d22 100644
--- a/spec/inputs/test/format_spec.yue
+++ b/spec/inputs/test/format_spec.yue
@@ -50,6 +50,7 @@ files = [
50 "spec/inputs/test/table_spreading_spec.yue" 50 "spec/inputs/test/table_spreading_spec.yue"
51 "spec/inputs/test/loops_spec.yue" 51 "spec/inputs/test/loops_spec.yue"
52 "spec/inputs/test/format_spec.yue" 52 "spec/inputs/test/format_spec.yue"
53 "spec/inputs/upvalue_func.yue"
53 "spec/inputs/unicode/macro_export.yue" 54 "spec/inputs/unicode/macro_export.yue"
54 "spec/inputs/unicode/attrib.yue" 55 "spec/inputs/unicode/attrib.yue"
55 "spec/inputs/unicode/macro.yue" 56 "spec/inputs/unicode/macro.yue"
diff --git a/spec/inputs/upvalue_func.yue b/spec/inputs/upvalue_func.yue
index a4155da..159be76 100644
--- a/spec/inputs/upvalue_func.yue
+++ b/spec/inputs/upvalue_func.yue
@@ -205,3 +205,21 @@ GameEngine\schedule (deltaTime) -> -- closure 1
205 UpdateScoreText "Score: #{value}" -- value is captured by closure 2 205 UpdateScoreText "Score: #{value}" -- value is captured by closure 2
206 "continue" 206 "continue"
207 207
208-- test cases from issue
209do
210 buff_strength = (char, item) ->
211 item.buffer.strength? char.stats.strength?::ref()
212
213 exe_func = (func, env) ->
214 ok, ... = try
215 debug_env_before(env)
216 func(env)
217 debug_env_after(env)
218 catch ex
219 -- accessing ex and error
220 error ex
221 return ex
222 if ok
223 return ...
224 else
225 os.exit(1)
diff --git a/spec/outputs/test/format_spec.lua b/spec/outputs/test/format_spec.lua
index b12fb04..33a85f2 100644
--- a/spec/outputs/test/format_spec.lua
+++ b/spec/outputs/test/format_spec.lua
@@ -50,6 +50,7 @@ local files = {
50 "spec/inputs/test/table_spreading_spec.yue", 50 "spec/inputs/test/table_spreading_spec.yue",
51 "spec/inputs/test/loops_spec.yue", 51 "spec/inputs/test/loops_spec.yue",
52 "spec/inputs/test/format_spec.yue", 52 "spec/inputs/test/format_spec.yue",
53 "spec/inputs/upvalue_func.yue",
53 "spec/inputs/unicode/macro_export.yue", 54 "spec/inputs/unicode/macro_export.yue",
54 "spec/inputs/unicode/attrib.yue", 55 "spec/inputs/unicode/attrib.yue",
55 "spec/inputs/unicode/macro.yue", 56 "spec/inputs/unicode/macro.yue",
diff --git a/spec/outputs/upvalue_func.lua b/spec/outputs/upvalue_func.lua
index 125d75f..5768d2d 100644
--- a/spec/outputs/upvalue_func.lua
+++ b/spec/outputs/upvalue_func.lua
@@ -486,7 +486,7 @@ GameEngine:schedule(function(deltaTime)
486 local value = 123 486 local value = 123
487 return func(_anon_func_27(UpdateScoreText, tostring, value)) 487 return func(_anon_func_27(UpdateScoreText, tostring, value))
488end) 488end)
489return GameEngine:schedule(function(deltaTime) 489GameEngine:schedule(function(deltaTime)
490 local value = 123 490 local value = 123
491 return func((function() 491 return func((function()
492 if value > 200 then 492 if value > 200 then
@@ -500,3 +500,44 @@ return GameEngine:schedule(function(deltaTime)
500 end 500 end
501 end)()) 501 end)())
502end) 502end)
503local _anon_func_28 = function(char)
504 local _obj_0 = char.stats.strength
505 if _obj_0 ~= nil then
506 return _obj_0:ref()
507 end
508 return nil
509end
510local _anon_func_29 = function(os, _arg_0, ...)
511 do
512 local ok = _arg_0
513 if ok then
514 return ...
515 else
516 return os.exit(1)
517 end
518 end
519end
520local _anon_func_30 = function(debug_env_after, debug_env_before, env, func)
521 do
522 debug_env_before(env)
523 func(env)
524 return debug_env_after(env)
525 end
526end
527do
528 local buff_strength
529 buff_strength = function(char, item)
530 local _obj_0 = item.buffer.strength
531 if _obj_0 ~= nil then
532 return _obj_0(_anon_func_28(char))
533 end
534 return nil
535 end
536 local exe_func
537 exe_func = function(func, env)
538 return _anon_func_29(os, xpcall(_anon_func_30, function(ex)
539 error(ex)
540 return ex
541 end, debug_env_after, debug_env_before, env, func))
542 end
543end