Hash :
5fa25fee
Author :
Thomas de Grivel
Date :
2018-06-14T01:38:37
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
(in-package :common-lisp-user)
(defpackage :css-lexer/test
(:use :babel-stream
:cl
:cl-stream
:css-lexer
:unistd-stream)
#.(cl-stream:shadowing-import-from)
(:export
#:run
#:simple-test
#:test-file))
(in-package :css-lexer/test)
(defun simple-test ()
(with-stream (css (css-lexer
(string-input-stream
"body { color: #f00; }")))
(loop
(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))
(untrace token-stream::subseq*
token-stream:make-token)