|
5 | 5 | (let closure (fun (&foo) ()))
|
6 | 6 |
|
7 | 7 | (test:suite builtin {
|
8 |
| - (test:eq (type []) "List") |
9 |
| - (test:eq (type true) "Bool") |
10 |
| - (test:eq (type false) "Bool") |
11 |
| - (test:eq (type nil) "Nil") |
12 |
| - (test:eq (type 1) "Number") |
13 |
| - (test:eq (type "hello") "String") |
14 |
| - (test:eq (type print) "CProc") |
15 |
| - (test:eq (type foo) "Function") |
16 |
| - (test:eq (type closure) "Closure") |
17 |
| - |
18 |
| - (test:expect (not (io:fileExists? "test.txt"))) |
19 |
| - (io:writeFile "test.txt" "hello, world!") |
20 |
| - (test:expect (io:fileExists? "test.txt")) |
21 |
| - (test:eq (io:readFile "test.txt") "hello, world!") |
22 |
| - (io:appendToFile "test.txt" "bis") |
23 |
| - (test:eq (io:readFile "test.txt") "hello, world!bis") |
24 |
| - (test:expect (> (len (io:listFiles "./")) 0)) |
25 |
| - (test:expect (not (io:dir? "test.txt"))) |
26 |
| - (test:expect (not (io:fileExists? "temp"))) |
27 |
| - (io:makeDir "temp") |
28 |
| - (test:expect (io:fileExists? "temp")) |
29 |
| - (test:expect (io:dir? "temp")) |
30 |
| - (let old (time)) |
31 |
| - (sys:sleep 1) |
32 |
| - (test:expect (< old (time))) |
| 8 | + (test:case "types" { |
| 9 | + (test:eq (type []) "List") |
| 10 | + (test:eq (type true) "Bool") |
| 11 | + (test:eq (type false) "Bool") |
| 12 | + (test:eq (type nil) "Nil") |
| 13 | + (test:eq (type 1) "Number") |
| 14 | + (test:eq (type "hello") "String") |
| 15 | + (test:eq (type print) "CProc") |
| 16 | + (test:eq (type foo) "Function") |
| 17 | + (test:eq (type closure) "Closure") }) |
| 18 | + |
| 19 | + (test:case "closures" { |
| 20 | + (mut keep true) |
| 21 | + (mut foo nil) |
| 22 | + (while keep { |
| 23 | + (set foo (fun (&keep) keep)) |
| 24 | + (set keep false) }) |
| 25 | + (test:expect foo.keep "capture inside a deeper scope works") }) |
| 26 | + |
| 27 | + (test:case "files" { |
| 28 | + (test:expect (not (io:fileExists? "test.txt"))) |
| 29 | + (io:writeFile "test.txt" "hello, world!") |
| 30 | + (test:expect (io:fileExists? "test.txt")) |
| 31 | + (test:eq (io:readFile "test.txt") "hello, world!") |
| 32 | + (io:appendToFile "test.txt" "bis") |
| 33 | + (test:eq (io:readFile "test.txt") "hello, world!bis") |
| 34 | + (test:expect (> (len (io:listFiles "./")) 0)) |
| 35 | + (test:expect (not (io:dir? "test.txt"))) |
| 36 | + (test:expect (not (io:fileExists? "temp"))) |
| 37 | + (io:makeDir "temp") |
| 38 | + (test:expect (io:fileExists? "temp")) |
| 39 | + (test:expect (io:dir? "temp")) }) |
| 40 | + |
| 41 | + (test:case "time" { |
| 42 | + (let old (time)) |
| 43 | + (sys:sleep 1) |
| 44 | + (test:expect (< old (time))) }) |
33 | 45 |
|
34 | 46 | (mut rands [])
|
35 | 47 | (mut i 0)
|
|
0 commit comments