aboutsummaryrefslogtreecommitdiff
path: root/spec/outputs/test/nil_coalescing_spec.lua
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2026-01-22 15:03:12 +0800
committerLi Jin <dragon-fly@qq.com>2026-01-22 15:03:12 +0800
commitf1454bbbd13a71da2005ff789cde2da0e9eb81f6 (patch)
tree37131187f4218dd3ebec049101c28a161e7ca289 /spec/outputs/test/nil_coalescing_spec.lua
parent604a8e5e53cdc7391a502fcabf07e8f1cc2a778c (diff)
downloadyuescript-main.tar.gz
yuescript-main.tar.bz2
yuescript-main.zip
Adding tests.HEADmain
Diffstat (limited to '')
-rw-r--r--spec/outputs/test/nil_coalescing_spec.lua23
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 @@
1local _anon_func_0 = function(a, b)
2 if a ~= nil then
3 return a
4 else
5 return b
6 end
7end
8local _anon_func_1 = function(a, c)
9 if a ~= nil then
10 return a
11 else
12 return c
13 end
14end
15return 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)
23end)