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 "bangwhathashatpercent")
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 regular-expression-literals-2
122 (test-ps-js literal-symbols-1
126 (test-ps-js literal-symbols-2
130 (test-ps-js literal-symbols-3
134 (test-ps-js literal-symbols-4
138 (test-ps-js literal-symbols-5
142 (test-ps-js variables-1
146 (test-ps-js variables-2
150 (test-ps-js variables-3
154 (test-ps-js variables-4
158 (test-ps-js function-calls-and-method-calls-1
162 (test-ps-js function-calls-and-method-calls-2
163 (foobar (blorg 1 2) (blabla 3 4) (array 2 3 4))
164 "foobar(blorg(1, 2), blabla(3, 4), [ 2, 3, 4 ])")
166 (test-ps-js function-calls-and-method-calls-3
170 (test-ps-js function-calls-and-method-calls-4
174 (test-ps-js function-calls-and-method-calls-5
178 (test-ps-js function-calls-and-method-calls-6
179 (.blorg
(aref foobar
1) NIL T
)
180 "foobar[1].blorg(null, true)")
182 (test-ps-js operator-expressions-1
186 (test-ps-js operator-expressions-2
190 (test-ps-js operator-expressions-3
194 (test-ps-js operator-expressions-5
195 (* 1 (+ 2 3 4) 4 (/ 6 7))
196 "1 * (2 + 3 + 4) * 4 * (6 / 7)")
198 (test-ps-js operator-expressions-6
202 (test-ps-js operator-expressions-7
206 (test-ps-js operator-expressions-8
210 (test-ps-js operator-expressions-9
214 (test-ps-js operator-expressions-10
218 (test-ps-js operator-expressions-11
222 (test-ps-js operator-expressions-12
226 (test-ps-js operator-expressions-13
230 (test-ps-js body-forms-1
231 (progn (blorg i
) (blafoo i
))
235 (test-ps-js body-forms-2
236 (+ i
(progn (blorg i
) (blafoo i
)))
237 "i + (blorg(i), blafoo(i))")
239 (test-ps-js function-definition-1
240 (defun a-function (a b
)
242 "function aFunction(a, b) {
246 (test-ps-js function-definition-2
247 (lambda (a b
) (return (+ a b
)))
252 (test-ps-js assignment-1
256 (test-ps-js assignment-2
257 (setf a
2 b
3 c
4 x
(+ a b c
))
263 (test-ps-js assignment-3
267 (test-ps-js assignment-4
268 (setf a
(* 2 3 4 a
4 a
))
269 "a *= 2 * 3 * 4 * 4 * a")
271 (test-ps-js assignment-5
275 (test-ps-js single-argument-statements-1
279 (test-ps-js single-argument-statements-2
283 (test-ps-js single-argument-expression-1
284 (delete (new (*foobar
2 3 4)))
285 "delete new Foobar(2, 3, 4)")
287 (test-ps-js single-argument-expression-2
288 (if (= (typeof blorg
) *string
)
289 (alert (+ "blorg is a string: " blorg
))
290 (alert "blorg is not a string"))
291 "if (typeof blorg == String) {
292 alert('blorg is a string: ' + blorg);
294 alert('blorg is not a string');
297 (test-ps-js conditional-statements-1
298 (if (blorg.is-correct
)
299 (progn (carry-on) (return i
))
300 (alert "blorg is not correct!"))
301 "if (blorg.isCorrect()) {
305 alert('blorg is not correct!');
308 (test-ps-js conditional-statements-2
309 (+ i
(if (blorg.add-one
) 1 2))
310 "i + (blorg.addOne() ? 1 : 2)")
312 (test-ps-js conditional-statements-3
313 (when (blorg.is-correct
)
316 "if (blorg.isCorrect()) {
321 (test-ps-js conditional-statements-4
322 (unless (blorg.is-correct
)
323 (alert "blorg is not correct!"))
324 "if (!blorg.isCorrect()) {
325 alert('blorg is not correct!');
328 (test-ps-js variable-declaration-1
329 (defvar *a
* (array 1 2 3))
330 "var A = [ 1, 2, 3 ];")
332 (test-ps-js variable-declaration-2
334 (progn (defvar blorg
"hallo")
336 (progn (defvar blorg
"blitzel")
342 var blorg = 'blitzel';
346 (test-ps-js variable-declaration-3
348 (let ((blorg "hallo"))
350 (let ((blorg "blitzel"))
356 var blorg = 'blitzel';
360 (test-ps-js iteration-constructs-1
362 (l (aref blorg i
) (aref blorg i
)))
363 ((or (= i blorg.length
)
364 (eql l
"Fumitastic")))
365 (document.write
(+ "L is " l
)))
366 "for (var i = 0, l = blorg[i];
367 !(i == blorg.length || l == 'Fumitastic');
368 i = i + 1, l = blorg[i]) {
369 document.write('L is ' + l);
372 (test-ps-js iteration-constructs-2
373 (dotimes (i blorg.length
)
374 (document.write
(+ "L is " (aref blorg i
))))
375 "for (var i = 0; i < blorg.length; i = i + 1) {
376 document.write('L is ' + blorg[i]);
379 (test-ps-js iteration-constructs-3
381 (document.write
(+ "L is " l
)))
384 for (var tmpI2 = 0; tmpI2 < tmpArr1.length;
386 var l = tmpArr1[tmpI2];
387 document.write('L is ' + l);
391 (test-ps-js iteration-constructs-4
393 (document.write
(+ i
" is " (aref object i
))))
394 "for (var i in object) {
395 document.write(i + ' is ' + object[i]);
398 (test-ps-js iteration-constructs-5
399 (while (film.is-not-finished
)
400 (this.eat
(new *popcorn
)))
401 "while (film.isNotFinished()) {
402 this.eat(new Popcorn);
405 (test-ps-js the-case-statement-1
407 ((1 "one") (alert "one"))
409 (t (alert "default clause")))
418 default: alert('default clause');
421 (test-ps-js the-case-statement-2
422 (switch (aref blorg i
)
423 (1 (alert "If I get here"))
424 (2 (alert "I also get here"))
425 (default (alert "I always get here")))
427 case 1: alert('If I get here');
428 case 2: alert('I also get here');
429 default: alert('I always get here');
432 (test-ps-js the-with-statement-1
433 (with (create :foo
"foo" :i
"i")
434 (alert (+ "i is now intermediary scoped: " i
)))
435 "with ({ foo : 'foo',
437 alert('i is now intermediary scoped: ' + i);
440 (test-ps-js the-try-statement-1
443 (alert (+ "an error happened: " error
)))
445 (alert "Leaving the try form")))
449 alert('an error happened: ' + error);
451 alert('Leaving the try form');
454 (test-ps-js the-html-generator-1
455 (html ((:a
:href
"foobar") "blorg"))
456 "'<a href=\"foobar\">blorg</a>'")
458 (test-ps-js the-html-generator-2
459 (html ((:a
:href
(generate-a-link)) "blorg"))
460 "'<a href=\"' + generateALink() + '\">blorg</a>'")
462 (test-ps-js the-html-generator-3
465 :onclick
(js-inline (transport))) "link")))
467 ('<a href=\"#\" onclick=\"' + 'javascript:transport();' + '\">link</a>')")
469 (test-ps-js the-html-generator-4
470 (css-inline :color
"red"
471 :font-size
"x-small")
472 "'color:red;font-size:x-small'")
474 (test-ps-js the-html-generator-5
475 (defun make-color-div(color-name)
476 (return (html ((:div
:style
(css-inline :color color-name
))
477 color-name
" looks like this."))))
478 "function makeColorDiv(colorName) {
479 return '<div style=\"' + ('color:' + colorName) + '\">' + colorName
480 + ' looks like this.</div>';