aboutsummaryrefslogtreecommitdiff
path: root/spec/outputs/test/with_statement_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'spec/outputs/test/with_statement_spec.lua')
-rw-r--r--spec/outputs/test/with_statement_spec.lua98
1 files changed, 35 insertions, 63 deletions
diff --git a/spec/outputs/test/with_statement_spec.lua b/spec/outputs/test/with_statement_spec.lua
index dcd2aa1..e6f64e8 100644
--- a/spec/outputs/test/with_statement_spec.lua
+++ b/spec/outputs/test/with_statement_spec.lua
@@ -53,14 +53,10 @@ return describe("with statement", function()
53 value = 5 53 value = 5
54 } 54 }
55 local result 55 local result
56 do 56 repeat
57 local _accum_0 57 result = obj.value * 2
58 repeat 58 break
59 _accum_0 = obj.value * 2 59 until true
60 break
61 until true
62 result = _accum_0
63 end
64 return assert.same(result, 10) 60 return assert.same(result, 10)
65 end) 61 end)
66 it("should support multiple statements", function() 62 it("should support multiple statements", function()
@@ -125,27 +121,19 @@ return describe("with statement", function()
125 y = 10 121 y = 10
126 } 122 }
127 local result 123 local result
128 do 124 repeat
129 local _accum_0 125 result = obj.x + obj.y
130 repeat 126 break
131 _accum_0 = obj.x + obj.y 127 until true
132 break
133 until true
134 result = _accum_0
135 end
136 return assert.same(result, 15) 128 return assert.same(result, 15)
137 end) 129 end)
138 it("should work with string methods", function() 130 it("should work with string methods", function()
139 local s = "hello" 131 local s = "hello"
140 local result 132 local result
141 do 133 repeat
142 local _accum_0 134 result = s:upper()
143 repeat 135 break
144 _accum_0 = s:upper() 136 until true
145 break
146 until true
147 result = _accum_0
148 end
149 return assert.same(result, "HELLO") 137 return assert.same(result, "HELLO")
150 end) 138 end)
151 it("should handle metatable access", function() 139 it("should handle metatable access", function()
@@ -169,12 +157,10 @@ return describe("with statement", function()
169 x = 10 157 x = 10
170 } 158 }
171 local _val_0 159 local _val_0
172 local _accum_0
173 repeat 160 repeat
174 _accum_0 = obj.x * 2 161 _val_0 = obj.x * 2
175 break 162 break
176 until true 163 until true
177 _val_0 = _accum_0
178 return _val_0 164 return _val_0
179 end 165 end
180 local result = fn() 166 local result = fn()
@@ -187,12 +173,10 @@ return describe("with statement", function()
187 value = 42 173 value = 42
188 } 174 }
189 local _val_0 175 local _val_0
190 local _accum_0
191 repeat 176 repeat
192 _accum_0 = obj.value 177 _val_0 = obj.value
193 break 178 break
194 until true 179 until true
195 _val_0 = _accum_0
196 return _val_0 180 return _val_0
197 end 181 end
198 return assert.same(get_value(), 42) 182 return assert.same(get_value(), 42)
@@ -202,19 +186,15 @@ return describe("with statement", function()
202 value = 10 186 value = 10
203 } 187 }
204 local result 188 local result
205 do 189 repeat
206 local _accum_0 190 local _exp_0 = obj.value
207 repeat 191 if _exp_0 ~= nil then
208 local _exp_0 = obj.value 192 result = _exp_0
209 if _exp_0 ~= nil then 193 else
210 _accum_0 = _exp_0 194 result = 0
211 else 195 end
212 _accum_0 = 0 196 break
213 end 197 until true
214 break
215 until true
216 result = _accum_0
217 end
218 return assert.same(result, 10) 198 return assert.same(result, 10)
219 end) 199 end)
220 it("should handle nil object safely", function() 200 it("should handle nil object safely", function()
@@ -222,10 +202,10 @@ return describe("with statement", function()
222 do 202 do
223 local _with_0 = nil 203 local _with_0 = nil
224 do 204 do
225 local _accum_0 205 local _accum_0 = { }
226 repeat 206 repeat
227 if _with_0 ~= nil then 207 if _with_0 ~= nil then
228 _accum_0 = _with_0.value 208 result = _with_0.value
229 break 209 break
230 end 210 end
231 until true 211 until true
@@ -245,16 +225,12 @@ return describe("with statement", function()
245 end 225 end
246 } 226 }
247 local result 227 local result
248 do 228 repeat
249 local _accum_0 229 obj:add(10)
250 repeat 230 obj:add(5)
251 obj:add(10) 231 result = obj:get()
252 obj:add(5) 232 break
253 _accum_0 = obj:get() 233 until true
254 break
255 until true
256 result = _accum_0
257 end
258 return assert.same(result, 20) 234 return assert.same(result, 20)
259 end) 235 end)
260 return it("should support nested property access", function() 236 return it("should support nested property access", function()
@@ -266,14 +242,10 @@ return describe("with statement", function()
266 } 242 }
267 } 243 }
268 local result 244 local result
269 do 245 repeat
270 local _accum_0 246 result = obj.level1.level2.level3
271 repeat 247 break
272 _accum_0 = obj.level1.level2.level3 248 until true
273 break
274 until true
275 result = _accum_0
276 end
277 return assert.same(result, "deep") 249 return assert.same(result, "deep")
278 end) 250 end)
279end) 251end)