aboutsummaryrefslogtreecommitdiff
path: root/spec/inputs/test/whitespace_spec.yue
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2026-01-28 18:43:14 +0800
committerLi Jin <dragon-fly@qq.com>2026-01-28 18:43:14 +0800
commitdd64edd58fe25ec74ae5958128cf3f74b0692f3b (patch)
tree0f2de1df55897e2713977c5a53936757e14b477a /spec/inputs/test/whitespace_spec.yue
parent7c2a92b82e9808d3c5ea29b47d1c59d663fe984a (diff)
downloadyuescript-dd64edd58fe25ec74ae5958128cf3f74b0692f3b.tar.gz
yuescript-dd64edd58fe25ec74ae5958128cf3f74b0692f3b.tar.bz2
yuescript-dd64edd58fe25ec74ae5958128cf3f74b0692f3b.zip
Fixed compiler issues and added 800+ test cases.
Diffstat (limited to 'spec/inputs/test/whitespace_spec.yue')
-rw-r--r--spec/inputs/test/whitespace_spec.yue17
1 files changed, 10 insertions, 7 deletions
diff --git a/spec/inputs/test/whitespace_spec.yue b/spec/inputs/test/whitespace_spec.yue
index baf3fd5..43b7644 100644
--- a/spec/inputs/test/whitespace_spec.yue
+++ b/spec/inputs/test/whitespace_spec.yue
@@ -8,13 +8,14 @@ describe "whitespace", ->
8 assert.same z, 30 8 assert.same z, 30
9 9
10 it "should work with semicolon in function", -> 10 it "should work with semicolon in function", ->
11 fn = -> a = 1; b = 2; a + b 11 fn = ->
12 a = 1; b = 2; a + b
12 assert.same fn!, 3 13 assert.same fn!, 3
13 14
14 it "should support multiline chaining", -> 15 it "should support multiline chaining", ->
15 obj = 16 obj =
16 value: 10 17 value: 10
17 add: (n) => @value += n 18 add: (n): @ => @value += n
18 get: => @value 19 get: => @value
19 20
20 result = obj 21 result = obj
@@ -26,7 +27,7 @@ describe "whitespace", ->
26 it "should handle multiline method calls", -> 27 it "should handle multiline method calls", ->
27 str = " hello " 28 str = " hello "
28 result = str 29 result = str
29 \trim! 30 \match "^%s*(.-)%s*$"
30 \upper! 31 \upper!
31 assert.same result, "HELLO" 32 assert.same result, "HELLO"
32 33
@@ -53,7 +54,7 @@ describe "whitespace", ->
53 54
54 it "should work with pipe in chaining", -> 55 it "should work with pipe in chaining", ->
55 result = [1, 2, 3] 56 result = [1, 2, 3]
56 |> [x * 2 for x in *] 57 |> ((tb) -> [x * 2 for x in *tb])
57 |> table.concat 58 |> table.concat
58 assert.same result, "246" 59 assert.same result, "246"
59 60
@@ -68,7 +69,7 @@ describe "whitespace", ->
68 fn = -> 69 fn = ->
69 if true 70 if true
70 result = 10 71 result = 10
71 result 72 result
72 73
73 assert.same fn!, 10 74 assert.same fn!, 10
74 75
@@ -91,7 +92,7 @@ describe "whitespace", ->
91 92
92 it "should work in multiline function call", -> 93 it "should work in multiline function call", ->
93 sum = (a, b) -> a + b 94 sum = (a, b) -> a + b
94 result = sum 5, 10, 95 result = sum 5, sum 10,
95 sum 3, 7 96 sum 3, 7
96 assert.same result, 25 97 assert.same result, 25
97 98
@@ -105,13 +106,15 @@ describe "whitespace", ->
105 assert.same doubled, 10 106 assert.same doubled, 10
106 107
107 it "should handle complex chaining", -> 108 it "should handle complex chaining", ->
108 result = "hello" 109 result = ("hello")
109 \upper! 110 \upper!
110 \sub 1, 3 111 \sub 1, 3
111 \lower! 112 \lower!
112 assert.same result, "hel" 113 assert.same result, "hel"
113 114
114 it "should work with backcalls and whitespace", -> 115 it "should work with backcalls and whitespace", ->
116 readAsync = (file, callback) -> callback "data"
117 process = (data) -> true if data
115 results = do 118 results = do
116 data <- readAsync "data.txt" 119 data <- readAsync "data.txt"
117 process data 120 process data