From 604a8e5e53cdc7391a502fcabf07e8f1cc2a778c Mon Sep 17 00:00:00 2001 From: Li Jin Date: Wed, 21 Jan 2026 10:05:19 +0800 Subject: Update. --- spec/inputs/import_global.yue | 17 +++++++++++++++ spec/inputs/test/format_spec.yue | 1 + spec/outputs/5.1/import_global.lua | 42 +++++++++++++++++++++++++++++++++++++- spec/outputs/import_global.lua | 42 +++++++++++++++++++++++++++++++++++++- spec/outputs/test/format_spec.lua | 1 + 5 files changed, 101 insertions(+), 2 deletions(-) (limited to 'spec') diff --git a/spec/inputs/import_global.yue b/spec/inputs/import_global.yue index 18f0e85..d9e5c7f 100644 --- a/spec/inputs/import_global.yue +++ b/spec/inputs/import_global.yue @@ -91,3 +91,20 @@ do func! try func +do + import global + f = -> + if result := try? func! + print result + + switch Item + when 1 + print "one" + when 2 + print "two" + +import global +f = -> + if a! < b! < c! + print "OK" + diff --git a/spec/inputs/test/format_spec.yue b/spec/inputs/test/format_spec.yue index 3ad2c7f..95f73fc 100644 --- a/spec/inputs/test/format_spec.yue +++ b/spec/inputs/test/format_spec.yue @@ -51,6 +51,7 @@ files = [ "spec/inputs/test/loops_spec.yue" "spec/inputs/test/format_spec.yue" "spec/inputs/upvalue_func.yue" + "spec/inputs/import_global.yue" "spec/inputs/unicode/macro_export.yue" "spec/inputs/unicode/attrib.yue" "spec/inputs/unicode/macro.yue" diff --git a/spec/outputs/5.1/import_global.lua b/spec/outputs/5.1/import_global.lua index 3b8334a..b5ac582 100644 --- a/spec/outputs/5.1/import_global.lua +++ b/spec/outputs/5.1/import_global.lua @@ -41,8 +41,8 @@ do func(1, 2) end do - local xpcall = xpcall local func = func + local xpcall = xpcall local world = world local tostring = tostring local print = print @@ -129,3 +129,43 @@ do return pcall(_anon_func_0, func) end end +do + local func = func + local pcall = pcall + local print = print + local Item = Item + local f + f = function() + local result + local _ok_0, _ret_0 = pcall(func) + if _ok_0 then + result = _ret_0 + end + if result then + return print(result) + end + end + if 1 == Item then + print("one") + elseif 2 == Item then + print("two") + end +end +local b = b +local a = a +local c = c +local print = print +local _anon_func_1 = function() + local _cond_0 = b() + if not (a() < _cond_0) then + return false + else + return _cond_0 < c() + end +end +local f +f = function() + if _anon_func_1() then + return print("OK") + end +end diff --git a/spec/outputs/import_global.lua b/spec/outputs/import_global.lua index 895daf9..2d6c61b 100644 --- a/spec/outputs/import_global.lua +++ b/spec/outputs/import_global.lua @@ -41,8 +41,8 @@ do func(1, 2) end do - local xpcall = xpcall local func = func + local xpcall = xpcall local world = world local tostring = tostring local print = print @@ -129,3 +129,43 @@ do return pcall(_anon_func_0, func) end end +do + local func = func + local pcall = pcall + local print = print + local Item = Item + local f + f = function() + local result + local _ok_0, _ret_0 = pcall(func) + if _ok_0 then + result = _ret_0 + end + if result then + return print(result) + end + end + if 1 == Item then + print("one") + elseif 2 == Item then + print("two") + end +end +local b = b +local a = a +local c = c +local print = print +local _anon_func_1 = function() + local _cond_0 = b() + if not (a() < _cond_0) then + return false + else + return _cond_0 < c() + end +end +local f +f = function() + if _anon_func_1() then + return print("OK") + end +end diff --git a/spec/outputs/test/format_spec.lua b/spec/outputs/test/format_spec.lua index 7aa85cd..898fa03 100644 --- a/spec/outputs/test/format_spec.lua +++ b/spec/outputs/test/format_spec.lua @@ -51,6 +51,7 @@ local files = { "spec/inputs/test/loops_spec.yue", "spec/inputs/test/format_spec.yue", "spec/inputs/upvalue_func.yue", + "spec/inputs/import_global.yue", "spec/inputs/unicode/macro_export.yue", "spec/inputs/unicode/attrib.yue", "spec/inputs/unicode/macro.yue", -- cgit v1.2.3-55-g6feb