Browse files

Updated tests to expect the result they were getting :) Mostly to do …

…with

predeclaring vars and functions and using " for strings instead of '.
  • Loading branch information...
1 parent e4fbcd9 commit 12b85fc9078ed974045529b156e40cd1a2034d02 @scottjad scottjad committed Sep 16, 2010
Showing with 12 additions and 12 deletions.
  1. +12 −12 test/test_scriptjure.clj
View
24 test/test_scriptjure.clj
@@ -16,8 +16,8 @@
(is (= "/^abc/" (js #"^abc"))))
(deftest test-var-expr
- (is (= (strip-whitespace (js (var x 42))) "var x = 42;"))
- (is (= (strip-whitespace (js (var x 1 y 2))) (strip-whitespace "var x = 1; var y = 2"))))
+ (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;"))))
(deftest test-invalid-variables-throw
(is (= (js valid_symbol)) "valid_symbol")
@@ -68,39 +68,39 @@
(is (= (js (.. google chart (bar :a :b))) "google.chart.bar(a, b)")))
(deftest test-if
- (is (= (strip-whitespace (js (if (&& (== foo bar) (!= foo baz)) (.draw google.chart))))
- "if (((foo == bar) && (foo != baz))) { google.chart.draw() }"))
+ (is (= (strip-whitespace (js (if (&& (= foo bar) (!= foo baz)) (.draw google.chart))))
+ "if (((foo === bar) && (foo !== baz))) { google.chart.draw() }"))
(is (= (strip-whitespace (js (if foo (do (var x 3) (foo x)) (do (var y 4) (bar y)))))
- "if (foo) { var x = 3; foo(x); } else { var y = 4; bar(y); }")))
+ "var x, y; if (foo) { x = 3; foo(x); } else { y = 4; bar(y); }")))
(deftest test-new-operator
- (is (= (js (new google.visualization.ColumnChart (.getElementById document "chart_div"))) "new google.visualization.ColumnChart(document.getElementById('chart_div'))")))
+ (is (= (js (new google.visualization.ColumnChart (.getElementById document "chart_div"))) "new google.visualization.ColumnChart(document.getElementById(\"chart_div\"))")))
(deftest test-fn
- (is (= (strip-whitespace (js (fn foo [x] (foo a) (bar b)))) "function foo(x) { foo(a); bar(b); }")))
+ (is (= (strip-whitespace (js (fn foo [x] (foo a) (bar b)))) "var foo; foo = function (x) { foo(a); bar(b); }")))
(deftest test-array
- (is (= (js [1 "2" :foo]) "[1, '2', foo]")))
+ (is (= (js [1 "2" :foo]) "[1, \"2\", foo]")))
(deftest test-aget
(is (= (js (aget foo 2)) "foo[2]")))
(deftest test-map
- (is (= (strip-whitespace (js {:packages ["columnchart"]})) "{packages: ['columnchart']}")))
+ (is (= (strip-whitespace (js {:packages ["columnchart"]})) "{packages: [\"columnchart\"]}")))
(deftest jquery
(is (= (strip-whitespace (js (.ready ($j document)
(fn []
(.bind ($j "div-id") "click"
(fn [e]
- (.cookie $j "should-display-make-public" true))))))) "$j(document).ready(function () { $j('div-id').bind('click', function (e) { $j.cookie('should-display-make-public', true); } ); } )" )))
+ (.cookie $j "should-display-make-public" true))))))) "$j(document).ready(function () { $j(\"div-id\").bind(\"click\", function (e) { $j.cookie(\"should-display-make-public\", true); }); })" )))
(deftest test-do
(is (= (strip-whitespace
(js
(var x 3)
(var y 4)
- (+ x y))) "var x = 3; var y = 4; (x + y);")))
+ (+ x y))) "var x, y; x = 3; y = 4; (x + y);")))
(deftest test-doseq
(is (= (strip-whitespace (js (doseq [i [1 2 3]] (foo i))))
@@ -113,7 +113,7 @@
(var x 3)
(var y 4)))]
(is (= (strip-whitespace (js (fn foo [x] (clj stuff))))
- "function foo(x) { var x, y; x = 3; y = 4; }"))))
+ "var foo; foo = function (x) { var x, y; x = 3; y = 4; }"))))
(deftest test-js*-adds-implicit-do
(let [one (js* (var x 3)

0 comments on commit 12b85fc

Please sign in to comment.