aboutsummaryrefslogtreecommitdiff
path: root/spec/inputs/test/multiline_args_spec.yue
diff options
context:
space:
mode:
Diffstat (limited to 'spec/inputs/test/multiline_args_spec.yue')
-rw-r--r--spec/inputs/test/multiline_args_spec.yue52
1 files changed, 26 insertions, 26 deletions
diff --git a/spec/inputs/test/multiline_args_spec.yue b/spec/inputs/test/multiline_args_spec.yue
index bbb06f9..add9d2b 100644
--- a/spec/inputs/test/multiline_args_spec.yue
+++ b/spec/inputs/test/multiline_args_spec.yue
@@ -1,6 +1,6 @@
1describe "multiline arguments", -> 1describe "multiline arguments", ->
2 it "should split arguments across lines", -> 2 it "should split arguments across lines", ->
3 sum = (a, b, c) -> a + b + c 3 sum = (a, b, c, d, e, f) -> a + b + c + d + e + f
4 result = sum 5, 4, 3, 4 result = sum 5, 4, 3,
5 8, 9, 10 5 8, 9, 10
6 assert.same result, 39 6 assert.same result, 39
@@ -42,46 +42,46 @@ describe "multiline arguments", ->
42 assert.same result, {1, 2, 3, 4, 9, 8, 9, 10} 42 assert.same result, {1, 2, 3, 4, 9, 8, 9, 10}
43 43
44 it "should handle deeply nested indentation", -> 44 it "should handle deeply nested indentation", ->
45 y = [ fn 1, 2, 3, 45 -- Create function first
46 4, 5,
47 5, 6, 7
48 ]
49
50 -- Create the function first
51 fn = (a, b, c, d, e, f, g) -> a + b + c + d + e + f + g 46 fn = (a, b, c, d, e, f, g) -> a + b + c + d + e + f + g
47 y = { fn 1, 2, 3,
48 4,
49 5, 6, 7
50 }
52 51
53 result = y[1] 52 result = y[1]
54 assert.same result, 22 53 assert.same result, 28
55 54
56 it "should work with conditional statements", -> 55 it "should work with conditional statements", ->
57 fn = (a, b, c, d, e) -> a + b + c + d + e 56 fn = (a, b, c, d, e, f) -> a + b + c + d + e + f
58 57 result1 = fn 1, 2, 3,
59 result = if fn 1, 2, 3, 58 4, 5,
60 "hello", 59 6
61 "world" 60
62 "yes" 61 result = if result1 > 20
63 else 62 "yes"
64 "no" 63 else
64 "no"
65 assert.same result, "yes" 65 assert.same result, "yes"
66 66
67 it "should support function expressions", -> 67 it "should support function expressions", ->
68 double = (x) -> x * 2 68 doublePlus = (x, y) -> x * 2 + y
69 result = double 5, 69 result = doublePlus 5,
70 10 70 10
71 assert.same result, 20 71 assert.same result, 20
72 72
73 it "should handle chained function calls", -> 73 it "should handle chained function calls", ->
74 add = (a, b) -> a + b 74 add = (a, b, c, d) -> a + b + c + d
75 multiply = (a, b) -> a * b 75 multiply = (a, b, c, d) -> a * b * c * d
76 76
77 result = multiply add 1, 2, 77 result = multiply 1, 2,
78 add 3, 4 78 3, 4
79 assert.same result, 21 79 assert.same result, 24
80 80
81 it "should work with method calls", -> 81 it "should work with method calls", ->
82 obj = 82 obj =
83 value: 10 83 value: 10
84 add: (a, b) => @value + a + b 84 add: (a, b, c) => @value + a + b + c
85 85
86 result = obj\add 5, 10, 86 result = obj\add 5, 10,
87 15 87 15
@@ -100,7 +100,7 @@ describe "multiline arguments", ->
100 assert.same result, 45 100 assert.same result, 45
101 101
102 it "should work with return statement", -> 102 it "should work with return statement", ->
103 fn = (a, b) -> a + b 103 fn = (a, b, c) -> a + b + c
104 get_value = -> 104 get_value = ->
105 return fn 10, 20, 105 return fn 10, 20,
106 30 106 30