2 ;; Tests of everything in the reference.
3 ;; File is generated automatically from the text in reference.lisp by
4 ;; the function make-reference-tests-dot-lisp in ref2test.lisp
5 ;; so do not edit this file.
6 (eval-when (:compile-toplevel
:load-toplevel
:execute
)
10 (test-ps-js statements-and-expressions-1
14 (test-ps-js statements-and-expressions-2
22 (test-ps-js symbol-conversion-1
24 "bangwhathashatpercent")
26 (test-ps-js symbol-conversion-2
30 (test-ps-js symbol-conversion-3
34 (test-ps-js symbol-conversion-6
38 (test-ps-js symbol-conversion-7
42 (test-ps-js number-literals-1
46 (test-ps-js number-literals-2
50 (test-ps-js number-literals-3
54 (test-ps-js string-literals-1
58 (test-ps-js string-literals-2
62 (test-ps-js array-literals-1
66 (test-ps-js array-literals-2
70 (test-ps-js array-literals-3
72 (array "foobar" "bratzel bub"))
73 "[ [ 2, 3 ], [ 'foobar', 'bratzel bub' ] ]")
75 (test-ps-js array-literals-4
79 (test-ps-js array-literals-5
83 (test-ps-js array-literals-6
86 (make-array "foobar" "bratzel bub"))
87 "new Array(new Array(2, 3), new Array('foobar', 'bratzel bub'))")
89 (test-ps-js object-literals-1
90 (create :foo
"bar" :blorg
1)
94 (test-ps-js object-literals-2
97 :another-object
(create :schtrunz
1))
100 anotherObject : { schtrunz : 1 } }")
102 (test-ps-js object-literals-3
103 (slot-value an-object
'foo
)
106 (test-ps-js object-literals-4
110 (test-ps-js object-literals-5
111 (with-slots (a b c
) this
113 "(this).a + (this).b + (this).c;")
115 (test-ps-js regular-expression-literals-1
119 (test-ps-js regular-expression-literals-2
123 (test-ps-js literal-symbols-1
127 (test-ps-js literal-symbols-2
131 (test-ps-js literal-symbols-3
135 (test-ps-js literal-symbols-4
139 (test-ps-js literal-symbols-5
143 (test-ps-js variables-1
147 (test-ps-js variables-2
151 (test-ps-js variables-3
155 (test-ps-js variables-4
159 (test-ps-js function-calls-and-method-calls-1
163 (test-ps-js function-calls-and-method-calls-2
164 (foobar (blorg 1 2) (blabla 3 4) (array 2 3 4))
165 "foobar(blorg(1, 2), blabla(3, 4), [ 2, 3, 4 ])")
167 (test-ps-js function-calls-and-method-calls-3
171 (test-ps-js function-calls-and-method-calls-4
175 (test-ps-js function-calls-and-method-calls-5
179 (test-ps-js function-calls-and-method-calls-6
180 (.blorg
(aref foobar
1) NIL T
)
181 "foobar[1].blorg(null, true)")
183 (test-ps-js operator-expressions-1
187 (test-ps-js operator-expressions-2
191 (test-ps-js operator-expressions-3
195 (test-ps-js operator-expressions-5
196 (* 1 (+ 2 3 4) 4 (/ 6 7))
197 "1 * (2 + 3 + 4) * 4 * (6 / 7)")
199 (test-ps-js operator-expressions-6
203 (test-ps-js operator-expressions-7
207 (test-ps-js operator-expressions-8
211 (test-ps-js operator-expressions-9
215 (test-ps-js operator-expressions-10
219 (test-ps-js operator-expressions-11
223 (test-ps-js operator-expressions-12
227 (test-ps-js operator-expressions-13
231 (test-ps-js body-forms-1
232 (progn (blorg i
) (blafoo i
))
236 (test-ps-js body-forms-2
237 (+ i
(progn (blorg i
) (blafoo i
)))
238 "i + (blorg(i), blafoo(i))")
240 (test-ps-js function-definition-1
241 (defun a-function (a b
)
243 "function aFunction(a, b) {
247 (test-ps-js function-definition-2
248 (lambda (a b
) (return (+ a b
)))
253 (test-ps-js assignment-1
257 (test-ps-js assignment-2
258 (setf a
2 b
3 c
4 x
(+ a b c
))
264 (test-ps-js assignment-3
268 (test-ps-js assignment-4
269 (setf a
(+ a
2 3 4 a
))
270 "a += 2 + 3 + 4 + a")
272 (test-ps-js assignment-5
276 (test-ps-js single-argument-statements-1
280 (test-ps-js single-argument-statements-2
284 (test-ps-js single-argument-expression-1
285 (delete (new (*foobar
2 3 4)))
286 "delete new Foobar(2, 3, 4)")
288 (test-ps-js single-argument-expression-2
289 (if (= (typeof blorg
) *string
)
290 (alert (+ "blorg is a string: " blorg
))
291 (alert "blorg is not a string"))
292 "if (typeof blorg == String) {
293 alert('blorg is a string: ' + blorg);
295 alert('blorg is not a string');
298 (test-ps-js conditional-statements-1
299 (if (blorg.is-correct
)
300 (progn (carry-on) (return i
))
301 (alert "blorg is not correct!"))
302 "if (blorg.isCorrect()) {
306 alert('blorg is not correct!');
309 (test-ps-js conditional-statements-2
310 (+ i
(if (blorg.add-one
) 1 2))
311 "i + (blorg.addOne() ? 1 : 2)")
313 (test-ps-js conditional-statements-3
314 (when (blorg.is-correct
)
317 "if (blorg.isCorrect()) {
322 (test-ps-js conditional-statements-4
323 (unless (blorg.is-correct
)
324 (alert "blorg is not correct!"))
325 "if (!blorg.isCorrect()) {
326 alert('blorg is not correct!');
329 (test-ps-js variable-declaration-1
330 (defvar *a
* (array 1 2 3))
331 "var A = [ 1, 2, 3 ];")
333 (test-ps-js variable-declaration-2
335 (progn (defvar blorg
"hallo")
337 (progn (defvar blorg
"blitzel")
343 var blorg = 'blitzel';
347 (test-ps-js variable-declaration-3
349 (let ((blorg "hallo"))
351 (let ((blorg "blitzel"))
357 var blorg = 'blitzel';
361 (test-ps-js iteration-constructs-1
363 (l (aref blorg i
) (aref blorg i
)))
364 ((or (= i blorg.length
)
365 (eql l
"Fumitastic")))
366 (document.write
(+ "L is " l
)))
367 "for (var i = 0, l = blorg[i];
368 !(i == blorg.length || l == 'Fumitastic');
369 i = i + 1, l = blorg[i]) {
370 document.write('L is ' + l);
373 (test-ps-js iteration-constructs-2
374 (dotimes (i blorg.length
)
375 (document.write
(+ "L is " (aref blorg i
))))
376 "for (var i = 0; i < blorg.length; i = i + 1) {
377 document.write('L is ' + blorg[i]);
380 (test-ps-js iteration-constructs-3
382 (document.write
(+ "L is " l
)))
385 for (var tmpI2 = 0; tmpI2 < tmpArr1.length;
387 var l = tmpArr1[tmpI2];
388 document.write('L is ' + l);
392 (test-ps-js iteration-constructs-4
394 (document.write
(+ i
" is " (aref object i
))))
395 "for (var i in object) {
396 document.write(i + ' is ' + object[i]);
399 (test-ps-js iteration-constructs-5
400 (while (film.is-not-finished
)
401 (this.eat
(new *popcorn
)))
402 "while (film.isNotFinished()) {
403 this.eat(new Popcorn);
406 (test-ps-js the-case-statement-1
408 ((1 "one") (alert "one"))
410 (t (alert "default clause")))
419 default: alert('default clause');
422 (test-ps-js the-case-statement-2
423 (switch (aref blorg i
)
424 (1 (alert "If I get here"))
425 (2 (alert "I also get here"))
426 (default (alert "I always get here")))
428 case 1: alert('If I get here');
429 case 2: alert('I also get here');
430 default: alert('I always get here');
433 (test-ps-js the-with-statement-1
434 (with (create :foo
"foo" :i
"i")
435 (alert (+ "i is now intermediary scoped: " i
)))
436 "with ({ foo : 'foo',
438 alert('i is now intermediary scoped: ' + i);
441 (test-ps-js the-try-statement-1
444 (alert (+ "an error happened: " error
)))
446 (alert "Leaving the try form")))
450 alert('an error happened: ' + error);
452 alert('Leaving the try form');
455 (test-ps-js the-html-generator-1
456 (html ((:a
:href
"foobar") "blorg"))
457 "'<a href=\"foobar\">blorg</a>'")
459 (test-ps-js the-html-generator-2
460 (html ((:a
:href
(generate-a-link)) "blorg"))
461 "'<a href=\"' + generateALink() + '\">blorg</a>'")
463 (test-ps-js the-html-generator-3
466 :onclick
(js-inline (transport))) "link")))
468 ('<a href=\"#\" onclick=\"' + 'javascript:transport();' + '\">link</a>')")
470 (test-ps-js the-html-generator-4
473 (setf element.inner-h-t-m-l
474 (html ((:textarea
(or disabled
(not authorized
)) :disabled
"disabled")
478 var authorized = true;
481 + (disabled || !authorized ? ' disabled=\"' + 'disabled' + '\"' : '')
482 + '>Edit me</textarea>';
485 (test-ps-js the-html-generator-5
486 (css-inline :color
"red"
487 :font-size
"x-small")
488 "'color:red;font-size:x-small'")
490 (test-ps-js the-html-generator-6
491 (defun make-color-div(color-name)
492 (return (html ((:div
:style
(css-inline :color color-name
))
493 color-name
" looks like this."))))
494 "function makeColorDiv(colorName) {
495 return '<div style=\"' + ('color:' + colorName) + '\">' + colorName
496 + ' looks like this.</div>';