Permalink
Browse files

Fix a bug where the unary operators weren't emitting their arguments

  • Loading branch information...
1 parent e0c3d3f commit 1d8c086eac7eaea09aac35dac0ddd553cd0882b6 @arohner committed Sep 13, 2010
Showing with 6 additions and 4 deletions.
  1. +1 −1 project.clj
  2. +2 −2 src/com/reasonr/scriptjure.clj
  3. +3 −1 test/test_scriptjure.clj
View
@@ -1,4 +1,4 @@
-(defproject scriptjure "0.1.15"
+(defproject scriptjure "0.1.16"
:description "a clojure DSL for generating javascript"
:url "http://github.com/arohner/scriptjure"
:dependencies [[org.clojure/clojure "1.2.0"]
@@ -101,10 +101,10 @@
(contains? suffix-unary-operators expr))
(defn emit-prefix-unary [type [operator arg]]
- (str operator arg))
+ (str operator (emit arg)))
(defn emit-suffix-unary [type [operator arg]]
- (str arg operator))
+ (str (emit arg) operator))
(defn emit-infix [type [operator & args]]
(when (< (count args) 2)
View
@@ -39,10 +39,12 @@
(is (= (js (+ x y z a b c)) "(x + y + z + a + b + c)")))
(deftest test-prefix-unary
- (is (= (js (! x) "!x"))))
+ (is (= (js (! x) "!x")))
+ (is (= (js (! (+ x 1))) "!(x + 1)")))
(deftest test-suffix-unary
(is (= (js (++ x) "x++")))
+ (is (= (js (++ (+ x 1)) "(x + 1)++")))
(is (= (js (-- x) "x--"))))
(deftest test-return

0 comments on commit 1d8c086

Please sign in to comment.