1;; Tests for `read-lines' 2 3(import (chicken file) 4 (chicken io)) 5 6(include "test.scm") 7 8(define input-test-file "read-lines.in") 9 10(with-output-to-file input-test-file 11 (lambda () 12 (print #<<EOF 131 142 153 164 175 18EOF 19))) 20 21(test-begin "read-lines") 22 23(test-equal 24 "without arguments" 25 '("1" "2" "3" "4" "5") 26 (with-input-from-file input-test-file read-lines)) 27 28(test-equal 29 "with a port as argument" 30 '("1" "2" "3" "4" "5") 31 (call-with-input-file input-test-file 32 (lambda (port) 33 (read-lines port)))) 34 35(test-equal 36 "with a limit" 37 '("1" "2") 38 (call-with-input-file input-test-file 39 (lambda (port) 40 (read-lines port 2)))) 41 42(test-error 43 "with an invalid first argument (port)" 44 (read-lines input-test-file)) 45 46(test-error 47 "with an invalid second argument (max)" 48 (call-with-input-file input-test-file 49 (lambda (port) 50 (dynamic-wind 51 void 52 (lambda () (read-lines port 2.0)) 53 (lambda () (close-input-port port)))))) 54 55(test-end "read-lines") 56 57(delete-file input-test-file) 58 59(test-exit) 60