1 (in-package "PARENSCRIPT-TEST")
5 (test-ps-js plus-is-not-commutative
6 (setf x
(+ "before" x
"after"))
7 "x = 'before' + x + 'after';")
9 (test-ps-js plus-works-if-first
10 (setf x
(+ x
"middle" "after"))
11 "x += 'middle' + 'after';")
13 (test-ps-js setf-side-effects
19 (setf x
(+ 2 (side-effect) x
5))))
21 function sideEffect() {
25 x = 2 + sideEffect() + x + 5;")
27 (test-ps-js method-call-op-form
28 ((@ (+ "" x
) to-string
))
29 "('' + x).toString();")
31 (test-ps-js method-call-op-form-args
32 ((@ (+ "" x
) to-string
) 1 2 :baz
3)
33 "('' + x).toString(1, 2, 'baz', 3);")
35 (test-ps-js method-call-number
39 (test-ps-js method-call-string
43 (test-ps-js method-call-lit-object
44 ((@ (create to-string
(lambda () (return "it works"))) to-string
))
45 "( { toString : function () { return 'it works'; } } ).toString();")
47 (test-ps-js method-call-conditional
51 (test-ps-js method-call-variable
55 (test-ps-js method-call-array
56 ((@ (list 10 20) to-string
))
57 "[ 10, 20 ].toString();")
59 (test-ps-js method-call-fn-call
63 (test-ps-js method-call-lambda-fn
64 ((@ (lambda () (alert 10)) to-string
))
65 "( function () { return alert(10); } ).toString();")
67 (test-ps-js method-call-lambda-call
68 ((@ ((lambda (x) (return x
)) 10) to-string
))
69 "(function (x) { return x; })(10).toString();")
71 (test no-whitespace-before-dot
72 (let* ((str (ps* '((@ ((lambda (x) (return x
)) 10) to-string
))))
73 (dot-pos (position #\. str
:test
#'char
=))
74 (char-before (elt str
(1- dot-pos
)))
76 (is (char= char-before a-parenthesis
))))
78 (test-ps-js simple-getprop
79 (let ((foo (create a
1)))
80 (alert (getprop foo
'a
)))
84 (test-ps-js buggy-getprop
85 (let ((foo (create a
1))
87 (alert (getprop foo slot-name
)))
88 " var foo = { a : 1 };
91 "); Last line was alert(foo.slotName) before bug-fix.
93 (test-ps-js buggy-getprop-two
94 (getprop foo
(get-slot-name))
95 "foo[getSlotName()];")
97 (test-ps-js old-case-is-now-switch
98 ;; Switch was "case" before, but that was very non-lispish.
99 ;; For example, this code makes three messages and not one
100 ;; which may have been expected. This is because a switch
101 ;; statment must have a break statement for it to return
102 ;; after the alert. Otherwise it continues on the next
104 (switch (aref blorg i
)
107 (default (alert "default clause")))
109 case 1: alert('one');
110 case 2: alert('two');
111 default: alert('default clause');
114 (test-ps-js lisp-like-case
118 (default (alert "default clause")))
126 default: alert('default clause');
130 (test-ps-js even-lispier-case
132 ((1 2) (alert "Below three"))
134 (t (alert "Something else")))
138 alert('Below three');
143 default: alert('Something else');
146 (test-ps-js otherwise-case
149 (otherwise (alert "default clause")))
154 default: alert('default clause');
157 (test escape-sequences-in-string
158 (let ((escapes `((#\\ .
#\\)
160 (#\f .
,(code-char 12))
161 ("u000B" .
,(code-char #x000b
));;Vertical tab, too uncommon to bother with
164 (#\' .
#\');;Double quote need not be quoted because parenscript strings are single quoted
166 ("u001F" .
,(code-char #x001f
));; character below 32
167 ("u0080" .
,(code-char 128)) ;;Character over 127. Actually valid, parenscript escapes them to be sure.
168 ("uABCD" .
,(code-char #xabcd
)))));; Really above ascii.
169 (loop for
(js-escape . lisp-char
) in escapes
170 for generated
= (ps-doc* `(let ((x ,(format nil
"hello~ahi" lisp-char
)))))
171 for wanted
= (format nil
"var x = 'hello\\~ahi';" js-escape
)
172 do
(is (string= (normalize-js-code generated
) wanted
)))))
174 (test-ps-js getprop-setf
175 (setf (getprop x
'y
) (+ (+ a
3) 4))
176 "x.y = (a + 3) + 4;")
178 (test-ps-js getprop-conditional1
179 (getprop (if zoo foo bar
) 'x
)
180 "(zoo ? foo : bar).x;")
182 (test-ps-js getprop-conditional2
183 (getprop (if (not zoo
) foo bar
) 'x
)
184 "(!zoo ? foo : bar).x;")
186 (test script-star-eval1
187 (is (string= "x = 1; y = 2;" (normalize-js-code (ps* '(setf x
1) '(setf y
2))))))
189 (test script-star-eval2
190 (is (string= "x = 1;" (normalize-js-code (ps* '(setf x
1))))))
192 (test-ps-js unquoted-nil
196 (test-ps-js list-with-single-nil
200 (test-ps-js quoted-nil-is-array
205 (progn (defsetf baz
(x y
) (newval) `(set-baz ,x
,y
,newval
))
210 setBaz(_js2, _js3, _js1);")
212 (test-ps-js setf-macroexpands1
213 (macrolet ((bar (x y
)
215 (setf (bar foo
2) 3))
218 (test-ps-js defsetf-short
219 (progn (defsetf baz set-baz
"docstring")
220 (setf (baz 1 2 3) "foo"))
221 "setBaz(1, 2, 3, 'foo');")
223 (test-ps-js defun-setf1
224 (progn (defun (setf some-thing
) (new-val i1 i2
)
225 (setf (aref *some-thing
* i1 i2
) new-val
))
226 (setf (some-thing 1 2) "foo"))
227 "function __setf_someThing(newVal, i1, i2) {
228 return SOMETHING[i1][i2] = newVal;
230 __setf_someThing('foo', 1, 2);")
232 (test-ps-js defun-optional1
233 (defun test-opt (&optional x
)
235 "function testOpt(x) {
236 if (x === undefined) {
246 (test-ps-js defun-optional2
247 (defun foo (x &optional y
)
249 "function foo(x, y) {
250 if (y === undefined) {
256 (test-ps-js defun-optional3
257 (defun blah (&optional
(x 0))
260 if (x === undefined) {
266 (test-ps-js return-nothing
270 (test-ps-js set-timeout
271 (do-set-timeout (10) (alert "foo"))
272 "setTimeout(function () { return alert('foo'); }, 10);")
274 (test-ps-js operator-precedence
278 (test-ps-js operators-1
298 (test-ps-js setf-conditional
299 (setf foo
(if x
1 2))
302 (test-ps-js obj-literal-numbers
306 (test-ps-js obj-literal-strings
310 (test-ps-js getprop-string
314 (test-ps-js getprop-string1
315 (getprop "bar" 'length
)
318 (test-ps-js getprop-progn
319 (getprop (progn (some-fun "abc") "123") "length")
320 "(someFun('abc'), '123')['length'];")
322 (test-ps-js method-call-block
323 ((@ (progn (some-fun "abc") "123") to-string
))
324 "(someFun('abc'), '123').toString();")
326 (test-ps-js create-blank
330 (test-ps-js blank-object-literal
334 (test-ps-js array-literal1
338 (test-ps-js array-literal2
342 (test-ps-js array-literal3
346 (test-ps-js array-literal4
350 (test-ps-js array-literal5
352 "[[1, 2], ['a', 'b']];")
354 (test-ps-js defun-rest1
355 (defun foo (&rest bar
)
356 (alert (aref bar
1)))
359 for (var i1 = 0; i1 < arguments.length - 0; i1 += 1) {
360 bar[i1] = arguments[i1 + 0];
362 return alert(bar[1]);
365 (test-ps-js defun-rest2
366 (defun foo (baz &rest bar
) (return (+ baz
(aref bar
1))))
369 for (var i1 = 0; i1 < arguments.length - 1; i1 += 1) {
370 bar[i1] = arguments[i1 + 1];
375 (test-ps-js defun-keyword1
376 (defun zoo (foo bar
&key baz
) (return (+ foo bar baz
)))
377 "function zoo(foo, bar) {
379 var _js2 = arguments.length;
380 for (var n1 = 2; n1 < _js2; n1 += 2) {
381 switch (arguments[n1]) {
383 baz = arguments[n1 + 1];
386 if (baz === undefined) {
389 return foo + bar + baz;
392 (test-ps-js defun-keyword2
393 (defun zoo (&key baz
) (return (* baz baz
)))
396 var _js2 = arguments.length;
397 for (var n1 = 0; n1 < _js2; n1 += 2) {
398 switch (arguments[n1]) {
400 baz = arguments[n1 + 1];
403 if (baz === undefined) {
409 (test-ps-js defun-keyword3
410 (defun zoo (&key baz
(bar 4)) (return (* baz bar
)))
414 var _js2 = arguments.length;
415 for (var n1 = 0; n1 < _js2; n1 += 2) {
416 switch (arguments[n1]) {
418 baz = arguments[n1 + 1];
421 bar = arguments[n1 + 1];
424 if (baz === undefined) {
427 if (bar === undefined) {
433 (test-ps-js defun-keyword4
434 (defun hello-world (&key
((:my-name-key my-name
) 1))
436 "function helloWorld() {
438 var _js2 = arguments.length;
439 for (var n1 = 0; n1 < _js2; n1 += 2) {
440 switch (arguments[n1]) {
442 myName = arguments[n1 + 1];
445 if (myName === undefined) {
451 (test-ps-js keyword-funcall1
455 (test-ps-js keyword-funcall2
456 (func :baz
1 :bar foo
)
457 "func('baz', 1, 'bar', foo);")
459 (test-ps-js keyword-funcall3
461 "fun(a, b, 'baz', c);")
471 ((= y
(* x
4)) (foo "blah") (* x y
)))
474 } else if (y == x * 4) {
479 (test-ps-js if-exp-without-else-returns-null
487 (test-ps-js progn-expression-single-statement
488 (return (progn (* x y
)))
491 (test-ps-js cond-expression1
493 (cond ((< 1 2) (bar "foo") (* 4 5))))
501 (test-ps-js cond-expression2
503 (cond ((< 2 1) "foo")
513 (test-ps-js cond-expression-final-t-clause
515 (cond ((< 1 2) (bar "foo") (* 4 5))
528 } else if ((_cmp1 = 2, _cmp2 = 3, _cmp3 = 4, 1 < _cmp1 && _cmp1 < _cmp2 && _cmp2 < _cmp3 && _cmp3 < 5)) {
535 (test-ps-js cond-expression-middle-t-clause
;; should this signal a warning?
548 (test-ps-js funcall-if-expression
550 (if (= *linkornot
* 1)
551 (ps-html ((:a
:href
"#"
552 :onclick
(ps-inline (transport)))
555 "document.write(LINKORNOT == 1 ? '<A HREF=\"#\" ONCLICK=\"' + ('javascript:' + 'transport()') + '\">' + img + '</A>' : img);")
557 (test-ps-js negate-number-literal
561 (test macro-environment1
562 (is (string= (normalize-js-code (let* ((macroname (gensym)))
563 (ps* `(defmacro ,macroname
(x) `(+ ,x
123))
565 (macrolet ((,macroname
(x) `(aref data
,x
)))
567 (setf (,macroname x
) 123)))))))
571 return data[x] = 123;
577 (test macro-environment2
578 (is (string= (normalize-js-code (let ((outer-lexical-variable 1))
579 (defpsmacro macro-environment2-macro
(x)
580 `(+ ,outer-lexical-variable
,x
))
581 (ps* '(macro-environment2-macro 2))))
582 (normalize-js-code "1 + 2;"))))
584 (test-ps-js ampersand-whole-1
585 (macrolet ((foo (&whole foo bar baz
)
586 (declare (ignore bar baz
))
587 (format nil
"~a" foo
)))
591 (test-ps-js keyword-consistent
595 (test-ps-js simple-symbol-macrolet
596 (symbol-macrolet ((x 1)) x
)
599 (test-ps-js compound-symbol-macrolet
600 (symbol-macrolet ((x 123)
605 (test-ps-js define-symbol-macro
606 (progn (define-symbol-macro tst-sym-macro
2)
610 (test-ps-js define-symbol-macro1
611 (progn (define-symbol-macro tst-sym-macro1
2)
612 (foo tst-sym-macro1
))
615 (test-ps-js expression-progn
616 (1+ (progn (foo) (if x
1 2)))
617 "(foo(), x ? 1 : 2) + 1;")
619 (test-ps-js let-decl-in-expression
621 (if x
1 (let* ((foo x
))
632 (test-ps-js special-var1
633 (progn (defvar *foo
*)
646 (test-ps-js special-var2
647 (progn (defvar *foo
*)
670 (test-ps-js setf-dec1
674 (test-ps-js setf-dec2
678 (test-ps-js special-char-equals
682 (test-ps-js setf-operator-priority
683 (return (or (getprop cache id
)
684 (setf (getprop cache id
) ((@ document get-element-by-id
) id
))))
685 "return cache[id] || (cache[id] = document.getElementById(id));")
687 (test-ps-js aref-operator-priority
688 (aref (if (and x
(> (length x
) 0))
692 "(x && x.length > 0 ? x[0] : y)[z];")
694 (test-ps-js aref-operator-priority1
695 (aref (or (getprop x
'y
)
700 (test-ps-js aref-operator-priority2
704 (test-ps-js negative-operator-priority
713 (delete (if a
(or b c
) d
))
714 "delete (a ? b || c : d);")
717 (not (if (or x
(not y
)) z
))
718 "!(x || !y ? z : null);")
725 (instanceof (or a b
) (if x y z
))
726 "((a || b) instanceof (x ? y : z));")
729 (or x
(if (= x
0) "zero" "empty"))
730 "x || (x == 0 ? 'zero' : 'empty');")
732 (test-ps-js named-op-expression
736 (test-ps-js named-op-expression1
740 (test-ps-js aref-array-expression
744 (test-ps-js getprop-operator
745 (getprop (or a b c
) 'd
)
748 (test-ps-js getprop-parens
749 (getprop (getprop foo
'bar
) 'baz
)
752 (test-ps-js funcall-funcall
756 (test-ps-js expression-funcall
757 ((or (@ window eval
) eval
) foo nil
)
758 "(window.eval || eval)(foo, null);")
760 (test-ps-js expression-funcall1
761 (((or (@ window eval
) eval
) foo nil
))
762 "(window.eval || eval)(foo, null)();")
764 (test-ps-js expression-funcall2
765 (((or (@ window eval
) eval
)) foo nil
)
766 "(window.eval || eval)()(foo, null);")
768 (test-ps-js getprop-object-literal
769 (getprop (create a
1) 'a
)
772 (test-ps-js getprop-lambda
773 (getprop (lambda ()) 'prototype
)
774 "(function () { return null; }).prototype;")
776 (test-ps-js who-html1
777 (who-ps-html (:span
:class
"ticker-symbol"
778 :ticker-symbol symbol
779 (:a
:href
"http://foo.com"
781 (:span
:class
"ticker-symbol-popup")))
782 "'<SPAN CLASS=\"ticker-symbol\" TICKER-SYMBOL=\"' + symbol + '\"><A HREF=\"http://foo.com\">' + symbol + '</A><SPAN CLASS=\"ticker-symbol-popup\"></SPAN></SPAN>';")
785 ((lambda () (flet ((foo (x)
789 var foo1 = function (x) {
796 (flet ((foo (x) (return (1+ x
)))
797 (bar (y) (return (+ 2 y
))))
799 "var foo1 = function (x) {
802 var bar2 = function (y) {
808 (flet ((foo (x) (return (1+ x
)))
809 (bar (y) (return (+ 2 (foo y
)))))
811 "var foo1 = function (x) {
814 var bar2 = function (y) {
820 ((lambda () (labels ((foo (x)
823 (+ x
(foo (1- x
))))))
826 var foo1 = function (x) {
830 return x + foo1(x - 1);
837 (labels ((foo (x) (return (1+ (bar x
))))
838 (bar (y) (return (+ 2 (foo y
)))))
840 "var foo1 = function (x) {
843 var bar2 = function (y) {
849 (labels ((foo (x) (return (1+ x
)))
850 (bar (y) (return (+ 2 (foo y
)))))
852 "var foo1 = function (x) {
855 var bar2 = function (y) {
860 (test-ps-js for-loop-var-init-exp
862 (return (do* ((y (if x
0 1) (1+ y
))
867 return (function () {
868 for (var y = x ? 0 : 1, z = 0; y != 3; y += 1, z += 1) {
878 (test-ps-js literal-array
882 (test-ps-js literal-array-1
886 (test ps-lisp-expands-in-lexical-environment
887 (is (string= "5;" (let ((x 5)) (ps (lisp x
))))))
889 (test ps
*-lisp-expands-in-null-lexical-environment
890 (signals error
(let ((x 5)) (declare (ignore x
)) (ps* '(lisp x
)))))
892 (test ps
*-lisp-expands-in-dynamic-environment
893 (is (string= "1 + 2;" (let ((*print-level
* 2)) (ps* '(+ 1 (lisp *print-level
*)))))))
895 (test ps-lisp-dynamic-environment
896 (is (string= "1 + 2;" (let ((*print-level
* 2)) (ps (+ 1 (lisp *print-level
*)))))))
898 (test-ps-js ps-js-target-version-keyword-test1
899 (defun foo (x y
&key bar baz
))
900 "function foo(x, y) {
902 var x1 = Array.prototype.indexOf.call(arguments, 'bar', 2);
903 var bar = -1 == x1 ? null : arguments[x1 + 1];
904 var x2 = Array.prototype.indexOf.call(arguments, 'baz', 2);
905 return baz = -1 == x2 ? null : arguments[x2 + 1];
907 :js-target-version
1.6)
909 (test-ps-js nested-if-expressions1
910 (return (if (if x y z
) a b
))
917 (test-ps-js nested-if-expressions2
918 (return (if x y
(if z a b
)))
1028 (test-ps-js symbol-macrolet-var
1029 (symbol-macrolet ((x y
))
1033 (test-ps-js setf-conditional1
1034 (setf x
(unless (null a
) (1+ a
)))
1035 "x = a != null ? a + 1 : null;")
1037 (test-ps-js setf-let1
1038 (setf x
(let ((a 1)) a
))
1041 (test-ps-js setf-let2
1042 (setf x
(let ((a (foo)))
1045 "x = (a = foo(), a != null ? a + 1 : null);")
1047 (test-ps-js symbol-macro-env1
1048 (symbol-macrolet ((bar 1))
1049 (macrolet ((bar (x y
) `(+ ,x
,y
)))
1053 (test-ps-js symbol-macrolet-fun1
1054 (symbol-macrolet ((baz +))
1058 (test-ps-js lisp2-namespaces1
1060 (setf list
(list 1 2 3)))
1064 (test-ps-js let-shadows-symbol-macrolet
1065 (symbol-macrolet ((x y
))
1073 (test-ps-js let-rename-optimization1
1079 (test-ps-js let-rename-optimization2
1088 (test-ps-js symbol-macro-array
1089 (symbol-macrolet ((x 1))
1093 (test-ps-js symbol-macro-obj
1094 (symbol-macrolet ((x y
))
1098 (test-ps-js symbol-macro-conditional1
1099 (symbol-macrolet ((x y
))
1107 (test-ps-js symbol-macro-conditional2
1108 (symbol-macrolet ((x y
))
1109 (return (if x x x
)))
1116 (test-ps-js flet-apply
1117 (flet ((foo () 'bar
))
1118 (apply (function foo
) nil
))
1119 "var foo1 = function () {
1122 foo1.apply(this, null);")
1124 (test-ps-js let-apply
1125 (let ((foo (lambda () (return 1))))
1126 (let ((foo (lambda () (return 2))))
1128 "var foo = function () {
1131 var foo1 = function () {
1134 foo1.apply(this, null);")
1136 (test-ps-js flet-let
1137 (flet ((x (x) (return (1+ x
))))
1140 "var x1 = function (x) {
1146 (test-ps-js let-flet
1148 (flet ((x (x) (return (1+ x
))))
1151 var x1 = function (x) {
1156 (test-ps-js macrolet-let-inteference
1157 (macrolet ((a (n) `(+ ,n
5)))
1159 (let ((b (a (- a
4))))
1162 var b = (a - 4) + 5;
1165 (test-ps-js let-subtract-add
1179 (test-ps-js create-reserved-word
1181 "{ 'default' : 1 };")
1183 (test-ps-js getprop-reserved-word
1184 (getprop foo
:default
)
1187 (test-ps-js eval-when-ps-side
1188 (eval-when (:execute
)
1192 (defvar *lisp-output
* nil
)
1194 (test eval-when-lisp-side
()
1195 (setf *lisp-output
* 'original-value
)
1196 (let ((js-output (normalize-js-code
1197 (ps-doc* `(eval-when (:compile-toplevel
)
1198 (setf *lisp-output
* 'it-works
))))))
1199 (is (eql 'it-works
*lisp-output
*))
1200 (is (string= "" js-output
))))
1202 (defpsmacro my-in-package
(package-name)
1203 `(eval-when (:compile-toplevel
)
1204 (setf *lisp-output
* ,package-name
)))
1206 (test eval-when-macro-expansion
()
1207 (setf *lisp-output
* 'original-value
)
1208 (let ((js-output (normalize-js-code
1210 (my-in-package :cl-user
)
1212 (declare (ignore js-output
))
1213 (is (eql :cl-user
*lisp-output
*))))
1215 (test eval-when-macrolet-expansion
()
1216 (setf *lisp-output
* 'original-value
)
1217 (let ((js-output (normalize-js-code
1218 (ps-doc* `(macrolet ((my-in-package2 (package-name)
1219 `(eval-when (:compile-toplevel
)
1220 (setf *lisp-output
* ,package-name
))))
1221 (my-in-package2 :cl-user
)
1223 (declare (ignore js-output
))
1224 (is (eql :cl-user
*lisp-output
*))))
1226 (test-ps-js getprop-keyword
1230 (test-ps-js nary-comparison1
1231 (lambda () (return (< 1 2 3)))
1234 return (_cmp1 = 2, 1 < _cmp1 && _cmp1 < 3);
1237 (test-ps-js chain-getprop1
1238 (chain ($
"foo") (bar x z
) frob
(baz 5))
1239 "$('foo').bar(x, z).frob.baz(5);")
1241 (test-ps-js chain-getprop2
1242 (chain ($
"foo") bar baz
)
1243 "$('foo').bar.baz;")
1245 (test-ps-js chain-getprop3
1246 (chain ($
"foo") bar
(x y
) baz
)
1247 "$('foo').bar.x(y).baz;")
1249 (test-ps-js flet-expression
1250 (1+ (flet ((foo (x) (1+ x
)))
1252 "(foo1 = function (x) {
1256 (test-ps-js return-case-break-elimination
1267 (test-ps-js aplusplus
1271 (test-ps-js astarstar
1275 (test-ps-js switch-return-fallthrough
1290 (test-ps-js return-last-case
1302 (test-ps-js return-macrolet
1304 (macrolet ((x () 1))
1315 (test-ps-js mv-bind1
1316 (multiple-value-bind (a b
)
1323 var prevmv2 = arguments['callee']['mv'];
1325 arguments['callee']['mv'] = true;
1327 var mv1 = typeof arguments['callee']['mv'] == 'object' ? arguments['callee']['mv'] : new Array(1);
1332 if (undefined === prevmv2) {
1333 delete arguments['callee']['mv'];
1335 arguments['callee']['mv'] = prevmv2;
1351 if (undefined !== arguments['callee']['caller']['mv']) {
1352 arguments['callee']['caller']['mv'] = valrest2;
1359 var valrest2 = [y, z];
1360 if (undefined !== arguments['callee']['caller']['mv']) {
1361 arguments['callee']['caller']['mv'] = valrest2;
1365 (test-ps-js values-return
1366 (return (values x y
))
1369 if (undefined !== arguments['callee']['caller']['mv']) {
1370 arguments['callee']['caller']['mv'] = valrest2;
1374 (test-ps-js return-macrolet
1376 (symbol-macrolet ((x 2))
1383 (test-ps-js return-cond
1385 (cond ((foo? x
) (loop for y in x do
(foo y
)))
1389 var _js2 = x.length;
1403 } else if (barwhat(x)) {
1409 (test-ps-js switch-loop
1414 for (var a = null, _js_idx1 = 0; _js_idx1 < b.length; _js_idx1 += 1) {
1419 (test-ps-js switch-folds-blocks
1421 (1 (loop repeat
3 do
(alert "foo"))))
1424 for (var _js1 = 0; _js1 < 3; _js1 += 1) {
1430 (test-ps-js setf-places-before-macros
1432 (defsetf left
(el) (offset)
1433 `(setf (@ ,el style left
) ,offset
))
1434 (macrolet ((left (el)
1435 `(@ ,el offset-left
)))
1440 _js2.style.left = _js1;
1443 (test-ps-js for-return
1444 (return (dolist (arg args
) (foo arg
)))
1445 "for (var arg = null, _js_idx1 = 0; _js_idx1 < args.length; _js_idx1 += 1) {
1446 arg = args[_js_idx1];
1450 (test-ps-js try-catch-return
1464 (test-ps-js defun-setf-optional
1465 (defun (setf foo
) (new-value b
&optional c
)
1466 (setf (aref b
(or c
0)) new-value
))
1467 "function __setf_foo(newValue, b, c) {
1468 if (c === undefined) {
1471 return b[c || 0] = newValue;
1474 (test-ps-js defun-setf-rest
1475 (progn (defun (setf foo
) (new-value b
&rest foo
)
1476 (do-something b foo new-value
))
1477 (setf (foo x
1 2 3 4) 5))
1478 "function __setf_foo(newValue, b) {
1480 for (var i1 = 0; i1 < arguments.length - 2; i1 += 1) {
1481 foo[i1] = arguments[i1 + 2];
1483 return doSomething(b, foo, newValue);
1485 __setf_foo(5, x, 1, 2, 3, 4);")