-
Notifications
You must be signed in to change notification settings - Fork 0
/
read-lines-tests.scm
56 lines (43 loc) · 920 Bytes
/
read-lines-tests.scm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
;; Tests for `read-lines'
(import (chicken file)
(chicken io))
(include "test.scm")
(define input-test-file "read-lines.in")
(with-output-to-file input-test-file
(lambda ()
(print #<<EOF
1
2
3
4
5
EOF
)))
(test-begin "read-lines")
(test-equal
"without arguments"
'("1" "2" "3" "4" "5")
(with-input-from-file input-test-file read-lines))
(test-equal
"with a port as argument"
'("1" "2" "3" "4" "5")
(call-with-input-file input-test-file
(lambda (port)
(read-lines port))))
(test-equal
"with a limit"
'("1" "2")
(call-with-input-file input-test-file
(lambda (port)
(read-lines port 2))))
(test-error
"with an invalid first argument (port)"
(read-lines input-test-file))
(test-error
"with an invalid second argument (max)"
(call-with-input-file input-test-file
(lambda (port)
(read-lines port 2.0))))
(test-end "read-lines")
(delete-file input-test-file)
(test-exit)