Skip to content

Add support for break statements #15

Merged
merged 1 commit into from Sep 7, 2011
View
5 src/com/reasonr/scriptjure.clj
@@ -80,7 +80,7 @@
(defmethod emit :default [expr]
(str expr))
-(def special-forms (set ['var '. '.. 'if 'funcall 'fn 'quote 'set! 'return 'delete 'new 'do 'aget 'while 'doseq 'str 'inc! 'dec! 'dec 'inc 'defined? 'and 'or '? 'try]))
+(def special-forms (set ['var '. '.. 'if 'funcall 'fn 'quote 'set! 'return 'delete 'new 'do 'aget 'while 'doseq 'str 'inc! 'dec! 'dec 'inc 'defined? 'and 'or '? 'try 'break]))
(def prefix-unary-operators (set ['!]))
@@ -282,6 +282,9 @@
(emit-do finally-body)
"}\n"))))))
+(defmethod emit-special 'break [type [break]]
+ (statement "break"))
+
(declare emit-custom custom-form?)
(derive clojure.lang.Cons ::list)
View
4 test/test_scriptjure.clj
@@ -220,4 +220,8 @@
(finally (print "bar")))))
"Cannot supply more than one finally clause")))
+(deftest test-break
+ (is (= (strip-whitespace (js (break)))
+ "break;")))
+
(run-tests)
Something went wrong with that request. Please try again.