aboutsummaryrefslogtreecommitdiff
path: root/spec/inputs/test/do_statement_spec.yue
diff options
context:
space:
mode:
Diffstat (limited to 'spec/inputs/test/do_statement_spec.yue')
-rw-r--r--spec/inputs/test/do_statement_spec.yue22
1 files changed, 12 insertions, 10 deletions
diff --git a/spec/inputs/test/do_statement_spec.yue b/spec/inputs/test/do_statement_spec.yue
index 0adad20..2611cba 100644
--- a/spec/inputs/test/do_statement_spec.yue
+++ b/spec/inputs/test/do_statement_spec.yue
@@ -62,7 +62,7 @@ describe "do statement", ->
62 it "should support variable shadowing", -> 62 it "should support variable shadowing", ->
63 x = "outer" 63 x = "outer"
64 result = do 64 result = do
65 x = "inner" 65 local x = "inner"
66 x 66 x
67 assert.same result, "inner" 67 assert.same result, "inner"
68 assert.same x, "outer" 68 assert.same x, "outer"
@@ -74,7 +74,7 @@ describe "do statement", ->
74 74
75 result = do 75 result = do
76 with obj 76 with obj
77 \double! 77 break \double!
78 assert.same result, 20 78 assert.same result, 20
79 79
80 it "should handle comprehensions in do block", -> 80 it "should handle comprehensions in do block", ->
@@ -84,13 +84,13 @@ describe "do statement", ->
84 assert.same result, {2, 4, 6, 8, 10} 84 assert.same result, {2, 4, 6, 8, 10}
85 85
86 it "should work with try-catch", -> 86 it "should work with try-catch", ->
87 result = do 87 success, result = try
88 success = try 88 error "test error"
89 error "test error" 89 false
90 false 90 catch err
91 catch err 91 true
92 true 92 assert.is_false success
93 assert.is_true success 93 assert.is_true result
94 94
95 it "should support return statement", -> 95 it "should support return statement", ->
96 fn = -> 96 fn = ->
@@ -125,13 +125,15 @@ describe "do statement", ->
125 it "should support implicit return", -> 125 it "should support implicit return", ->
126 result = do 126 result = do
127 value = 42 127 value = 42
128 value
128 assert.same result, 42 129 assert.same result, 42
129 130
130 it "should handle empty do block", -> 131 it "should handle empty do block", ->
131 result = do 132 result = do nil
132 assert.same result, nil 133 assert.same result, nil
133 134
134 it "should work with backcalls", -> 135 it "should work with backcalls", ->
136 map = (f, items) -> [f item for item in *items]
135 result = do 137 result = do
136 items = [1, 2, 3] 138 items = [1, 2, 3]
137 (x) <- map _, items 139 (x) <- map _, items