Reimplement (.method object . args) syntax
[clinton/parenscript.git] / t / test.lisp
index ca3b291..ac390f5 100644 (file)
@@ -1,10 +1,10 @@
-(in-package :ps-test)
+(in-package "PS-TEST")
 
 (defun normalize-whitespace (str)
   (substitute #\Space #\Newline (substitute #\Space #\Tab str)))
     
-(defun same-space-between-statements(code)
-  (let ((cl-ppcre:*use-bmh-matchers* nil)) ;; disable Booyer Moore string matching algorithm, which doesn't work very well on unicode lisps
+(defun same-space-between-statements (code)
+  (let ((cl-ppcre:*use-bmh-matchers* nil))
     (cl-ppcre:regex-replace-all "\\s*;\\s*" code "; ")))
     
 (defun remove-duplicate-spaces (str)
@@ -19,7 +19,7 @@
   (string-trim '(#\Space) str))
   
 (defun remove-spaces-near-brackets (str)
-  (let ((cl-ppcre:*use-bmh-matchers* nil)) ;; disable Booyer Moore string matching algorithm, which doesn't work very well on unicode lisps
+  (let ((cl-ppcre:*use-bmh-matchers* nil))
     (reduce (lambda (str rex-pair) (cl-ppcre:regex-replace-all (first rex-pair) str (second rex-pair)))
             (cons str '(("\\[ " "[") (" \\]" "]") ("\\( " "(") (" \\)" ")"))))))
   
      (same-space-between-statements
       (normalize-whitespace str))))))
 
-(defmacro test-ps-js (testname parenscript javascript)
-  (let (
-       ;; (parenscript
-       ;;   `(progn
-       ;; (defpackage parenscript-test
-       ;; (:lisp-package :parenscript-test))
-       ;; ,parenscript)))
-       )
-    `(test ,testname ()
-      (setf js::*var-counter* 0)
-    
-      ;; is-macro expands its argument again when reporting failures, so
-      ;; the reported temporary js-variables get wrong if we don't evalute first.
-      (let* ((generated-code (compile-script ',parenscript))
-             (js-code ,javascript))
-        (is (string= (normalize-js-code generated-code)
-                     (normalize-js-code js-code)))))))
-
-(defmacro defpstest (testname (&key (optimize t)) parenscript javascript)
-  `(test ,testname
-    (setf parenscript::*var-counter* 0)
-    (let* ((generated-code (compile-script ',parenscript))
-           (js-code ,javascript))
-      (is (string= (normalize-js-code generated-code)
-                   (normalize-js-code js-code))))))
+(defmacro test-ps-js (testname parenscript javascript &key (js-target-version *js-target-version*))
+  `(test ,testname ()
+         (is (string= (normalize-js-code (let ((*js-target-version* ,js-target-version))
+                                           (ps-doc* ',parenscript)))
+                      (normalize-js-code ,javascript)))))
 
 (defun run-tests()
   (format t "Running reference tests:~&")
@@ -63,4 +43,3 @@
   (run! 'ps-tests)
   (format t "Running Package System tests:~&")
   (run! 'package-system-tests))
-