Skip to content
Browse files

Added tests for calling literal functions (anonymous and named), tern…

…ary if

(?), dec, inc, and set!.
  • Loading branch information...
1 parent 4910383 commit 104628cd6fec8feae650821e9080be2f4599c563 @scottjad scottjad committed Sep 16, 2010
Showing with 24 additions and 0 deletions.
  1. +24 −0 test/test_scriptjure.clj
View
24 test/test_scriptjure.clj
@@ -135,4 +135,28 @@
(let [foo (fn [] (+ 1 2))]
(is (= (cljs* foo) (js* (clj foo))))))
+(deftest test-literal-fn-call
+ (is (= (strip-whitespace (js ((fn [x] (return x)) 1)))
+ "(function (x) { return x; })(1)"))
+ (is (= (strip-whitespace (js ((fn foo [x] (return x)) 1)))
+ "var foo; (foo = function (x) { return x; })(1)")))
+
+(deftest test-ternary-if
+ (is (= (strip-whitespace (js (? (= 1 2) 3 4)))
+ "(1 === 2) ? 3 : 4")))
+
+(deftest test-dec
+ (is (= (strip-whitespace(js (dec x)))
+ "(x - 1)")))
+
+(deftest test-inc
+ (is (= (strip-whitespace(js (inc x)))
+ "(x + 1)")))
+
+(deftest test-set!
+ (is (= (strip-whitespace (js (set! x 1)))
+ "x = 1;"))
+ (is (= (strip-whitespace(js (set! x 1 y 2)))
+ "x = 1; y = 2;")))
+
(run-tests)

0 comments on commit 104628c

Please sign in to comment.
Something went wrong with that request. Please try again.