1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
describe "whitespace", ->
it "should support semicolon statement separator", ->
a = 1; b = 2; result = a + b
assert.same result, 3
it "should handle multiple statements on one line", ->
x = 10; y = 20; z = x + y
assert.same z, 30
it "should work with semicolon in function", ->
fn = -> a = 1; b = 2; a + b
assert.same fn!, 3
it "should support multiline chaining", ->
obj =
value: 10
add: (n) => @value += n
get: => @value
result = obj
\add 5
\add 10
\get!
assert.same result, 25
it "should handle multiline method calls", ->
str = " hello "
result = str
\trim!
\upper!
assert.same result, "HELLO"
it "should work with nested chaining", ->
obj =
level1:
level2:
level3: => "deep"
result = obj
.level1
.level2
\level3!
assert.same result, "deep"
it "should support chaining with conditionals", ->
obj =
value: 10
isPositive: => @value > 0
result = obj
\isPositive!
assert.is_true result
it "should work with pipe in chaining", ->
result = [1, 2, 3]
|> [x * 2 for x in *]
|> table.concat
assert.same result, "246"
it "should handle mixed separators", ->
a = 1; b = 2
c = 3
d = 4
result = a + b + c + d
assert.same result, 10
it "should support indentation with spaces", ->
fn = ->
if true
result = 10
result
assert.same fn!, 10
it "should work with consistent indentation", ->
tb = {
a: 1
b: 2
nested:
c: 3
d: 4
}
assert.same tb.a, 1
assert.same tb.nested.c, 3
it "should handle semicolon with comments", ->
a = 1; -- comment
b = 2; -- another comment
result = a + b
assert.same result, 3
it "should work in multiline function call", ->
sum = (a, b) -> a + b
result = sum 5, 10,
sum 3, 7
assert.same result, 25
it "should support chaining in assignment", ->
obj =
value: 5
double: => @value * 2
doubled = obj
\double!
assert.same doubled, 10
it "should handle complex chaining", ->
result = "hello"
\upper!
\sub 1, 3
\lower!
assert.same result, "hel"
it "should work with backcalls and whitespace", ->
results = do
data <- readAsync "data.txt"
process data
assert.is_true true
|