39 lines
1.5 KiB
Common Lisp
39 lines
1.5 KiB
Common Lisp
(in-package #:user-side-compiler/test)
|
|
|
|
(eval-when (:compile-toplevel :load-toplevel :execute)
|
|
(use-package '#:parachute))
|
|
|
|
(defun load-example (name)
|
|
(uiop:read-file-string
|
|
(let ((default (asdf:system-relative-pathname
|
|
'#:user-side-compiler/test name)))
|
|
(make-pathname
|
|
:defaults default
|
|
:directory (append (pathname-directory default) '("tests"))))))
|
|
|
|
(define-test should-compile ()
|
|
(let ((*debug-io* (make-string-output-stream)))
|
|
(loop :for test :in '("example-1.c6l" "example-2.c6l" "example-3.c6l"
|
|
"example-4.c6l" "example-5.c6l" "example-6.c6l")
|
|
:do (true
|
|
(> (length (handler-bind
|
|
((usc:missing-function-error #'continue))
|
|
(usc:compile-string-to-bytes (load-example test))))
|
|
0)
|
|
test))))
|
|
|
|
(define-test should-not-compile)
|
|
|
|
(define-test syntax-errors
|
|
:parent should-not-compile
|
|
(let ((*debug-io* (make-string-output-stream)))
|
|
(loop :for test :in '("syntax-error-1.c6l" "syntax-error-2.c6l"
|
|
"syntax-error-3.c6l" "syntax-error-4.c6l"
|
|
"syntax-error-5.c6l")
|
|
:do (multiple-value-bind (ignore condition)
|
|
(ignore-errors
|
|
(handler-bind
|
|
((usc:missing-function-error #'continue))
|
|
(usc:compile-string-to-bytes (load-example test))))
|
|
(declare (ignore ignore))
|
|
(of-type usc:parser-error condition test)))))
|