1 ;; Copying and distribution of this file, with or without modification,
2 ;; are permitted in any medium without royalty provided the copyright
3 ;; notice and this notice are preserved. This file is offered as-is,
4 ;; without any warranty.
7 (named-readtables:in-readtable
:parenscript
)
9 (in-suite output-tests
)
11 (test-ps-js statements-and-expressions-1
15 (test-ps-js statements-and-expressions-2
23 (test-ps-js symbol-conversion-1
25 "bangwhathashatpercent;")
27 (test-ps-js symbol-conversion-2
31 (test-ps-js symbol-conversion-3
35 (test-ps-js symbol-conversion-4
39 (test-ps-js symbol-conversion-5
41 "encodeURIComponent;")
43 (test-ps-js symbol-conversion-6
47 (test-ps-js number-literals-1
51 (test-ps-js number-literals-2
55 (test-ps-js number-literals-3
59 (test-ps-js string-literals-1
63 (test-ps-js string-literals-2
67 (test-ps-js string-literals-3
71 (test-ps-js array-literals-1
75 (test-ps-js array-literals-2
79 (test-ps-js array-literals-3
81 (array "foobar" "bratzel bub"))
82 "[ [ 2, 3 ], [ 'foobar', 'bratzel bub' ] ];")
84 (test-ps-js array-literals-4
88 (test-ps-js array-literals-5
90 "new Array(1, 2, 3);")
92 (test-ps-js array-literals-6
95 (make-array "foobar" "bratzel bub"))
96 "new Array(new Array(2, 3), new Array('foobar', 'bratzel bub'));")
98 (test-ps-js object-literals-1
99 (create foo
"bar" :blorg
1)
100 "{ foo : 'bar', 'blorg' : 1 };")
102 (test-ps-js object-literals-2
105 another-object
(create :schtrunz
1))
108 anotherObject : { 'schtrunz' : 1 } };")
110 (test-ps-js object-literals-3
111 (getprop an-object
'foo
)
114 (test-ps-js object-literals-4
115 (@ an-object foo bar
)
118 (test-ps-js object-literals-5
119 (with-slots (a b c
) this
121 "this.a + this.b + this.c;")
123 (test-ps-js regular-expression-literals-1
127 (test-ps-js regular-expression-literals-2
131 (test-ps-js literal-symbols-1
135 (test-ps-js literal-symbols-2
139 (test-ps-js literal-symbols-3
143 (test-ps-js literal-symbols-4
149 (test-ps-js literal-symbols-5
153 (test-ps-js literal-symbols-6
157 (test-ps-js variables-1
161 (test-ps-js variables-2
165 (test-ps-js variables-3
169 (test-ps-js function-calls-and-method-calls-1
173 (test-ps-js function-calls-and-method-calls-2
174 (foobar (blorg 1 2) (blabla 3 4) (array 2 3 4))
175 "foobar(blorg(1, 2), blabla(3, 4), [ 2, 3, 4 ]);")
177 (test-ps-js function-calls-and-method-calls-3
178 ((getprop this
'blorg
) 1 2)
181 (test-ps-js function-calls-and-method-calls-4
185 (test-ps-js function-calls-and-method-calls-5
186 ((getprop (aref foobar
1) 'blorg
) nil t
)
187 "foobar[1].blorg(null, true);")
189 (test-ps-js operator-expressions-1
193 (test-ps-js operator-expressions-2
197 (test-ps-js operator-expressions-3
198 (* 1 (+ 2 3 4) 4 (/ 6 7))
199 "1 * (2 + 3 + 4) * 4 * 6 / 7;")
201 (test-ps-js operator-expressions-4
205 (test-ps-js operator-expressions-5
209 (test-ps-js operator-expressions-6
213 (test-ps-js operator-expressions-7
217 (test-ps-js operator-expressions-8
221 (test-ps-js body-forms-1
222 (progn (blorg i
) (blafoo i
))
226 (test-ps-js body-forms-2
227 (+ i
(progn (blorg i
) (blafoo i
)))
228 "i + (blorg(i), blafoo(i));")
230 (test-ps-js function-definition-1
231 (defun a-function (a b
)
233 "function aFunction(a, b) {
237 (test-ps-js function-definition-2
238 (lambda (a b
) (+ a b
))
243 (test-ps-js assignment-1
247 (test-ps-js assignment-2
248 (setf a
2 b
3 c
4 x
(+ a b c
))
254 (test-ps-js assignment-3
255 (setf a
(+ a
2 3 4 a
))
256 "a = a + 2 + 3 + 4 + a;")
258 (test-ps-js assignment-4
262 (test-ps-js assignment-5
272 (test-ps-js assignment-6
276 (test-ps-js assignment-8
278 (defun (setf color
) (new-color el
)
279 (setf (getprop (getprop el
'style
) 'color
) new-color
))
280 (setf (color some-div
) (+ 23 "em")))
281 "function __setf_color(newColor, el) {
282 return el.style.color = newColor;
284 __setf_color(23 + 'em', someDiv);")
286 (test-ps-js assignment-10
288 (defsetf left
(el) (offset)
289 `(setf (getprop (getprop ,el
'style
) 'left
) ,offset
))
290 (setf (left some-div
) (+ 123 "px")))
292 var _js1 = 123 + 'px';
293 _js2.style.left = _js1;")
295 (test-ps-js assignment-12
296 (macrolet ((left (el)
297 `(getprop ,el
'offset-left
)))
299 "someDiv.offsetLeft;")
301 (test-ps-js nil-block-return-1
307 (test-ps-js single-argument-statements-2
311 (test-ps-js single-argument-expression-1
312 (delete (new (*foobar
2 3 4)))
313 "delete new Foobar(2, 3, 4);")
315 (test-ps-js single-argument-expression-2
316 (if (= (typeof blorg
) *string
)
317 (alert (+ "blorg is a string: " blorg
))
318 (alert "blorg is not a string"))
319 "if (typeof blorg === String) {
320 alert('blorg is a string: ' + blorg);
322 alert('blorg is not a string');
325 (test-ps-js conditional-statements-1
327 (if ((@ blorg is-correct
))
328 (progn (carry-on) (return-from foo i
))
329 (alert "blorg is not correct!")))
331 if (blorg.isCorrect()) {
335 return alert('blorg is not correct!');
339 (test-ps-js conditional-statements-2
340 (+ i
(if ((@ blorg add-one
)) 1 2))
341 "i + (blorg.addOne() ? 1 : 2);")
343 (test-ps-js conditional-statements-3
345 (when ((@ blorg is-correct
))
347 (return-from foo i
)))
349 if (blorg.isCorrect()) {
355 (test-ps-js conditional-statements-4
356 (unless ((@ blorg is-correct
))
357 (alert "blorg is not correct!"))
358 "if (!blorg.isCorrect()) {
359 alert('blorg is not correct!');
362 (test-ps-js variable-declaration-1
363 (defvar *a
* (array 1 2 3))
364 "var A = [ 1, 2, 3 ];")
366 (test-ps-js variable-declaration-2
367 (progn (defvar *a
* 4)
386 (test-ps-js iteration-constructs-1
387 (do* ((a) b
(c (array "a" "b" "c" "d" "e"))
389 (e (aref c d
) (aref c d
)))
390 ((or (= d
(@ c length
)) (string= e
"x")))
392 (funcall (@ document write
) (+ "a: " a
" b: " b
"<br/>")))
393 "for (var a = null, b = null, c = ['a', 'b', 'c', 'd', 'e'], d = 0, e = c[d]; !(d === c.length || e === 'x'); d += 1, e = c[d]) {
396 document.write('a: ' + a + ' b: ' + b + '<br/>');
399 (test-ps-js iteration-constructs-2
401 (s 0 (+ s i
(1+ i
))))
403 (funcall (@ document write
) (+ "i: " i
" s: " s
"<br/>")))
407 document.write('i: ' + i + ' s: ' + s + '<br/>');
409 var _js2 = s + i + i + 1;
414 (test-ps-js iteration-constructs-3
416 (s 0 (+ s i
(1- i
))))
418 ((@ document write
) (+ "i: " i
" s: " s
"<br/>")))
419 "for (var i = 0, s = 0; i <= 10; i += 1, s = s + i + i - 1) {
420 document.write('i: ' + i + ' s: ' + s + '<br/>');
423 (test-ps-js iteration-constructs-4
424 (let ((arr (array "a" "b" "c" "d" "e")))
425 (dotimes (i (@ arr length
))
426 ((@ document write
) (+ "i: " i
" arr[i]: " (aref arr i
) "<br/>"))))
427 "var arr = ['a', 'b', 'c', 'd', 'e'];
428 for (var i = 0; i < arr.length; i += 1) {
429 document.write('i: ' + i + ' arr[i]: ' + arr[i] + '<br/>');
432 (test-ps-js iteration-constructs-5
434 (alert (+ "Summation to 10 is "
436 (incf res
(1+ i
))))))
438 alert('Summation to 10 is ' + (function () {
439 for (var i = 0; i < 10; i += 1) {
445 (test-ps-js iteration-constructs-6
446 (let ((l (list 1 2 4 8 16 32)))
448 ((@ document write
) (+ "c: " c
"<br/>"))))
449 "var l = [1, 2, 4, 8, 16, 32];
450 for (var c = null, _js_idx1 = 0; _js_idx1 < l.length; _js_idx1 += 1) {
452 document.write('c: ' + c + '<br/>');
455 (test-ps-js iteration-constructs-7
456 (let ((l '(1 2 4 8 16 32))
458 (alert (+ "Sum of " l
" is: "
461 "var l = [1, 2, 4, 8, 16, 32];
463 alert('Sum of ' + l + ' is: ' + (function () {
464 for (var c = null, _js_idx1 = 0; _js_idx1 < l.length; _js_idx1 += 1) {
471 (test-ps-js iteration-constructs-8
472 (let ((obj (create a
1 b
2 c
3)))
474 ((@ document write
) (+ i
": " (aref obj i
) "<br/>"))))
475 "var obj = { a : 1, b : 2, c : 3 };
477 document.write(i + ': ' + obj[i] + '<br/>');
480 (test-ps-js iteration-constructs-9
481 (while ((@ film is-not-finished
))
482 ((@ this eat
) (new *popcorn
)))
483 "while (film.isNotFinished()) {
484 this.eat(new Popcorn);
487 (test-ps-js the-case-statement-1
489 ((1 "one") (alert "one"))
491 (t (alert "default clause")))
501 alert('default clause');
504 (test-ps-js the-case-statement-2
505 (switch (aref blorg i
)
506 (1 (alert "If I get here"))
507 (2 (alert "I also get here"))
508 (default (alert "I always get here")))
510 case 1: alert('If I get here');
511 case 2: alert('I also get here');
512 default: alert('I always get here');
515 (test-ps-js the-try-statement-1
518 (alert (+ "an error happened: " error
)))
520 (alert "Leaving the try form")))
524 alert('an error happened: ' + error);
526 alert('Leaving the try form');
529 (test-ps-js the-html-generator-1
530 (ps-html ((:a
:href
"foobar") "blorg"))
531 "'<A HREF=\"foobar\">blorg</A>';")
533 (test-ps-js the-html-generator-2
534 (ps-html ((:a
:href
(generate-a-link)) "blorg"))
535 "['<A HREF=\"', generateALink(), '\">blorg</A>']['join']('');")
537 (test-ps-js the-html-generator-3
538 (funcall (getprop document
'write
)
539 (ps-html ((:a
:href
"#"
540 :onclick
(ps-inline (transport))) "link")))
541 "document.write(['<A HREF=\"#\" ONCLICK=\"', 'javascript:' + 'transport()', '\">link</A>']['join'](''));")
543 (test-ps-js the-html-generator-4
546 (setf (getprop element
'inner-h-t-m-l
)
547 (ps-html ((:textarea
(or disabled
(not authorized
)) :disabled
"disabled")
549 "var disabled = null;
550 var authorized = true;
551 element.innerHTML = ['<TEXTAREA', disabled || !authorized ? [' DISABLED=\"', 'disabled', '\"']['join']('') : '', '>Edit me</TEXTAREA>']['join']('');")
553 (test-ps-js plus-is-not-commutative
554 (setf x
(+ "before" x
"after"))
555 "x = 'before' + x + 'after';")
557 (test-ps-js plus-works-if-first
558 (setf x
(+ x
"middle" "after"))
559 "x = x + 'middle' + 'after';")
561 (test-ps-js setf-side-effects
567 (setf x
(+ 2 (side-effect) x
5))))
569 function sideEffect() {
573 x = 2 + sideEffect() + x + 5;")
575 (test-ps-js method-call-op-form
576 (funcall (getprop (+ "" x
) 'to-string
))
577 "('' + x).toString();")
579 (test-ps-js method-call-op-form-args
580 (funcall (getprop (+ "" x
) 'foo
) 1 2 :baz
3)
581 "('' + x).foo(1, 2, 'baz', 3);")
583 (test-ps-js method-call-string
584 ((getprop "hi" 'to-string
))
587 (test-ps-js method-call-conditional
591 (test-ps-js method-call-variable
595 (test-ps-js method-call-array
596 ((@ (list 10 20) to-string
))
597 "[ 10, 20 ].toString();")
599 (test-ps-js method-call-lambda-call
600 (funcall (getprop (funcall (lambda (x) x
) 10) 'to-string
))
601 "(function (x) { return x; })(10).toString();")
603 (test no-whitespace-before-dot
604 (let* ((str (ps* '((@ ((lambda (x) x
) 10) to-string
))))
605 (dot-pos (position #\. str
:test
#'char
=))
606 (char-before (elt str
(1- dot-pos
)))
608 (is (char= char-before a-parenthesis
))))
610 (test-ps-js simple-getprop
611 (let ((foo (create a
1)))
612 (alert (getprop foo
'a
)))
613 "var foo = { a : 1 };
616 (test-ps-js buggy-getprop
617 (getprop foo slot-name
)
620 (test-ps-js buggy-getprop-two
621 (getprop foo
(get-slot-name))
622 "foo[getSlotName()];")
624 (test-ps-js old-case-is-now-switch
625 ;; Switch was "case" before, but that was very non-lispish.
626 ;; For example, this code makes three messages and not one
627 ;; which may have been expected. This is because a switch
628 ;; statment must have a break statement for it to return
629 ;; after the alert. Otherwise it continues on the next
631 (switch (aref blorg i
)
634 (default (alert "default clause")))
636 case 1: alert('one');
637 case 2: alert('two');
638 default: alert('default clause');
641 (test-ps-js lisp-like-case
645 (default (alert "default clause")))
653 default: alert('default clause');
657 (test-ps-js even-lispier-case
659 ((1 2) (alert "Below three"))
661 (t (alert "Something else")))
665 alert('Below three');
670 default: alert('Something else');
673 (test-ps-js otherwise-case
676 (otherwise (alert "default clause")))
681 default: alert('default clause');
684 (test escape-sequences-in-string
685 (let ((escapes `((#\\ .
#\\)
687 (#\f .
,(code-char 12))
688 ("u000B" .
,(code-char #x000b
));;Vertical tab, too uncommon to bother with
691 (#\' .
#\');;Double quote need not be quoted because parenscript strings are single quoted
693 ("u001F" .
,(code-char #x001f
));; character below 32
694 ("u0080" .
,(code-char 128)) ;;Character over 127. Actually valid, parenscript escapes them to be sure.
695 ("uABCD" .
,(code-char #xabcd
)))));; Really above ascii.
696 (loop for
(js-escape . lisp-char
) in escapes
697 for generated
= (ps-doc* `(let ((x ,(format nil
"hello~ahi" lisp-char
)))))
698 for wanted
= (format nil
"var x = 'hello\\~ahi';" js-escape
)
699 do
(is (string= (normalize-js-code generated
) wanted
)))))
701 (test-ps-js getprop-setf
702 (setf (getprop x
'y
) (+ (+ a
3) 4))
705 (test-ps-js getprop-conditional1
706 (getprop (if zoo foo bar
) 'x
)
707 "(zoo ? foo : bar).x;")
709 (test-ps-js getprop-conditional2
710 (getprop (if (not zoo
) foo bar
) 'x
)
711 "(!zoo ? foo : bar).x;")
713 (test script-star-eval1
714 (is (string= "x = 1; y = 2;" (normalize-js-code (ps* '(setf x
1) '(setf y
2))))))
716 (test script-star-eval2
717 (is (string= "x = 1;" (normalize-js-code (ps* '(setf x
1))))))
719 (test-ps-js list-with-single-nil
723 (test-ps-js quoted-nil-is-array
728 (progn (defsetf baz
(x y
) (newval) `(set-baz ,x
,y
,newval
))
733 setBaz(_js2, _js3, _js1);")
735 (test-ps-js setf-macroexpands1
736 (macrolet ((bar (x y
)
738 (setf (bar foo
2) 3))
741 (test-ps-js defsetf-short
742 (progn (defsetf baz set-baz
"docstring")
743 (setf (baz 1 2 3) "foo"))
744 "setBaz(1, 2, 3, 'foo');")
746 (test-ps-js defun-setf1
747 (progn (defun (setf some-thing
) (new-val i1 i2
)
748 (setf (aref *some-thing
* i1 i2
) new-val
))
749 (setf (some-thing 1 2) "foo"))
750 "function __setf_someThing(newVal, i1, i2) {
751 return SOMETHING[i1][i2] = newVal;
753 __setf_someThing('foo', 1, 2);")
755 (test-ps-js defun-optional1
756 (defun test-opt (&optional x
)
758 "function testOpt(x) {
759 return x ? 'yes' : 'no';
762 (test-ps-js defun-optional2
763 (defun foo (x &optional y
)
765 "function foo(x, y) {
769 (test-ps-js defun-optional3
770 (defun blah (&optional
(x 0))
773 if (x === undefined) {
779 (test-ps-js defun-optional4
780 (lambda (&optional
(x 0 supplied?
))
783 var suppliedwhat = x !== undefined;
790 (test-ps-js return-nothing
791 (defun foo () (return-from foo
))
796 (test-ps-js set-timeout
797 (set-timeout (lambda () (alert "foo")) 10)
798 "setTimeout(function () { return alert('foo'); }, 10);")
800 (test-ps-js operator-precedence
804 (test-ps-js operators-1
824 (test-ps-js setf-conditional
825 (setf foo
(if x
1 2))
828 (test-ps-js obj-literal-numbers
832 (test-ps-js obj-literal-strings
836 (test-ps-js getprop-string
840 (test-ps-js getprop-string1
841 (getprop "bar" 'length
)
844 (test-ps-js getprop-progn
845 (getprop (progn (some-fun "abc") "123") "length")
846 "(someFun('abc'), '123')['length'];")
848 (test-ps-js method-call-block
849 ((@ (progn (some-fun "abc") "123") to-string
))
850 "(someFun('abc'), '123').toString();")
852 (test-ps-js create-blank
856 (test-ps-js blank-object-literal
860 (test-ps-js array-literal1
864 (test-ps-js array-literal2
868 (test-ps-js array-literal3
872 (test-ps-js array-literal4
876 (test-ps-js array-literal5
878 "[[1, 2], ['a', 'b']];")
880 (test-ps-js defun-rest1
881 (defun foo (&rest bar
)
882 (alert (aref bar
1)))
885 for (var i1 = 0; i1 < arguments.length - 0; i1 += 1) {
886 bar[i1] = arguments[i1 + 0];
888 return alert(bar[1]);
891 (test-ps-js defun-rest2
892 (defun foo (baz &rest bar
) (+ baz
(aref bar
1)))
895 for (var i1 = 0; i1 < arguments.length - 1; i1 += 1) {
896 bar[i1] = arguments[i1 + 1];
901 (test-ps-js defun-keyword1
902 (defun zoo (foo bar
&key baz
) (+ foo bar baz
))
903 "function zoo(foo, bar) {
904 var _js2 = arguments.length;
905 for (var n1 = 2; n1 < _js2; n1 += 2) {
906 switch (arguments[n1]) {
908 baz = arguments[n1 + 1];
912 return foo + bar + baz;
915 (test-ps-js defun-keyword2
916 (defun zoo (&key baz
) (* baz baz
))
918 var _js2 = arguments.length;
919 for (var n1 = 0; n1 < _js2; n1 += 2) {
920 switch (arguments[n1]) {
922 baz = arguments[n1 + 1];
929 (test-ps-js defun-keyword3
930 (defun zoo (&key baz
(bar 4)) (* baz bar
))
932 var _js2 = arguments.length;
933 for (var n1 = 0; n1 < _js2; n1 += 2) {
934 switch (arguments[n1]) {
936 baz = arguments[n1 + 1];
939 bar = arguments[n1 + 1];
943 var bar = undefined === bar ? 4 : bar;
947 (test-ps-js defun-keyword4
948 (defun hello-world (&key
((:my-name-key my-name
) 1))
950 "function helloWorld() {
951 var _js2 = arguments.length;
952 for (var n1 = 0; n1 < _js2; n1 += 2) {
953 switch (arguments[n1]) {
955 myName = arguments[n1 + 1];
958 var myName = undefined === myName ? 1 : myName;
962 (test-ps-js defun-keyword-supplied
963 (lambda (&key
(foo 1 supplied?
))
966 var _js2 = arguments.length;
967 for (var n1 = 0; n1 < _js2; n1 += 2) {
968 switch (arguments[n1]) {
970 foo = arguments[n1 + 1];
975 var foo = undefined === foo ? 1 : foo;
979 (test-ps-js keyword-funcall1
983 (test-ps-js keyword-funcall2
984 (func :baz
1 :bar foo
)
985 "func('baz', 1, 'bar', foo);")
987 (test-ps-js keyword-funcall3
989 "fun(a, b, 'baz', c);")
999 ((= y
(* x
4)) (foo "blah") (* x y
)))
1002 } else if (y === x * 4) {
1007 (test-ps-js if-exp-without-else-return
1008 (defun foo () (return-from foo
(if x
1)))
1010 return x ? 1 : null;
1013 (test-ps-js progn-expression-single-statement
1014 (defun foo () (return-from foo
(progn (* x y
))))
1019 (test-ps-js cond-expression1
1021 (cond ((< 1 2) (bar "foo") (* 4 5))))
1029 (test-ps-js cond-expression2
1031 (cond ((< 2 1) "foo")
1036 } else if (7 === 7) {
1041 (test-ps-js cond-expression-final-t-clause
1043 (cond ((< 1 2) (bar "foo") (* 4 5))
1054 } else if (a === b) {
1056 } else if (_cmp1 = 2, _cmp2 = 3, _cmp3 = 4, 1 < _cmp1 && _cmp1 < _cmp2 && _cmp2 < _cmp3 && _cmp3 < 5) {
1063 (test-ps-js cond-expression-middle-t-clause
;; should this signal a warning?
1076 (test-ps-js funcall-if-expression
1077 (funcall (getprop document
'write
)
1078 (if (= *linkornot
* 1)
1079 (ps-html ((:a
:href
"#"
1080 :onclick
(ps-inline (transport)))
1083 "document.write(LINKORNOT === 1 ? ['<A HREF=\"#\" ONCLICK=\"', 'javascript:' + 'transport()', '\">', img, '</A>']['join']('') : img);")
1085 (test-ps-js negate-number-literal
1089 (test macro-environment1
1090 (is (string= (normalize-js-code (let* ((macroname (gensym)))
1091 (ps* `(defmacro ,macroname
(x) `(+ ,x
123))
1093 (macrolet ((,macroname
(x) `(aref data
,x
)))
1094 (when (,macroname x
)
1095 (setf (,macroname x
) 123)))))))
1098 return data[x] ? (data[x] = 123) : null;
1101 (test macro-environment2
1102 (is (string= (normalize-js-code (let ((outer-lexical-variable 1))
1103 (defpsmacro macro-environment2-macro
(x)
1104 `(+ ,outer-lexical-variable
,x
))
1105 (ps* '(macro-environment2-macro 2))))
1106 (normalize-js-code "1 + 2;"))))
1108 (test-ps-js ampersand-whole-1
1109 (macrolet ((foo (&whole foo bar baz
)
1110 (declare (ignore bar baz
))
1111 (with-standard-io-syntax (format nil
"~a" foo
))))
1115 (test-ps-js keyword-consistent
1119 (test-ps-js simple-symbol-macrolet
1120 (symbol-macrolet ((x 1)) x
)
1123 (test-ps-js compound-symbol-macrolet
1124 (symbol-macrolet ((x 123)
1129 (test-ps-js define-symbol-macro
1130 (progn (define-symbol-macro tst-sym-macro
2)
1134 (test-ps-js define-symbol-macro1
1135 (progn (define-symbol-macro tst-sym-macro1
2)
1136 (foo tst-sym-macro1
))
1139 (test-ps-js expression-progn
1140 (1+ (progn (foo) (if x
1 2)))
1141 "(foo(), x ? 1 : 2) + 1;")
1143 (test-ps-js let-decl-in-expression
1145 (if x
1 (let* ((foo x
)) foo
)))
1155 (test-ps-js special-var1
1156 (progn (defvar *foo
*)
1162 FOO_TMPSTACK1 = FOO;
1166 FOO = FOO_TMPSTACK1;
1169 (test-ps-js special-var2
1170 (progn (defvar *foo
*)
1178 FOO_TMPSTACK1 = FOO;
1182 FOO = FOO_TMPSTACK1;
1185 (test-ps-js literal1
1189 (test-ps-js literal2
1193 (test-ps-js setf-dec1
1197 (test-ps-js setf-dec2
1201 (test-ps-js special-char-equals
1205 (test-ps-js setf-operator-priority
1207 (or (getprop cache id
)
1208 (setf (getprop cache id
) ((@ document get-element-by-id
) id
))))
1210 return cache[id] || (cache[id] = document.getElementById(id));
1213 (test-ps-js aref-operator-priority
1214 (aref (if (and x
(> (length x
) 0))
1218 "(x && x.length > 0 ? x[0] : y)[z];")
1220 (test-ps-js aref-operator-priority1
1221 (aref (or (getprop x
'y
)
1226 (test-ps-js aref-operator-priority2
1230 (test-ps-js negate-operator-priority
1239 (delete (if a
(or b c
) d
))
1240 "delete (a ? b || c : d);")
1243 (not (if (or x
(not y
)) z
))
1244 "!(x || !y ? z : null);")
1251 (instanceof (or a b
) (if x y z
))
1252 "((a || b) instanceof (x ? y : z));")
1255 (or x
(if (= x
0) "zero" "empty"))
1256 "x || (x === 0 ? 'zero' : 'empty');")
1258 (test-ps-js named-op-expression
1262 (test-ps-js named-op-expression1
1266 (test-ps-js aref-array-expression
1268 "(a || b || c)[0];")
1270 (test-ps-js getprop-operator
1271 (getprop (or a b c
) 'd
)
1274 (test-ps-js getprop-parens
1275 (getprop (getprop foo
'bar
) 'baz
)
1278 (test-ps-js funcall-funcall
1282 (test-ps-js expression-funcall
1283 ((or (@ window eval
) eval
) foo nil
)
1284 "(window.eval || eval)(foo, null);")
1286 (test-ps-js expression-funcall1
1287 (((or (@ window eval
) eval
) foo nil
))
1288 "(window.eval || eval)(foo, null)();")
1290 (test-ps-js expression-funcall2
1291 (((or (@ window eval
) eval
)) foo nil
)
1292 "(window.eval || eval)()(foo, null);")
1294 (test-ps-js who-html1
1295 (who-ps-html (:span
:class
"ticker-symbol"
1296 :ticker-symbol symbol
1297 (:a
:href
"http://foo.com"
1299 (:span
:class
"ticker-symbol-popup")))
1300 "['<SPAN CLASS=\"ticker-symbol\" TICKER-SYMBOL=\"', symbol, '\"><A HREF=\"http://foo.com\">', symbol, '</A><SPAN CLASS=\"ticker-symbol-popup\"></SPAN></SPAN>']['join']('');")
1303 ((lambda () (flet ((foo (x)
1307 var foo = function (x) {
1314 (flet ((foo (x) (1+ x
))
1317 "var foo = function (x) {
1320 var bar = function (y) {
1326 (flet ((foo (x) (+ 2 x
)))
1327 (flet ((foo (x) (1+ x
))
1328 (bar (y) (+ 2 (foo y
))))
1330 "var foo = function (x) {
1333 var foo1 = function (x) {
1336 var bar = function (y) {
1342 ((lambda () (labels ((foo (x)
1345 (+ x
(foo (1- x
))))))
1348 var foo = function (x) {
1349 return 0 === x ? 0 : x + foo(x - 1);
1355 (labels ((foo (x) (1+ (bar x
)))
1356 (bar (y) (+ 2 (foo y
))))
1358 "var foo = function (x) {
1361 var bar = function (y) {
1367 (labels ((foo (x) (1+ x
))
1368 (bar (y) (+ 2 (foo y
))))
1370 "var foo = function (x) {
1373 var bar = function (y) {
1378 (test-ps-js labels-lambda-list
1379 (labels ((foo (x &optional
(y 0))
1382 "var foo = function (x, y) {
1383 if (y === undefined) {
1390 (test-ps-js for-loop-var-init-exp
1392 (do* ((y (if x
0 1) (1+ y
))
1397 return (function () {
1398 for (var y = x ? 0 : 1, z = 0; y !== 3; y += 1, z += 1) {
1408 (test-ps-js literal-array
1412 (test-ps-js literal-array-1
1416 (test ps-lisp-expands-in-lexical-environment
1417 (is (string= "5;" (let ((x 5)) (ps (lisp x
))))))
1419 (test ps
*-lisp-expands-in-null-lexical-environment
1420 (signals error
(let ((x 5)) (declare (ignore x
)) (ps* '(lisp x
)))))
1422 (test ps
*-lisp-expands-in-dynamic-environment
1423 (is (string= "1 + 2;" (let ((foo 2)) (declare (special foo
)) (ps* '(+ 1 (lisp (locally (declare (special foo
)) foo
))))))))
1425 (test ps-lisp-dynamic-environment
1426 (is (string= "1 + 2;" (let ((foo 2)) (declare (special foo
)) (ps (+ 1 (lisp foo
)))))))
1428 (test-ps-js nested-if-expressions1
1430 (return-from foo
(if (if x y z
) a b
)))
1432 return (x ? y : z) ? a : b;
1435 (test-ps-js nested-if-expressions2
1437 (if x y
(if z a b
)))
1502 (test-ps-js let-exp1
1545 (test-ps-js symbol-macrolet-var
1546 (symbol-macrolet ((x y
))
1550 (test-ps-js setf-conditional1
1551 (setf x
(unless (null a
) (1+ a
)))
1552 "x = a != null ? a + 1 : null;")
1554 (test-ps-js setf-let1
1555 (setf x
(let ((a 1)) a
))
1558 (test-ps-js setf-let2
1559 (setf x
(let ((a (foo)))
1562 "x = (a = foo(), a != null ? a + 1 : null);")
1564 (test-ps-js symbol-macro-env1
1565 (symbol-macrolet ((bar 1))
1566 (macrolet ((bar (x y
) `(+ ,x
,y
)))
1570 (test-ps-js symbol-macrolet-fun1
1571 (symbol-macrolet ((baz +))
1575 (test-ps-js lisp2-namespaces1
1577 (setf list
(list 1 2 3)))
1581 (test-ps-js let-shadows-symbol-macrolet
1582 (symbol-macrolet ((x y
))
1590 (test-ps-js let-rename-optimization1
1596 (test-ps-js let-rename-optimization2
1605 (test-ps-js symbol-macro-array
1606 (symbol-macrolet ((x 1))
1610 (test-ps-js symbol-macro-obj
1611 (symbol-macrolet ((x y
))
1615 (test-ps-js symbol-macro-conditional1
1616 (symbol-macrolet ((x y
))
1624 (test-ps-js symbol-macro-conditional2
1625 (symbol-macrolet ((x y
))
1629 (test-ps-js flet-apply
1630 (flet ((foo () 'bar
))
1631 (apply (function foo
) nil
))
1632 "var foo = function () {
1635 foo.apply(this, null);")
1637 (test-ps-js let-apply
1638 (let ((foo (lambda () 1)))
1639 (let ((foo (lambda () 2)))
1641 "var foo = function () {
1644 var foo1 = function () {
1647 foo1.apply(this, null);")
1649 (test-ps-js flet-let
1650 (flet ((x (x) (1+ x
)))
1653 "var x = function (x) {
1659 (test-ps-js let-flet
1661 (flet ((x (x) (1+ x
)))
1664 var x1 = function (x) {
1669 (test-ps-js labels-let
1670 (labels ((x (x) (1+ x
)))
1673 "var x = function (x) {
1679 (test-ps-js let-labels
1681 (labels ((x (x) (1+ x
)))
1684 var x1 = function (x) {
1689 (test-ps-js macrolet-let-inteference
1690 (macrolet ((a (n) `(+ ,n
5)))
1692 (let ((b (a (- a
4))))
1698 (test-ps-js let-subtract-add
1712 (test-ps-js create-reserved-word
1714 "{ 'default' : 1 };")
1716 (test-ps-js getprop-reserved-word
1717 (getprop foo
:default
)
1720 (test-ps-js getprop-reserved-word1
1721 (getprop foo
'default
)
1724 (test-ps-js eval-when-ps-side
1725 (eval-when (:execute
)
1729 (defvar *lisp-output
* nil
)
1731 (test eval-when-lisp-side
()
1732 (setf *lisp-output
* 'original-value
)
1733 (let ((js-output (normalize-js-code
1734 (ps-doc* `(eval-when (:compile-toplevel
)
1735 (setf *lisp-output
* 'it-works
))))))
1736 (is (eql 'it-works
*lisp-output
*))
1737 (is (string= "" js-output
))))
1739 (defpsmacro my-in-package
(package-name)
1740 `(eval-when (:compile-toplevel
)
1741 (setf *lisp-output
* ,package-name
)))
1743 (test eval-when-macro-expansion
()
1744 (setf *lisp-output
* 'original-value
)
1745 (let ((js-output (normalize-js-code
1747 (my-in-package :cl-user
)
1749 (declare (ignore js-output
))
1750 (is (eql :cl-user
*lisp-output
*))))
1752 (test eval-when-macrolet-expansion
()
1753 (setf *lisp-output
* 'original-value
)
1754 (let ((js-output (normalize-js-code
1755 (ps-doc* `(macrolet ((my-in-package2 (package-name)
1756 `(eval-when (:compile-toplevel
)
1757 (setf *lisp-output
* ,package-name
))))
1758 (my-in-package2 :cl-user
)
1760 (declare (ignore js-output
))
1761 (is (eql :cl-user
*lisp-output
*))))
1763 (test-ps-js getprop-keyword
1767 (test-ps-js nary-comparison1
1768 (lambda () (< 1 2 3))
1771 return (_cmp1 = 2, 1 < _cmp1 && _cmp1 < 3);
1774 (test-ps-js chain-getprop1
1775 (chain ($
"foo") (bar x z
) frob
(baz 5))
1776 "$('foo').bar(x, z).frob.baz(5);")
1778 (test-ps-js chain-getprop2
1779 (chain ($
"foo") bar baz
)
1780 "$('foo').bar.baz;")
1782 (test-ps-js chain-getprop3
1783 (chain ($
"foo") bar
(x y
) baz
)
1784 "$('foo').bar.x(y).baz;")
1786 (test-ps-js flet-expression
1787 (1+ (flet ((foo (x) (1+ x
)))
1789 "(foo = function (x) {
1793 (test-ps-js flet-lambda-list
1794 (labels ((foo (x &key
(y 0))
1797 "var foo = function (x) {
1798 var _js2 = arguments.length;
1799 for (var n1 = 1; n1 < _js2; n1 += 2) {
1800 switch (arguments[n1]) {
1802 y = arguments[n1 + 1];
1805 var y = undefined === y ? 0 : y;
1810 (test-ps-js return-case-break-elimination
1825 (test-ps-js aplusplus
1829 (test-ps-js astarstar
1833 (test-ps-js switch-return-fallthrough
1851 (test-ps-js return-last-case
1866 (test-ps-js return-macrolet
1869 (macrolet ((x () 1))
1882 (test-ps-js mv-bind1
1883 (multiple-value-bind (a b
)
1889 "var prevMv2 = null;
1891 prevMv2 = arguments['callee']['mv'];
1893 arguments['callee']['mv'] = true;
1895 var mv1 = typeof arguments['callee']['mv'] === 'object' ? arguments['callee']['mv'] : new Array(1);
1900 if (undefined === prevMv2) {
1901 delete arguments['callee']['mv'];
1903 arguments['callee']['mv'] = prevMv2;
1907 (test-ps-js mv-bind2
1908 (multiple-value-bind (a b
)
1914 "var prevMv2 = null;
1917 prevMv2 = arguments['callee']['mv'];
1919 arguments['callee']['mv'] = true;
1921 var mv1 = typeof arguments['callee']['mv'] === 'object' ? arguments['callee']['mv'] : new Array(1);
1926 if (undefined === prevMv2) {
1927 delete arguments['callee']['mv'];
1929 arguments['callee']['mv'] = prevMv2;
1933 (test-ps-js multiple-value-bind-simple
1934 (multiple-value-bind (a b
) (blah)
1936 "var prevMv2 = null;
1937 prevMv2 = arguments['callee']['mv'];
1939 arguments['callee']['mv'] = true;
1941 var mv1 = typeof arguments['callee']['mv'] === 'object' ? arguments['callee']['mv'] : new Array(1);
1945 if (undefined === prevMv2) {
1946 delete arguments['callee']['mv'];
1948 arguments['callee']['mv'] = prevMv2;
1953 (lambda () (values))
1966 if (undefined !== arguments['callee']['caller']['mv']) {
1967 arguments['callee']['caller']['mv'] = valrest2;
1974 var valrest2 = [y, z];
1975 if (undefined !== arguments['callee']['caller']['mv']) {
1976 arguments['callee']['caller']['mv'] = valrest2;
1980 (test-ps-js values-return
1982 (return-from foo
(values x y
)))
1986 if (undefined !== arguments['callee']['caller']['mv']) {
1987 arguments['callee']['caller']['mv'] = valrest2;
1992 (test-ps-js return-macrolet
1995 (symbol-macrolet ((x 2))
1996 (loop do
(+ x x
)))))
2004 (test-ps-js return-cond
2007 (cond ((foo? x
) (loop for y in x do
(foo y
)))
2012 var _js2 = x.length;
2026 } else if (barwhat(x)) {
2033 (test-ps-js switch-loop
2038 for (var a = null, _js_idx1 = 0; _js_idx1 < b.length; _js_idx1 += 1) {
2043 (test-ps-js switch-folds-blocks
2045 (1 (loop repeat
3 do
(alert "foo"))))
2048 for (var _js1 = 0; _js1 < 3; _js1 += 1) {
2053 (test-ps-js setf-places-before-macros
2055 (defsetf left
(el) (offset)
2056 `(setf (@ ,el style left
) ,offset
))
2057 (macrolet ((left (el)
2058 `(@ ,el offset-left
)))
2063 _js2.style.left = _js1;
2066 (test-ps-js for-return
2067 (lambda () (dolist (arg args
) (foo arg
)))
2069 for (var arg = null, _js_idx1 = 0; _js_idx1 < args.length; _js_idx1 += 1) {
2070 arg = args[_js_idx1];
2075 (test-ps-js try-catch-return
2093 (test-ps-js defun-setf-optional
2094 (defun (setf foo
) (new-value b
&optional c
)
2095 (setf (aref b
(or c
0)) new-value
))
2096 "function __setf_foo(newValue, b, c) {
2097 return b[c || 0] = newValue;
2100 (test-ps-js defun-setf-rest
2101 (progn (defun (setf foo
) (new-value b
&rest foo
)
2102 (do-something b foo new-value
))
2103 (setf (foo x
1 2 3 4) 5))
2104 "function __setf_foo(newValue, b) {
2106 for (var i1 = 0; i1 < arguments.length - 2; i1 += 1) {
2107 foo[i1] = arguments[i1 + 2];
2109 return doSomething(b, foo, newValue);
2111 __setf_foo(5, x, 1, 2, 3, 4);")
2113 (test-ps-js return-null
2114 (defun foo () (return-from foo nil
))
2119 (test-ps-js implicit-return-null
2126 (test-ps-js implicit-return-null
2133 (test-ps-js return-conditional-nested
2134 (defun blep (ss x y
)
2138 (destructuring-bind (a b
) pair
2139 (unless (or (null a
) (null b
))
2140 (let ((val (baz a b
)))
2145 "function blep(ss, x, y) {
2151 if (!(a == null || b == null)) {
2152 var val = baz(a, b);
2155 return !blee() ? true : null;
2163 ;; this test needs to be rewritten when named blocks are implemented!!!!
2164 (test-ps-js return-when-returns-broken-return
2166 (return-from foo
(when x
1))
2169 return x ? 1 : null;
2173 (test-ps-js return-case-conditional
2177 (123 (when (bar) t
))
2182 return bar() ? true : null;
2189 (test-ps-js return-try-conditional
2197 return x ? 1 : null;
2205 (test-ps-js function-declare-special
2207 (declare (special *foo
*))
2213 FOO_TMPSTACK1 = FOO;
2217 FOO = FOO_TMPSTACK1;
2221 (test-ps-js declare-special-let
2223 (declare (special *foo
*))
2227 FOO_TMPSTACK1 = FOO;
2231 FOO = FOO_TMPSTACK1;
2234 (test-ps-js macro-null-toplevel
2236 (defmacro macro-null-toplevel
()
2238 (macro-null-toplevel))
2241 (test-ps-js define-symbol-macro-let
2243 (define-symbol-macro test-symbol-macro
1)
2244 (let ((test-symbol-macro 2))
2245 (1+ test-symbol-macro
))
2246 (1+ test-symbol-macro
))
2247 "var testSymbolMacro1 = 2;
2248 testSymbolMacro1 + 1;
2251 (test-ps-js define-symbol-macro-flet
2253 (define-symbol-macro test-symbol-macro1
1)
2254 (flet ((test-symbol-macro1 () 2))
2255 (foo test-symbol-macro1
)
2256 (test-symbol-macro1))
2257 (bar test-symbol-macro1
))
2258 "var testSymbolMacro1_1 = function () {
2262 testSymbolMacro1_1();
2265 (test compile-stream-nulls
2268 (with-input-from-string (s "
2269 (defmacro macro-null-toplevel ()
2271 (macro-null-toplevel)")
2272 (ps-compile-stream s
)))))
2274 (test compile-stream1
2276 "var testSymbolMacro1_1 = function () {
2280 testSymbolMacro1_1();
2283 (with-input-from-string (s "
2284 (define-symbol-macro test-symbol-macro1 1)
2285 (flet ((test-symbol-macro1 () 2))
2286 (foo test-symbol-macro1)
2287 (test-symbol-macro1))
2288 (bar test-symbol-macro1)")
2289 (ps::with-blank-compilation-environment
(ps-compile-stream s
))))))
2291 (test-ps-js equality-nary1
2292 (let ((x 10) (y 10) (z 10))
2298 x === _cmp1 && _cmp1 === z;")
2300 (test-ps-js equality1
2311 (test-ps-js getprop-quote-reserved
2312 (getprop foo
':break
)
2315 (test-ps-js defun-block-return-from
2326 (test-ps-js block-return-from
2330 (return-from scope
))
2340 (test-ps-js let-funcall
2352 (test-ps-js symbol-macrolet-funcall
2353 (symbol-macrolet ((foo bar
))
2354 (funcall foo
1 2 3))
2357 (test-ps-js times-assign
2361 (test-ps-js vector-literal
2366 (+ 1 (rem 2 (+ 3 4)))
2369 (test-ps-js non-associative
2370 (+ (/ 1 (/ 2 3)) (- 1 (- 2 3)))
2371 "1 / (2 / 3) + 1 - (2 - 3);")
2373 (test-ps-js lambda-apply
2375 (apply (lambda (y) (bar (1+ y
))) x
))
2377 return (function (y) {
2382 (test-ps-js operator-expressions-nested-let
2383 (let ((x (let ((y 1))
2386 "var x = (y = 1, y); x;")
2388 (test-ps-js operator-expressions-array-nested-let
2389 (list (let ((y 1)) y
) 2)
2392 (test-ps-js add-subtract-precedence
2396 (test-ps-js ps-inline-toplevel
2398 "'javascript:' + 'foo()';")
2400 (test-ps-js no-clause-progn-exp
2404 (test-ps-js no-clause-progn-return
2406 (return-from foo
(progn)))
2411 (test-ps-js empty-cond-clause
2412 (setf x
(cond ((foo))))
2413 "x = foo() ? null : null;")
2415 (test-ps-js empty-cond-clause1
2416 (setf x
(cond ((foo) 123)
2419 "x = foo() ? 123 : (bar() ? null : 456);")
2421 (test-ps-js let-no-body
2423 (return-from foo
(let ((foo bar
)))))
2429 (test-ps-js dont-hoist-lexical-dupes
2431 (list (let ((foo 12)) (* foo
2))
2432 (let ((foo 13)) (* foo
3))))
2435 return [(foo = 12, foo * 2), (foo = 13, foo * 3)];
2438 (test-ps-js defun-comment1
2440 "BARBAR is a revolutionary new foobar.
2444 * BARBAR is a revolutionary new foobar.
2451 (test-ps-js var-comment
2456 (test-ps-js case-return-break-broken-return
2459 ("bar" (if y
(return-from foo t
) nil
))
2473 (test-ps-js case-return-break1-broken-return
2476 ("bar" (if y
(return-from foo t
)))
2490 (test-ps-js setf-progn
2491 (setf foo
(progn (bar) (baz) 3))
2496 ;; (test-ps-js var-progn
2497 ;; (var x (progn (foo) (bar)))
2501 (test-ps-js implicit-return-loop
2505 (loop :repeat
100 :do
(bar))
2511 for (var _js2 = 0; _js2 < 100; _js2 += 1) {
2518 ;; closures in loops need a new binding per loop iteration (idea borrowed from Scheme2JS)
2519 (test-ps-js loop-closures
2520 (dotimes (i 10) (lambda () (+ i
1)))
2521 "for (var i = 0; i < 10; i += 1) {
2529 (test-ps-js loop-closures-let
2530 (dotimes (i 10) (let ((x (+ i
1))) (lambda () (+ i x
))))
2531 "for (var i = 0; i < 10; i += 1) {
2532 with ({ x : null, i : i }) {
2540 (test-ps-js loop-closures-flet
2541 (dotimes (i 10) (flet ((foo (x) (+ i x
))) (lambda () (foo i
))))
2542 "for (var i = 0; i < 10; i += 1) {
2543 with ({ foo : null, i : i }) {
2544 var foo = function (x) {
2553 (test-ps-js while-closures-let
2556 (lambda () (+ 1 x
))))
2558 with ({ x : null }) {
2566 (test-ps-js dotted-list-form
2569 (destructuring-bind (b . c
)
2575 var c = bar.length > 1 ? bar.slice(1) : [];
2580 (test-ps-js return-from-loop
2581 (dolist (x '(2 1 3))
2584 (chain console
(log x
)))
2585 "for (var x = null, _js_arrvar2 = [2, 1, 3], _js_idx1 = 0; _js_idx1 < _js_arrvar2.length; _js_idx1 += 1) {
2586 x = _js_arrvar2[_js_idx1];
2593 (test-ps-js explicit-nil-block
2594 (block nil
(return) (+ 1 2))
2600 (test-ps-js dynamic-extent-function-return
2601 (defun foo () ((lambda () (return-from foo
))))
2604 return (function () {
2605 throw { 'ps-block-tag' : 'foo', 'ps-return-value' : null };
2608 if (err && 'foo' === err['ps-block-tag']) {
2609 err['ps-return-value'];
2616 (test-ps-js block-dynamic-return
2617 (block nil
((lambda () (return))) (+ 1 2))
2621 throw { 'ps-block-tag' : 'nilBlock', 'ps-return-value' : null };
2625 if (err && 'nilBlock' === err['ps-block-tag']) {
2626 err['ps-return-value'];
2633 (test-ps-js iteration-lambda-capture-no-need
2634 (dolist (x y
) (lambda (x) (1+ x
))) ;; there's really no need to create a 'with' scope in this case
2635 "for (var x = null, _js_idx1 = 0; _js_idx1 < y.length; _js_idx1 += 1) {
2644 (test-ps-js case-invert1
2645 (encodeURIComponent fooBar
)
2646 "encodeURIComponent(fooBar);")
2648 (test-ps-js simple-ash
2649 (+ (ash 4 1) (ash 4 -
1))
2650 "(4 << 1) + (4 >> 1);")
2652 (test-ps-js progn-nil-expression
2653 (bar (progn (foo) nil
))
2654 "bar((foo(), null));")
2656 (test-ps-js other-progn-nil-exp
2658 (or (foo) (progn (bar) nil
)))
2660 return foo() || (bar(), null);
2663 (test-ps-js lambda-nil-return
2676 (test-ps-js lambda-nil-return-implicit-nested
2688 for (var i = 0; i < 4; i += 1) {
2695 (test-ps-js throw-is-a-statement
2697 (let ((result (foo)))
2698 (unless (null result
)
2702 if (result != null) {
2707 (test-ps-js expressify1
2709 (when (some-condition)
2714 if (someCondition()) {
2721 (test-ps-js case-when-return
2724 ("a" (when (foo) (return-from blah
111)))
2738 (test-ps-js flet-return-from
2741 (return-from foo
123)))
2744 var foo = function () {
2750 (test-ps-js flet-return-from1
2752 (return-from foo
123)))
2754 "var foo = function () {
2759 (test-ps-js lambda-docstring-declarations
2761 "This is a docstring"
2762 (declare (ignore x
))
2768 (test-ps-js setf-let-exp
2769 (setf foo
(let ((x (+ 1 2)))
2771 "foo = (x = 1 + 2, x ? 123 : 456);")
2773 (test-ps-js create-let-exp
2774 (create :abc
(let ((x (+ 1 2)))
2776 "{ 'abc' : (x = 1 + 2, x ? 123 : 456) };")
2778 (test-ps-js eql-eql-eql-precedence
2779 (unless (equal (= 3 3) (= 3 4))
2780 (chain console
(log 1)))
2781 "if ((3 === 3) != (3 === 4)) {
2785 (test-ps-js case-cond-breaks
2788 (123 (cond ((foo1) (when (foo2)
2790 (return-from blah nil
))