Fixed problem with (- 1). Unary operator "-" didn't like number constants.
authorVladimir Sedach <vsedach@gmail.com>
Fri, 24 Aug 2007 20:16:51 +0000 (20:16 +0000)
committerVladimir Sedach <vsedach@gmail.com>
Fri, 24 Aug 2007 20:16:51 +0000 (20:16 +0000)
docs/reference.lisp
src/js-translation.lisp
t/ps-tests.lisp

index a1ee294..7237bbe 100644 (file)
@@ -971,7 +971,7 @@ a-variable  => aVariable
 ; (DEFPSMACRO name lambda-list macro-body)
 ; (MACROLET ({name lambda-list macro-body}*) body)
 ; (SYMBOL-MACROLET ({name macro-body}*) body)
-; (PS-GENSYM {string}?)
+; (PS-GENSYM {string})
 ;
 ; name        ::= a Lisp symbol
 ; lambda-list ::= a lambda list
index fa23621..2058dfe 100644 (file)
@@ -199,7 +199,7 @@ vice-versa.")
 (defprinter unary-operator (op arg &key prefix)
   (when prefix
     (write-string op))
-  (if (eql 'operator (car arg))
+  (if (and (listp arg) (eql 'operator (car arg)))
       (parenthesize-print arg)
       (ps-print arg))
   (unless prefix
index 3f36206..68a502b 100644 (file)
@@ -275,6 +275,14 @@ x = 2 + sideEffect() + x + 5;")
   (decf foo bar)
   "foo -= bar")
 
+(test-ps-js incf2
+  (incf x 5)
+  "x += 5")
+
+(test-ps-js decf2
+  (decf y 10)
+  "y -= 10")
+
 (test-ps-js setf-conditional
   (setf foo (if x 1 2))
   "foo = x ? 1 : 2;")
@@ -389,3 +397,7 @@ x = 2 + sideEffect() + x + 5;")
                  img))
        img))
   "document.write(LINKORNOT == 1 ? '<a href=\"#\" onclick=\"' + 'javascript:transport();' + '\">' + img + '</a>' : img)")
+
+(test-ps-js negate-number-literal ;; ok, this was broken and fixed before, but no one bothered to add the test!
+  (- 1)
+  "-1")