You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tests/IntegrationSpec.hs
+44Lines changed: 44 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -215,6 +215,25 @@ spec = do
215
215
end
216
216
|]
217
217
`shouldReturn`"[2,3,4]\n"
218
+
it "Can use a lambda calling a nested function"$do
219
+
compileAndRun
220
+
[r|
221
+
let main => IO = do
222
+
let square (x: Int) = x * x
223
+
let toThird (x: Int) = x * square x
224
+
println map (\x -> toThird x), [1, 2, 3]
225
+
end
226
+
|]
227
+
`shouldReturn`"[1,8,27]\n"
228
+
it "Can use strict values in lambda"$do
229
+
compileAndRun
230
+
[r|
231
+
let main => IO = do
232
+
let strict = $2
233
+
println map (\x -> x * strict), [1, 2, 3]
234
+
end
235
+
|]
236
+
`shouldReturn`"[2,4,6]\n"
218
237
describe "Recursion"$do
219
238
it "Can use recursion"$do
220
239
compileAndRun
@@ -258,6 +277,31 @@ spec = do
258
277
|]
259
278
`shouldReturn`"14\n"
260
279
280
+
describe "No main"$do
281
+
it "Hello World"$do
282
+
compileAndRun
283
+
[r|
284
+
println "Hello, World!"
285
+
|]
286
+
`shouldReturn`"Hello, World!\n"
287
+
it "\"99\" bottles of beer"$do
288
+
compileAndRun
289
+
[r|
290
+
let bottles (i: Int) => IO = do
291
+
if i > 0 then do
292
+
println ^i : " bottles of beer on the wall, " : ^i : " bottles of beer."
293
+
println "Take one down and pass it around, " : ((i) - 1) as String : " bottles of beer on the wall.\n"
294
+
bottles (i)-1
295
+
else do
296
+
println "No more bottles of beer on the wall, no more bottles of beer."
297
+
println "Go to the store and buy some more, 99 bottles of beer on the wall."
298
+
end
299
+
end
300
+
301
+
bottles 3
302
+
|]
303
+
`shouldReturn`"3 bottles of beer on the wall, 3 bottles of beer.\nTake one down and pass it around, 2 bottles of beer on the wall.\n\n2 bottles of beer on the wall, 2 bottles of beer.\nTake one down and pass it around, 1 bottles of beer on the wall.\n\n1 bottles of beer on the wall, 1 bottles of beer.\nTake one down and pass it around, 0 bottles of beer on the wall.\n\nNo more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall.\n"
304
+
261
305
-- describe "Import"
262
306
-- it "Can find function based on type with lists, multiple definitions and pattern matching" $ do
0 commit comments