diff options
| author | Li Jin <dragon-fly@qq.com> | 2026-01-21 10:05:19 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2026-01-21 10:05:19 +0800 |
| commit | 604a8e5e53cdc7391a502fcabf07e8f1cc2a778c (patch) | |
| tree | 18dca1f8314fe918d6173ed4acbdc84c5b541752 /spec | |
| parent | c6229c02564024d8c02c2d438b2fc180ce4c6bcf (diff) | |
| download | yuescript-604a8e5e53cdc7391a502fcabf07e8f1cc2a778c.tar.gz yuescript-604a8e5e53cdc7391a502fcabf07e8f1cc2a778c.tar.bz2 yuescript-604a8e5e53cdc7391a502fcabf07e8f1cc2a778c.zip | |
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/inputs/import_global.yue | 17 | ||||
| -rw-r--r-- | spec/inputs/test/format_spec.yue | 1 | ||||
| -rw-r--r-- | spec/outputs/5.1/import_global.lua | 42 | ||||
| -rw-r--r-- | spec/outputs/import_global.lua | 42 | ||||
| -rw-r--r-- | spec/outputs/test/format_spec.lua | 1 |
5 files changed, 101 insertions, 2 deletions
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 | |||
| 91 | func! | 91 | func! |
| 92 | try func | 92 | try func |
| 93 | 93 | ||
| 94 | do | ||
| 95 | import global | ||
| 96 | f = -> | ||
| 97 | if result := try? func! | ||
| 98 | print result | ||
| 99 | |||
| 100 | switch Item | ||
| 101 | when 1 | ||
| 102 | print "one" | ||
| 103 | when 2 | ||
| 104 | print "two" | ||
| 105 | |||
| 106 | import global | ||
| 107 | f = -> | ||
| 108 | if a! < b! < c! | ||
| 109 | print "OK" | ||
| 110 | |||
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 = [ | |||
| 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/upvalue_func.yue" |
| 54 | "spec/inputs/import_global.yue" | ||
| 54 | "spec/inputs/unicode/macro_export.yue" | 55 | "spec/inputs/unicode/macro_export.yue" |
| 55 | "spec/inputs/unicode/attrib.yue" | 56 | "spec/inputs/unicode/attrib.yue" |
| 56 | "spec/inputs/unicode/macro.yue" | 57 | "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 | |||
| 41 | func(1, 2) | 41 | func(1, 2) |
| 42 | end | 42 | end |
| 43 | do | 43 | do |
| 44 | local xpcall = xpcall | ||
| 45 | local func = func | 44 | local func = func |
| 45 | local xpcall = xpcall | ||
| 46 | local world = world | 46 | local world = world |
| 47 | local tostring = tostring | 47 | local tostring = tostring |
| 48 | local print = print | 48 | local print = print |
| @@ -129,3 +129,43 @@ do | |||
| 129 | return pcall(_anon_func_0, func) | 129 | return pcall(_anon_func_0, func) |
| 130 | end | 130 | end |
| 131 | end | 131 | end |
| 132 | do | ||
| 133 | local func = func | ||
| 134 | local pcall = pcall | ||
| 135 | local print = print | ||
| 136 | local Item = Item | ||
| 137 | local f | ||
| 138 | f = function() | ||
| 139 | local result | ||
| 140 | local _ok_0, _ret_0 = pcall(func) | ||
| 141 | if _ok_0 then | ||
| 142 | result = _ret_0 | ||
| 143 | end | ||
| 144 | if result then | ||
| 145 | return print(result) | ||
| 146 | end | ||
| 147 | end | ||
| 148 | if 1 == Item then | ||
| 149 | print("one") | ||
| 150 | elseif 2 == Item then | ||
| 151 | print("two") | ||
| 152 | end | ||
| 153 | end | ||
| 154 | local b = b | ||
| 155 | local a = a | ||
| 156 | local c = c | ||
| 157 | local print = print | ||
| 158 | local _anon_func_1 = function() | ||
| 159 | local _cond_0 = b() | ||
| 160 | if not (a() < _cond_0) then | ||
| 161 | return false | ||
| 162 | else | ||
| 163 | return _cond_0 < c() | ||
| 164 | end | ||
| 165 | end | ||
| 166 | local f | ||
| 167 | f = function() | ||
| 168 | if _anon_func_1() then | ||
| 169 | return print("OK") | ||
| 170 | end | ||
| 171 | 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 | |||
| 41 | func(1, 2) | 41 | func(1, 2) |
| 42 | end | 42 | end |
| 43 | do | 43 | do |
| 44 | local xpcall <const> = xpcall | ||
| 45 | local func <const> = func | 44 | local func <const> = func |
| 45 | local xpcall <const> = xpcall | ||
| 46 | local world <const> = world | 46 | local world <const> = world |
| 47 | local tostring <const> = tostring | 47 | local tostring <const> = tostring |
| 48 | local print <const> = print | 48 | local print <const> = print |
| @@ -129,3 +129,43 @@ do | |||
| 129 | return pcall(_anon_func_0, func) | 129 | return pcall(_anon_func_0, func) |
| 130 | end | 130 | end |
| 131 | end | 131 | end |
| 132 | do | ||
| 133 | local func <const> = func | ||
| 134 | local pcall <const> = pcall | ||
| 135 | local print <const> = print | ||
| 136 | local Item <const> = Item | ||
| 137 | local f | ||
| 138 | f = function() | ||
| 139 | local result | ||
| 140 | local _ok_0, _ret_0 = pcall(func) | ||
| 141 | if _ok_0 then | ||
| 142 | result = _ret_0 | ||
| 143 | end | ||
| 144 | if result then | ||
| 145 | return print(result) | ||
| 146 | end | ||
| 147 | end | ||
| 148 | if 1 == Item then | ||
| 149 | print("one") | ||
| 150 | elseif 2 == Item then | ||
| 151 | print("two") | ||
| 152 | end | ||
| 153 | end | ||
| 154 | local b <const> = b | ||
| 155 | local a <const> = a | ||
| 156 | local c <const> = c | ||
| 157 | local print <const> = print | ||
| 158 | local _anon_func_1 = function() | ||
| 159 | local _cond_0 = b() | ||
| 160 | if not (a() < _cond_0) then | ||
| 161 | return false | ||
| 162 | else | ||
| 163 | return _cond_0 < c() | ||
| 164 | end | ||
| 165 | end | ||
| 166 | local f | ||
| 167 | f = function() | ||
| 168 | if _anon_func_1() then | ||
| 169 | return print("OK") | ||
| 170 | end | ||
| 171 | 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 = { | |||
| 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/upvalue_func.yue", |
| 54 | "spec/inputs/import_global.yue", | ||
| 54 | "spec/inputs/unicode/macro_export.yue", | 55 | "spec/inputs/unicode/macro_export.yue", |
| 55 | "spec/inputs/unicode/attrib.yue", | 56 | "spec/inputs/unicode/attrib.yue", |
| 56 | "spec/inputs/unicode/macro.yue", | 57 | "spec/inputs/unicode/macro.yue", |
