diff options
| author | Li Jin <dragon-fly@qq.com> | 2026-01-22 15:03:12 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2026-01-22 15:03:12 +0800 |
| commit | f1454bbbd13a71da2005ff789cde2da0e9eb81f6 (patch) | |
| tree | 37131187f4218dd3ebec049101c28a161e7ca289 /spec/outputs/test/nil_coalescing_spec.lua | |
| parent | 604a8e5e53cdc7391a502fcabf07e8f1cc2a778c (diff) | |
| download | yuescript-main.tar.gz yuescript-main.tar.bz2 yuescript-main.zip | |
Diffstat (limited to 'spec/outputs/test/nil_coalescing_spec.lua')
| -rw-r--r-- | spec/outputs/test/nil_coalescing_spec.lua | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/outputs/test/nil_coalescing_spec.lua b/spec/outputs/test/nil_coalescing_spec.lua new file mode 100644 index 0000000..90b2a64 --- /dev/null +++ b/spec/outputs/test/nil_coalescing_spec.lua | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | local _anon_func_0 = function(a, b) | ||
| 2 | if a ~= nil then | ||
| 3 | return a | ||
| 4 | else | ||
| 5 | return b | ||
| 6 | end | ||
| 7 | end | ||
| 8 | local _anon_func_1 = function(a, c) | ||
| 9 | if a ~= nil then | ||
| 10 | return a | ||
| 11 | else | ||
| 12 | return c | ||
| 13 | end | ||
| 14 | end | ||
| 15 | return describe("nil coalescing", function() | ||
| 16 | return it("distinguish nil and false", function() | ||
| 17 | local a = nil | ||
| 18 | local b = false | ||
| 19 | local c = 0 | ||
| 20 | assert.same((_anon_func_0(a, b)), false) | ||
| 21 | return assert.same((_anon_func_1(a, c)), 0) | ||
| 22 | end) | ||
| 23 | end) | ||
