aboutsummaryrefslogtreecommitdiff
path: root/spec/outputs/test/destructure_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/destructure_spec.lua
parent604a8e5e53cdc7391a502fcabf07e8f1cc2a778c (diff)
downloadyuescript-main.tar.gz
yuescript-main.tar.bz2
yuescript-main.zip
Adding tests.HEADmain
Diffstat (limited to 'spec/outputs/test/destructure_spec.lua')
-rw-r--r--spec/outputs/test/destructure_spec.lua29
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/outputs/test/destructure_spec.lua b/spec/outputs/test/destructure_spec.lua
new file mode 100644
index 0000000..4e18b02
--- /dev/null
+++ b/spec/outputs/test/destructure_spec.lua
@@ -0,0 +1,29 @@
1return describe("destructure", function()
2 return it("defaults and nested", function()
3 local t = {
4 a = 1,
5 b = {
6 c = 3
7 },
8 d = nil
9 }
10 local a, c, d, e = t.a, t.b.c, t.b.d, t.e
11 if d == nil then
12 d = 4
13 end
14 if e == nil then
15 e = 5
16 end
17 return assert.same({
18 a,
19 c,
20 d,
21 e
22 }, {
23 1,
24 3,
25 4,
26 5
27 })
28 end)
29end)