;;;; -*- lisp -*- (in-package :it.bese.yaclml.test) (eval-when (:compile-toplevel :load-toplevel :execute) (def-suite :it.bese.yaclml.tal :in :it.bese.yaclml)) (in-suite :it.bese.yaclml.tal) (defparameter *test-generator* (make-instance 'file-system-generator :root-directories (list (make-pathname :directory (pathname-directory *load-truename*) :name nil :type nil :version :newest) (make-pathname :directory (append (pathname-directory *load-truename*) (list "root-a")) :name nil :type nil :version :newest) (make-pathname :directory (append (pathname-directory *load-truename*) (list "root-b")) :name nil :type nil :version :newest)))) (defun tal-compile&run (tal-string env) (with-output-to-string (*yaclml-stream*) (funcall (yaclml::compile-tal-string tal-string (find-package :it.bese.yaclml.test)) env *test-generator*))) (test non-tal (is (string= "" (tal-compile&run "" nil))) (is (string= "" (tal-compile&run "" nil))) (is (string= "
one two" (tal-compile&run "
one two" nil)))) (test tal-when (is (string= "OK1" (tal-compile&run "OK1" '((c . t))))) (is (string= "OK2" (tal-compile&run "OK2" '((c . nil))))) (is (string= "OK3" (tal-compile&run "OK3" nil)))) (test tal-replace (is (string= "OK!" (tal-compile&run "" '((c . "OK!")))))) (test tal-content (is (string= "OK!" (tal-compile&run "BAD BAD BAD" '((C . "OK!")))))) (test tal-include (is (string= "FOO" (with-output-to-string (*yaclml-stream*) (funcall (load-tal *test-generator* "inc1.tal") '((TO-INCLUDE . "inc2.tal")) *test-generator*)))) (is (string= "foo is FOOPARAM, and bar is BARINCLUDED" (with-output-to-string (*yaclml-stream*) (funcall (load-tal *test-generator* "inc3.tal") '((FOO . "FOOPARAM")) *test-generator*)))) (is (string= "OK" (with-output-to-string (*yaclml-stream*) (funcall (load-tal *test-generator* "inc6.tal") '() *test-generator*))))) (test tal-env (let* ((e (make-tal-environment (cons 'foo 4))) (e1 (make-tal-environment (cons 'foo 5)))) (is (= 4 (lookup-tal-variable 'foo e))) (is (= 5 (lookup-tal-variable 'foo e1))) (is (= 4 (lookup-tal-variable 'foo (extend-environment e e1)))) (is (= 5 (lookup-tal-variable 'foo (extend-environment e1 e))))))