Skip to content

Commit

Permalink
more test cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
pigpigyyy committed Mar 19, 2024
1 parent 2733fe5 commit 80b6552
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 1 deletion.
1 change: 1 addition & 0 deletions spec/inputs/test/format_spec.yue
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ files = [
"spec/inputs/test/table_spreading_spec.yue"
"spec/inputs/test/loops_spec.yue"
"spec/inputs/test/format_spec.yue"
"spec/inputs/upvalue_func.yue"
"spec/inputs/unicode/macro_export.yue"
"spec/inputs/unicode/attrib.yue"
"spec/inputs/unicode/macro.yue"
Expand Down
18 changes: 18 additions & 0 deletions spec/inputs/upvalue_func.yue
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,21 @@ GameEngine\schedule (deltaTime) -> -- closure 1
UpdateScoreText "Score: #{value}" -- value is captured by closure 2
"continue"

-- test cases from issue
do
buff_strength = (char, item) ->
item.buffer.strength? char.stats.strength?::ref()

exe_func = (func, env) ->
ok, ... = try
debug_env_before(env)
func(env)
debug_env_after(env)
catch ex
-- accessing ex and error
error ex
return ex
if ok
return ...
else
os.exit(1)
1 change: 1 addition & 0 deletions spec/outputs/test/format_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ local files = {
"spec/inputs/test/table_spreading_spec.yue",
"spec/inputs/test/loops_spec.yue",
"spec/inputs/test/format_spec.yue",
"spec/inputs/upvalue_func.yue",
"spec/inputs/unicode/macro_export.yue",
"spec/inputs/unicode/attrib.yue",
"spec/inputs/unicode/macro.yue",
Expand Down
43 changes: 42 additions & 1 deletion spec/outputs/upvalue_func.lua
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ GameEngine:schedule(function(deltaTime)
local value = 123
return func(_anon_func_27(UpdateScoreText, tostring, value))
end)
return GameEngine:schedule(function(deltaTime)
GameEngine:schedule(function(deltaTime)
local value = 123
return func((function()
if value > 200 then
Expand All @@ -500,3 +500,44 @@ return GameEngine:schedule(function(deltaTime)
end
end)())
end)
local _anon_func_28 = function(char)
local _obj_0 = char.stats.strength
if _obj_0 ~= nil then
return _obj_0:ref()
end
return nil
end
local _anon_func_29 = function(os, _arg_0, ...)
do
local ok = _arg_0
if ok then
return ...
else
return os.exit(1)
end
end
end
local _anon_func_30 = function(debug_env_after, debug_env_before, env, func)
do
debug_env_before(env)
func(env)
return debug_env_after(env)
end
end
do
local buff_strength
buff_strength = function(char, item)
local _obj_0 = item.buffer.strength
if _obj_0 ~= nil then
return _obj_0(_anon_func_28(char))
end
return nil
end
local exe_func
exe_func = function(func, env)
return _anon_func_29(os, xpcall(_anon_func_30, function(ex)
error(ex)
return ex
end, debug_env_after, debug_env_before, env, func))
end
end

0 comments on commit 80b6552

Please sign in to comment.