diff --git a/test.lisp b/test.lisp
index 3b77e02..8dd06a2 100644
--- a/test.lisp
+++ b/test.lisp
@@ -10,7 +10,8 @@
#.(cl-stream:shadowing-import-from)
(:export
#:run
- #:simple-test))
+ #:simple-test
+ #:test-file))
(in-package :css-lexer/test)
@@ -19,10 +20,22 @@
(string-input-stream
"body { color: #f00; }")))
(loop
- (let ((r (stream-read css)))
- (print r)
- (when (typep r 'css-lexer::eof-token)
- (return))))))
+ (multiple-value-bind (token state) (stream-read css)
+ (ecase state
+ ((nil) (print token))
+ ((:eof) (return))
+ ((:non-blocking) (sleep 0.01)))))))
+
+(defun test-file (path)
+ (with-stream (css (css-lexer
+ (babel-input-stream
+ (unistd-stream-open path :read t))))
+ (loop
+ (multiple-value-bind (token state) (stream-read css)
+ (ecase state
+ ((nil) (print token))
+ ((:eof) (return))
+ ((:non-blocking) (sleep 0.01)))))))
(defun run ()
(simple-test))