Permalink
Browse files

Allow vars to be declared without specifying a value

  • Loading branch information...
1 parent 185f4ff commit 798ccaa70898a60099b63ad5276ea4aa3739c47a @arohner committed Oct 29, 2010
Showing with 2 additions and 2 deletions.
  1. +1 −1 project.clj
  2. +0 −1 src/com/reasonr/scriptjure.clj
  3. +1 −0 test/test_scriptjure.clj
View
@@ -1,4 +1,4 @@
-(defproject scriptjure "0.1.18"
+(defproject scriptjure "0.1.19"
:description "a clojure DSL for generating javascript"
:url "http://github.com/arohner/scriptjure"
:dependencies [[org.clojure/clojure "1.2.0"]
@@ -121,7 +121,6 @@
~@body))
(defmethod emit-special 'var [type [var & more]]
- (assert (even? (count more)))
(apply swap! var-declarations conj (filter identity (map (fn [name i] (when (odd? i) name)) more (iterate inc 1))))
(apply str (interleave (map (fn [[name expr]]
(str (when-not var-declarations "var ") (emit name) " = " (emit expr)))
View
@@ -16,6 +16,7 @@
(is (= "/^abc/" (js #"^abc"))))
(deftest test-var-expr
+ (is (= (strip-whitespace (js (var x)))) "var x;")
(is (= (strip-whitespace (js (var x 42))) "var x; x = 42;"))
(is (= (strip-whitespace (js (var x 1 y 2))) (strip-whitespace "var x, y; x = 1; y = 2;"))))

0 comments on commit 798ccaa

Please sign in to comment.