diff options
Diffstat (limited to 'spec/outputs/test/destructure_spec.lua')
| -rw-r--r-- | spec/outputs/test/destructure_spec.lua | 29 |
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 @@ | |||
| 1 | return 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) | ||
| 29 | end) | ||
