diff options
Diffstat (limited to 'spec/inputs/test/const_attribute_spec.yue')
| -rw-r--r-- | spec/inputs/test/const_attribute_spec.yue | 20 |
1 files changed, 2 insertions, 18 deletions
diff --git a/spec/inputs/test/const_attribute_spec.yue b/spec/inputs/test/const_attribute_spec.yue index e3cc638..24ced21 100644 --- a/spec/inputs/test/const_attribute_spec.yue +++ b/spec/inputs/test/const_attribute_spec.yue | |||
| @@ -13,7 +13,7 @@ describe "const attribute", -> | |||
| 13 | assert.same name, "test" | 13 | assert.same name, "test" |
| 14 | 14 | ||
| 15 | it "should support const with destructuring", -> | 15 | it "should support const with destructuring", -> |
| 16 | tb = {a: 1, b: 2, c: 3, d: 4} | 16 | tb = {a: 1, b: 2, 3, 4} |
| 17 | const {:a, :b, c, d} = tb | 17 | const {:a, :b, c, d} = tb |
| 18 | assert.same a, 1 | 18 | assert.same a, 1 |
| 19 | assert.same b, 2 | 19 | assert.same b, 2 |
| @@ -46,7 +46,7 @@ describe "const attribute", -> | |||
| 46 | 46 | ||
| 47 | it "should handle const functions", -> | 47 | it "should handle const functions", -> |
| 48 | const add = (a, b) -> a + b | 48 | const add = (a, b) -> a + b |
| 49 | assert.same add 5, 10, 15 | 49 | assert.same add(5, 10), 15 |
| 50 | 50 | ||
| 51 | it "should work with const tables", -> | 51 | it "should work with const tables", -> |
| 52 | const config = { | 52 | const config = { |
| @@ -74,28 +74,12 @@ describe "const attribute", -> | |||
| 74 | const calculated = 10 + 20 | 74 | const calculated = 10 + 20 |
| 75 | assert.same calculated, 30 | 75 | assert.same calculated, 30 |
| 76 | 76 | ||
| 77 | it "should support const with prefixed return", -> | ||
| 78 | getDefault: const "default" -> | ||
| 79 | return nil | ||
| 80 | |||
| 81 | result = getDefault! | ||
| 82 | assert.same result, nil | ||
| 83 | |||
| 84 | it "should work in table comprehension", -> | 77 | it "should work in table comprehension", -> |
| 85 | const multiplier = 2 | 78 | const multiplier = 2 |
| 86 | items = [1, 2, 3] | 79 | items = [1, 2, 3] |
| 87 | result = [item * multiplier for item in *items] | 80 | result = [item * multiplier for item in *items] |
| 88 | assert.same result, {2, 4, 6} | 81 | assert.same result, {2, 4, 6} |
| 89 | 82 | ||
| 90 | it "should handle const with fat arrow", -> | ||
| 91 | obj = | ||
| 92 | value: 100 | ||
| 93 | getValue: const => | ||
| 94 | @value | ||
| 95 | |||
| 96 | result = obj\getValue! | ||
| 97 | assert.same result, 100 | ||
| 98 | |||
| 99 | it "should work with complex expressions", -> | 83 | it "should work with complex expressions", -> |
| 100 | const complex = { | 84 | const complex = { |
| 101 | data: [1, 2, 3] | 85 | data: [1, 2, 3] |
