| 1 |
|
| 2 |
#!eof |
| 3 |
(add-tests-with-string-output "tokenizer" |
| 4 |
[(let () |
| 5 |
(define test-tokenizer |
| 6 |
(lambda (p) |
| 7 |
;(display (input-port? p) (standard-error-port)) |
| 8 |
(let ([tok (read-token p)]) |
| 9 |
(cond |
| 10 |
[(eof-object? tok) 'ok] |
| 11 |
[(or (eq? tok 'lparen) |
| 12 |
(eq? tok 'rparen) |
| 13 |
(eq? tok 'vparen) |
| 14 |
(eq? tok 'lbrack) |
| 15 |
(eq? tok 'rbrack) |
| 16 |
(eq? tok 'dot) |
| 17 |
(and (pair? tok) |
| 18 |
(or (eq? (car tok) 'datum) |
| 19 |
(eq? (car tok) 'macro)))) |
| 20 |
(test-tokenizer p)] |
| 21 |
[else |
| 22 |
(display tok) |
| 23 |
(error 'test "Invalid token ~s" tok)])))) |
| 24 |
(define test-file |
| 25 |
(lambda (filename) |
| 26 |
(display "Testing " (standard-error-port)) |
| 27 |
(display filename (standard-error-port)) |
| 28 |
(display "..." (standard-error-port)) |
| 29 |
(let ([p (open-input-file filename)]) |
| 30 |
; (display (input-port? p)(standard-error-port)) |
| 31 |
(test-tokenizer p)))) |
| 32 |
(define test-files |
| 33 |
(lambda (files) |
| 34 |
(unless (null? files) |
| 35 |
(test-file (car files)) |
| 36 |
(test-files (cdr files))))) |
| 37 |
(define filenames |
| 38 |
'("libsymboltable-4.4.ss" |
| 39 |
"libhandlers-3.3.ss" |
| 40 |
"libcore-4.4.ss" |
| 41 |
"libio-4.2.ss" |
| 42 |
"libwriter-4.4.ss" |
| 43 |
"libtokenizer-4.3.ss" |
| 44 |
"compiler-5.1.ss")) |
| 45 |
(when (null? filenames) |
| 46 |
(error 'no-files-provided-in-test "add them")) |
| 47 |
(test-files filenames) |
| 48 |
'ok) => "ok\n"] |
| 49 |
|
| 50 |
) |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
(add-tests-with-string-output "reader" |
| 55 |
[(let () |
| 56 |
(define test-reader |
| 57 |
(lambda (p) |
| 58 |
(let ([x (read p)]) |
| 59 |
(cond |
| 60 |
[(eof-object? x) 'ok] |
| 61 |
[else (test-reader p)])))) |
| 62 |
(define test-file |
| 63 |
(lambda (filename) |
| 64 |
(display "Testing " (standard-error-port)) |
| 65 |
(display filename (standard-error-port)) |
| 66 |
(display "..." (standard-error-port)) |
| 67 |
(test-reader (open-input-file filename)))) |
| 68 |
(define test-files |
| 69 |
(lambda (files) |
| 70 |
(unless (null? files) |
| 71 |
(test-file (car files)) |
| 72 |
(test-files (cdr files))))) |
| 73 |
(define filenames |
| 74 |
'("libsymboltable-4.4.ss" |
| 75 |
"libhandlers-3.3.ss" |
| 76 |
"libcore-4.4.ss" |
| 77 |
"libio-4.2.ss" |
| 78 |
"libwriter-4.4.ss" |
| 79 |
"libtokenizer-4.3.ss" |
| 80 |
"compiler-5.1.ss")) |
| 81 |
(when (null? filenames) |
| 82 |
(error 'no-files-provided-in-test "add them")) |
| 83 |
(test-files filenames) |
| 84 |
'ok) => "ok\n"] |
| 85 |
|
| 86 |
) |