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.
9 (test-ps-js statements-and-expressions-1
13 (test-ps-js statements-and-expressions-2
21 (test-ps-js symbol-conversion-1
23 "bangwhathashdollaratpercent")
25 (test-ps-js symbol-conversion-2
29 (test-ps-js symbol-conversion-3
33 (test-ps-js symbol-conversion-6
37 (test-ps-js symbol-conversion-7
41 (test-ps-js number-literals-1
45 (test-ps-js number-literals-2
49 (test-ps-js number-literals-3
53 (test-ps-js string-literals-1
57 (test-ps-js string-literals-2
61 (test-ps-js array-literals-1
65 (test-ps-js array-literals-2
69 (test-ps-js array-literals-3
71 (array "foobar" "bratzel bub"))
72 "[ [ 2, 3 ], [ 'foobar', 'bratzel bub' ] ]")
74 (test-ps-js array-literals-4
78 (test-ps-js array-literals-5
82 (test-ps-js array-literals-6
85 (make-array "foobar" "bratzel bub"))
86 "new Array(new Array(2, 3), new Array('foobar', 'bratzel bub'))")
88 (test-ps-js object-literals-1
89 (create :foo
"bar" :blorg
1)
93 (test-ps-js object-literals-2
96 :another-object
(create :schtrunz
1))
99 anotherObject : { schtrunz : 1 } }")
101 (test-ps-js object-literals-3
102 (slot-value an-object
'foo
)
105 (test-ps-js object-literals-4
109 (test-ps-js object-literals-5
110 (with-slots (a b c
) this
112 "this.a + this.b + this.c;")
114 (test-ps-js regular-expression-literals-1
118 (test-ps-js literal-symbols-1
122 (test-ps-js literal-symbols-2
126 (test-ps-js literal-symbols-3
130 (test-ps-js literal-symbols-4
134 (test-ps-js literal-symbols-5
138 (test-ps-js variables-1
142 (test-ps-js variables-2
146 (test-ps-js variables-3
150 (test-ps-js variables-4
154 (test-ps-js function-calls-and-method-calls-1
158 (test-ps-js function-calls-and-method-calls-2
159 (foobar (blorg 1 2) (blabla 3 4) (array 2 3 4))
160 "foobar(blorg(1, 2), blabla(3, 4), [ 2, 3, 4 ])")
162 (test-ps-js function-calls-and-method-calls-3
166 (test-ps-js function-calls-and-method-calls-4
170 (test-ps-js function-calls-and-method-calls-5
174 (test-ps-js function-calls-and-method-calls-6
175 (.blorg
(aref foobar
1) NIL T
)
176 "foobar[1].blorg(null, true)")
178 (test-ps-js operator-expressions-1
182 (test-ps-js operator-expressions-2
186 (test-ps-js operator-expressions-3
190 (test-ps-js operator-expressions-5
191 (* 1 (+ 2 3 4) 4 (/ 6 7))
192 "1 * (2 + 3 + 4) * 4 * (6 / 7)")
194 (test-ps-js operator-expressions-6
198 (test-ps-js operator-expressions-7
202 (test-ps-js operator-expressions-8
206 (test-ps-js operator-expressions-9
210 (test-ps-js operator-expressions-10
214 (test-ps-js operator-expressions-11
218 (test-ps-js operator-expressions-12
222 (test-ps-js operator-expressions-13
226 (test-ps-js body-forms-1
227 (progn (blorg i
) (blafoo i
))
231 (test-ps-js body-forms-2
232 (+ i
(progn (blorg i
) (blafoo i
)))
233 "i + (blorg(i), blafoo(i))")
235 (test-ps-js function-definition-1
236 (defun a-function (a b
)
238 "function aFunction(a, b) {
242 (test-ps-js function-definition-2
243 (lambda (a b
) (return (+ a b
)))
248 (test-ps-js assignment-1
252 (test-ps-js assignment-2
253 (setf a
2 b
3 c
4 x
(+ a b c
))
259 (test-ps-js assignment-3
263 (test-ps-js assignment-4
264 (setf a
(* 2 3 4 a
4 a
))
265 "a *= 2 * 3 * 4 * 4 * a")
267 (test-ps-js assignment-5
271 (test-ps-js single-argument-statements-1
275 (test-ps-js single-argument-statements-2
279 (test-ps-js single-argument-expression-1
280 (delete (new (*foobar
2 3 4)))
281 "delete new Foobar(2, 3, 4)")
283 (test-ps-js single-argument-expression-2
284 (if (= (typeof blorg
) *string
)
285 (alert (+ "blorg is a string: " blorg
))
286 (alert "blorg is not a string"))
287 "if (typeof blorg == String) {
288 alert('blorg is a string: ' + blorg);
290 alert('blorg is not a string');
293 (test-ps-js conditional-statements-1
294 (if (blorg.is-correct
)
295 (progn (carry-on) (return i
))
296 (alert "blorg is not correct!"))
297 "if (blorg.isCorrect()) {
301 alert('blorg is not correct!');
304 (test-ps-js conditional-statements-2
305 (+ i
(if (blorg.add-one
) 1 2))
306 "i + (blorg.addOne() ? 1 : 2)")
308 (test-ps-js conditional-statements-3
309 (when (blorg.is-correct
)
312 "if (blorg.isCorrect()) {
317 (test-ps-js conditional-statements-4
318 (unless (blorg.is-correct
)
319 (alert "blorg is not correct!"))
320 "if (!blorg.isCorrect()) {
321 alert('blorg is not correct!');
324 (test-ps-js variable-declaration-1
325 (defvar *a
* (array 1 2 3))
326 "var A = [ 1, 2, 3 ];")
328 (test-ps-js variable-declaration-2
330 (progn (defvar blorg
"hallo")
332 (progn (defvar blorg
"blitzel")
338 var blorg = 'blitzel';
342 (test-ps-js variable-declaration-3
344 (let ((blorg "hallo"))
346 (let ((blorg "blitzel"))
352 var blorg = 'blitzel';
356 (test-ps-js iteration-constructs-1
358 (l (aref blorg i
) (aref blorg i
)))
359 ((or (= i blorg.length
)
360 (eql l
"Fumitastic")))
361 (document.write
(+ "L is " l
)))
362 "for (var i = 0, l = blorg[i];
363 !(i == blorg.length || l == 'Fumitastic');
364 i = i + 1, l = blorg[i]) {
365 document.write('L is ' + l);
368 (test-ps-js iteration-constructs-2
369 (dotimes (i blorg.length
)
370 (document.write
(+ "L is " (aref blorg i
))))
371 "for (var i = 0; i < blorg.length; i = i + 1) {
372 document.write('L is ' + blorg[i]);
375 (test-ps-js iteration-constructs-3
377 (document.write
(+ "L is " l
)))
380 for (var tmpI2 = 0; tmpI2 < tmpArr1.length;
382 var l = tmpArr1[tmpI2];
383 document.write('L is ' + l);
387 (test-ps-js iteration-constructs-4
389 (document.write
(+ i
" is " (aref object i
))))
390 "for (var i in object) {
391 document.write(i + ' is ' + object[i]);
394 (test-ps-js iteration-constructs-5
395 (while (film.is-not-finished
)
396 (this.eat
(new *popcorn
)))
397 "while (film.isNotFinished()) {
398 this.eat(new Popcorn);
401 (test-ps-js the-case-statement-1
403 ((1 "one") (alert "one"))
405 (t (alert "default clause")))
414 default: alert('default clause');
417 (test-ps-js the-case-statement-2
418 (switch (aref blorg i
)
419 (1 (alert "If I get here"))
420 (2 (alert "I also get here"))
421 (default (alert "I always get here")))
423 case 1: alert('If I get here');
424 case 2: alert('I also get here');
425 default: alert('I always get here');
428 (test-ps-js the-with-statement-1
429 (with ((create :foo
"foo" :i
"i"))
430 (alert (+ "i is now intermediary scoped: " i
)))
431 "with ({ foo : 'foo',
433 alert('i is now intermediary scoped: ' + i);
436 (test-ps-js the-try-statement-1
439 (alert (+ "an error happened: " error
)))
441 (alert "Leaving the try form")))
445 alert('an error happened: ' + error);
447 alert('Leaving the try form');
450 (test-ps-js the-html-generator-1
451 (html ((:a
:href
"foobar") "blorg"))
452 "'<a href=\"foobar\">blorg</a>'")
454 (test-ps-js the-html-generator-2
455 (html ((:a
:href
(generate-a-link)) "blorg"))
456 "'<a href=\"' + generateALink() + '\">blorg</a>'")
458 (test-ps-js the-html-generator-3
461 :onclick
(js-inline (transport))) "link")))
463 ('<a href=\"#\" onclick=\"' + 'javascript:transport();' + '\">link</a>')")
465 (test-ps-js the-html-generator-4
466 (css-inline :color
"red"
467 :font-size
"x-small")
468 "'color:red;font-size:x-small'")
470 (test-ps-js the-html-generator-5
471 (defun make-color-div(color-name)
472 (return (html ((:div
:style
(css-inline :color color-name
))
473 color-name
" looks like this."))))
474 "function makeColorDiv(colorName) {
475 return '<div style=\"' + ('color:' + colorName) + '\">' + colorName
476 + ' looks like this.</div>';