UNDO: Added functions to set up and tear down a persistent compilation environment.
[clinton/parenscript.git] / t / ps-tests.lisp
index 0f1a7de..d811cfa 100644 (file)
@@ -1,4 +1,4 @@
-(in-package :js-test)
+(in-package :ps-test)
 ;; Other tests not in the reference
 
 (eval-when (:compile-toplevel :load-toplevel :execute)
@@ -68,7 +68,8 @@ x = 2 + sideEffect() + x + 5;")
             "(function (x) { return x; }) (10).toString()")
 
 (test no-whitespace-before-dot
-  (let* ((str (js:js* '(.to-string ((lambda (x) (return x)) 10))))
+  (let* ((parenscript::*enable-package-system* nil)
+        (str (compile-script '(.to-string ((lambda (x) (return x)) 10))))
          (dot-pos (position #\. str :test #'char=))
          (char-before (elt str (1- dot-pos)))
          (a-parenthesis #\)))
@@ -172,7 +173,8 @@ x = 2 + sideEffect() + x + 5;")
          }")
 
 (test escape-sequences-in-string
-  (let ((escapes `((#\\ . #\\)
+  (let ((parenscript::*enable-package-system* nil)
+       (escapes `((#\\ . #\\)
                    (#\b . #\Backspace)
                    (#\f . ,(code-char 12))
                    ("u000B" . ,(code-char #x000b));;Vertical tab, too uncommon to bother with
@@ -200,4 +202,38 @@ x = 2 + sideEffect() + x + 5;")
 
 (test-ps-js slot-value-setf
   (setf (slot-value x 'y) (+ (+ a 3) 4))
-  "x.y = (a + 3) + 4")
\ No newline at end of file
+  "x.y = (a + 3) + 4")
+
+(test-ps-js slot-value-conditional1
+  (slot-value (if zoo foo bar) 'x)
+  "(zoo ? foo : bar).x")
+
+(test-ps-js slot-value-conditional2
+  (slot-value (if (not zoo) foo bar) 'x)
+  "(!zoo ? foo : bar).x")
+
+(test script-star-eval1
+  (is (string= "x = 1; y = 2;" (normalize-js-code (let ((*enable-package-system* nil)) (script* '(setf x 1) '(setf y 2)))))))
+
+(test script-star-eval2
+  (is (string= "x = 1;" (normalize-js-code (let ((*enable-package-system* nil)) (script* '(setf x 1)))))))
+
+(test-ps-js slot-value-null1
+  (slot-value foo nil)
+  "foo")
+
+(test-ps-js slot-value-null2
+  (slot-value foo 'nil)
+  "foo")
+
+(test-ps-js unquoted-nil
+  nil
+  "null")
+
+(test-ps-js list-with-single-nil
+  (array 'nil)
+  "[null]")
+
+(test-ps-js quoted-nil
+  'nil
+  "null")
\ No newline at end of file