Fixed the CHAIN macro to correctly chain plain slot values.
[clinton/parenscript.git] / t / ps-tests.lisp
index 32ab88c..2350f03 100644 (file)
@@ -55,7 +55,7 @@ x = 2 + sideEffect() + x + 5;")
   "'hi'.toString();")
 
 (test-ps-js method-call-lit-object
-  ((@ (create :to-string (lambda () (return "it works"))) to-string))
+  ((@ (create to-string (lambda () (return "it works"))) to-string))
   "( { toString : function () { return 'it works'; } } ).toString();")
 
 (test-ps-js method-call-conditional
@@ -90,13 +90,13 @@ x = 2 + sideEffect() + x + 5;")
     (is (char= char-before a-parenthesis))))
 
 (test-ps-js simple-slot-value
-  (let ((foo (create :a 1)))
+  (let ((foo (create a 1)))
     (alert (slot-value foo 'a)))
   "var foo = { a : 1 };
    alert(foo.a);")
 
 (test-ps-js buggy-slot-value
-   (let ((foo (create :a 1))
+   (let ((foo (create a 1))
          (slot-name "a"))
     (alert (slot-value foo slot-name)))
   " var foo = { a : 1 };
@@ -516,9 +516,16 @@ __setf_someThing(_js1, _js2, _js3);")
 };")
 
 (test-ps-js cond-expression-final-t-clause
-  (defun foo () (return (cond ((< 1 2) (bar "foo") (* 4 5)) ((= a b) (+ c d)) ((< 1 2 3 4 5) x) (t "foo"))))
+  (defun foo ()
+    (return (cond ((< 1 2) (bar "foo") (* 4 5))
+                  ((= a b) (+ c d))
+                  ((< 1 2 3 4 5) x)
+                  (t "foo"))))
   "function foo() {
-    return 1 < 2 ? (bar('foo'), 4 * 5) : (a == b ? c + d : (1 < 2 < 3 < 4 < 5 ? x : 'foo'));
+    var _cmp3;
+    var _cmp2;
+    var _cmp1;
+    return 1 < 2 ? (bar('foo'), 4 * 5) : (a == b ? c + d : ((_cmp1 = 2, _cmp2 = 3, _cmp3 = 4, 1 < _cmp1 && _cmp1 < _cmp2 && _cmp2 < _cmp3 && _cmp3 < 5) ? x : 'foo'));
 };")
 
 (test-ps-js cond-expression-middle-t-clause ;; should this signal a warning?
@@ -534,7 +541,7 @@ __setf_someThing(_js1, _js2, _js3);")
                      :onclick (ps-inline (transport)))
                  img))
        img))
-  "document.write(LINKORNOT == 1 ? '<A HREF=\"#\" ONCLICK=\"' + ('javascript:' + 'transport' + '(' + ')') + '\">' + img + '</A>' : img);")
+  "document.write(LINKORNOT == 1 ? '<A HREF=\"#\" ONCLICK=\"' + ('javascript:' + 'transport()') + '\">' + img + '</A>' : img);")
 
 (test-ps-js negate-number-literal ;; ok, this was broken and fixed before, but no one bothered to add the test!
   (- 1)
@@ -742,7 +749,7 @@ try {
   "(window.eval || eval)()(foo, null);")
 
 (test-ps-js slot-value-object-literal
-  (slot-value (create :a 1) 'a)
+  (slot-value (create a 1) 'a)
   "({ a : 1 }).a;")
 
 (test-ps-js slot-value-lambda
@@ -1179,3 +1186,22 @@ x1 - x1;
 (test-ps-js slot-value-keyword
   (slot-value foo :bar)
   "foo['bar'];")
+
+(test-ps-js nary-comparison1
+  (lambda () (return (< 1 2 3)))
+  "function () {
+    var _cmp1;
+    return (_cmp1 = 2, 1 < _cmp1 && _cmp1 < 3);
+};")
+
+(test-ps-js chain-slot-value1
+  (chain ($ "foo") (bar x z) frob (baz 5))
+  "$('foo').bar(x, z).frob.baz(5);")
+
+(test-ps-js chain-slot-value2
+  (chain ($ "foo") bar baz)
+  "$('foo').bar.baz;")
+
+(test-ps-js chain-slot-value3
+  (chain ($ "foo") bar (x y) baz)
+  "$('foo').bar.x(y).baz;")