Skip to content

Commit

Permalink
Allow vars to be declared without specifying a value
Browse files Browse the repository at this point in the history
  • Loading branch information
arohner committed Oct 29, 2010
1 parent 185f4ff commit 798ccaa
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion project.clj
@@ -1,4 +1,4 @@
(defproject scriptjure "0.1.18" (defproject scriptjure "0.1.19"
:description "a clojure DSL for generating javascript" :description "a clojure DSL for generating javascript"
:url "http://github.com/arohner/scriptjure" :url "http://github.com/arohner/scriptjure"
:dependencies [[org.clojure/clojure "1.2.0"] :dependencies [[org.clojure/clojure "1.2.0"]
Expand Down
1 change: 0 additions & 1 deletion src/com/reasonr/scriptjure.clj
Expand Up @@ -121,7 +121,6 @@
~@body)) ~@body))


(defmethod emit-special 'var [type [var & more]] (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 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]] (apply str (interleave (map (fn [[name expr]]
(str (when-not var-declarations "var ") (emit name) " = " (emit expr))) (str (when-not var-declarations "var ") (emit name) " = " (emit expr)))
Expand Down
1 change: 1 addition & 0 deletions test/test_scriptjure.clj
Expand Up @@ -16,6 +16,7 @@
(is (= "/^abc/" (js #"^abc")))) (is (= "/^abc/" (js #"^abc"))))


(deftest test-var-expr (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 42))) "var x; x = 42;"))
(is (= (strip-whitespace (js (var x 1 y 2))) (strip-whitespace "var x, y; x = 1; y = 2;")))) (is (= (strip-whitespace (js (var x 1 y 2))) (strip-whitespace "var x, y; x = 1; y = 2;"))))


Expand Down

0 comments on commit 798ccaa

Please sign in to comment.