(with-slots (a b c) this
(+ a b c))
- => (this).a + (this).b + (this).c;
+ => this.a + this.b + this.c;
;;;## Regular Expression literals
;;;t \index{REGEX}
;;; Lisp. The `DEFVAR' is converted to "var ... = ..." form in
;;; JavaScript.
-(defvar *a* (array 1 2 3)) => var A = [ 1, 2, 3 ];
+(defvar *a* (array 1 2 3)) => var A = [ 1, 2, 3 ]
(if (= i 1)
(progn (defvar blorg "hallo")
(2 (alert "two"))
(t (alert "default clause")))
=> switch (blorg[i]) {
- case 1: ;
+ case 1:
case 'one':
alert('one');
break;
(document.write
(html ((:a :href "#"
:onclick (ps-inline (transport))) "link")))
- => document.write
- ('<a href=\"#\" onclick=\"' + 'javascript:transport();' + '\">link</a>')
+ => document.write('<a href=\"#\" onclick=\"' + 'javascript:transport();' + '\">link</a>')
;;; Forms may be used in attribute lists to conditionally generate
;;; the next attribute. In this example the textarea is sometimes disabled.
"( function () { alert(10); } ).toString()")
(test-ps-js method-call-lambda-call
(.to-string ((lambda (x) (return x)) 10))
- "(function (x) { return x; }) (10).toString()")
+ "(function (x) { return x; })(10).toString()")
(test no-whitespace-before-dot
(let* ((str (compile-script '(.to-string ((lambda (x) (return x)) 10))))
:font-size "x-small"
:height (* 2 200)
:width (* 2 300))))))
- "alert
-('<div id=\"777\" style=\"'
+ "alert('<div id=\"777\" style=\"'
+ ('border:1pxsssssssssss;font-size:x-small;height:' + 2 * 200 + ';width:'
+ 2 * 300)
+ '\"></div>')") ;";This line should start with a plus character.
(3 (alert "Three"))
(t (alert "Something else")))
"switch (blorg[i]) {
- case 1: ;
+ case 1:
case 2:
alert('Below three');
break;
(test-ps-js set-timeout
(do-set-timeout (10) (alert "foo"))
- "setTimeout (function () { alert('foo'); }, 10)")
+ "setTimeout(function () { alert('foo'); }, 10)")
(test-ps-js operator-precedence
(* 3 (+ 4 5) 6)
(test-ps-js slot-value-string
(slot-value foo "bar")
"foo['bar']")
+
+(test-ps-js slot-value-progn
+ (slot-value (progn "abc" "123") "length")
+ "('abc', '123')['length']")
+
+(test-ps-js method-call-block
+ (.to-string (progn "abc" "123"))
+ "('abc', '123').toString()")
+
+(test-ps-js create-blank
+ (create)
+ "{ }")
+
+(test-ps-js blank-object-literal
+ {}
+ "{ }")
(test-ps-js object-literals-5
(with-slots (a b c) this
(+ a b c))
- "(this).a + (this).b + (this).c;")
+ "this.a + this.b + this.c;")
(test-ps-js regular-expression-literals-1
(regex "foobar")
(test-ps-js variable-declaration-1
(defvar *a* (array 1 2 3))
- "var A = [ 1, 2, 3 ];")
+ "var A = [ 1, 2, 3 ]")
(test-ps-js variable-declaration-2
(if (= i 1)
(2 (alert "two"))
(t (alert "default clause")))
"switch (blorg[i]) {
- case 1: ;
+ case 1:
case 'one':
alert('one');
break;
(document.write
(html ((:a :href "#"
:onclick (ps-inline (transport))) "link")))
- "document.write
-('<a href=\"#\" onclick=\"' + 'javascript:transport();' + '\">link</a>')")
+ "document.write('<a href=\"#\" onclick=\"' + 'javascript:transport();' + '\">link</a>')")
(test-ps-js the-html-generator-4
(let ((disabled nil)