Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix a bug emitting keywords. Fix a bug with the unary operators

  • Loading branch information...
commit e0c3d3f73ae6b1ec1e937d1ed7f154ddc8aa4f08 1 parent e44a360
@arohner authored
View
2  project.clj
@@ -1,4 +1,4 @@
-(defproject scriptjure "0.1.14"
+(defproject scriptjure "0.1.15"
:description "a clojure DSL for generating javascript"
:url "http://github.com/arohner/scriptjure"
:dependencies [[org.clojure/clojure "1.2.0"]
View
6 src/com/reasonr/scriptjure.clj
@@ -63,7 +63,7 @@
(boolean (re-matches #"[_$\p{Alpha}][.\w]*" (str sym))))
(defmethod emit clojure.lang.Keyword [expr]
- (when-not (valid-symbol? (str expr))
+ (when-not (valid-symbol? (name expr))
(throwf "%s is not a valid javascript symbol" expr))
(str (name expr)))
@@ -211,8 +211,8 @@
(not (= (cstr/get (str head) 1) \.))) (emit-special 'dot-method expr)
(special-form? head) (emit-special head expr)
(infix-operator? head) (emit-infix head expr)
- (prefix-unary? head) (emit-prefix-unary expr)
- (suffix-unary? head) (emit-suffix-unary expr)
+ (prefix-unary? head) (emit-prefix-unary head expr)
+ (suffix-unary? head) (emit-suffix-unary head expr)
:else (emit-special 'funcall expr)))
(throw (new Exception (str "invalid form: " expr)))))
View
5 test/test_scriptjure.clj
@@ -19,8 +19,13 @@
(is (= (strip-whitespace (js (var x 42))) "var x = 42;")))
(deftest test-invalid-variables-throw
+ (is (= (js valid_symbol)) "valid_symbol")
(is (thrown? Exception (js (var invalid-symbol 42)))))
+(deftest test-valid-keyword
+ (is (= (js :foo)) "foo")
+ (is (thrown? Exception (js :invalid-symbol))))
+
(deftest test-simple-funcall
(is (= (js (a b)) "a(b)")))
Please sign in to comment.
Something went wrong with that request. Please try again.