Updated the reference and tests to reflect some small changes in the new printing...
authorVladimir Sedach <vsedach@gmail.com>
Wed, 15 Aug 2007 01:08:33 +0000 (01:08 +0000)
committerVladimir Sedach <vsedach@gmail.com>
Wed, 15 Aug 2007 01:08:33 +0000 (01:08 +0000)
...such as the current lack of line breaks and spaces before some
opening parens.

Also added a few new unit tests.

docs/reference.lisp
t/ps-tests.lisp
t/reference-tests.lisp

index c063d43..23d44cd 100644 (file)
@@ -222,7 +222,7 @@ an-object.foo => anObject.foo
 
 (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}
@@ -633,7 +633,7 @@ a-variable  => aVariable
 ;;; 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")
@@ -775,7 +775,7 @@ a-variable  => aVariable
   (2 (alert "two"))
   (t (alert "default clause")))
     => switch (blorg[i]) {
-         case 1:   ;
+         case 1:   
          case 'one':
                    alert('one');
                    break;
@@ -883,8 +883,7 @@ a-variable  => aVariable
 (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.
index 2ad1646..d5cf80d 100644 (file)
@@ -65,7 +65,7 @@ x = 2 + sideEffect() + x + 5;")
             "( 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))))
@@ -82,8 +82,7 @@ x = 2 + sideEffect() + x + 5;")
                                           :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.
@@ -147,7 +146,7 @@ x = 2 + sideEffect() + x + 5;")
       (3 (alert "Three"))
       (t (alert "Something else")))
    "switch (blorg[i]) {
-         case 1:   ;
+         case 1:
          case 2:
                    alert('Below three');
                    break;
@@ -261,7 +260,7 @@ x = 2 + sideEffect() + x + 5;")
 
 (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)
@@ -290,3 +289,19 @@ x = 2 + sideEffect() + x + 5;")
 (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
+  {}
+  "{ }")
index d2885cf..8c2cdb7 100644 (file)
 (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")
@@ -320,7 +320,7 @@ x = a + b + c;")
 
 (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)
@@ -399,7 +399,7 @@ x = a + b + c;")
   (2 (alert "two"))
   (t (alert "default clause")))
   "switch (blorg[i]) {
-  case 1:   ;
+  case 1:   
   case 'one':
             alert('one');
             break;
@@ -454,8 +454,7 @@ x = a + b + c;")
   (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)