Skip to content

Commit 4d1bfbf

Browse files
committedJul 29, 2011
wip: move tests into their own directory, run them with script/test
1 parent bbe37dd commit 4d1bfbf

File tree

9 files changed

+667
-627
lines changed

9 files changed

+667
-627
lines changed
 

‎devnotes/testing

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Definitely a work-in-progress.
2+
3+
To run tests before you commit:
4+
5+
script/test
6+
7+
To add tests:
8+
9+
* Create test fiels in the test/cljs directory.
10+
* Write fns that throw an exception on failure.
11+
* Call those fns from test/cljs/cljs/test_runner.cljs
12+
13+

‎script/repl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/sh
2-
java -server -Xmx2G -Xms2G -Xmn256m -cp 'lib/*:src/clj:src/cljs' clojure.main
2+
java -server -Xmx2G -Xms2G -Xmn256m -cp 'lib/*:src/clj:src/cljs:test/cljs' clojure.main
33

‎script/repljs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/sh
2-
java -server -Xmx2G -Xms2G -Xmn256m -cp 'lib/*:src/clj:src/cljs' clojure.main -e \
2+
java -server -Xmx2G -Xms2G -Xmn256m -cp 'lib/*:src/clj:src/cljs:test/cljs' clojure.main -e \
33
"(require '[cljs.compiler :as comp])
44
(def jse (comp/repl-env))
55
(comp/repl jse)"

‎script/test

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
mkdir -p out
2+
3+
bin/cljsc test > out/core-test.js
4+
bin/cljsc test {:optimizations :advanced} > out/core-advanced-test.js
5+
6+
if [ "$V8_HOME" == "" ]; then
7+
echo "V8_HOME not set, skipping V8 tests"
8+
else
9+
${V8_HOME}/d8 out/core-advanced-test.js
10+
# TODO: figure out path problem when not in advanced mode
11+
# ${V8_HOME}/d8 out/core-test.js
12+
fi
13+
14+
# TODO : run tests with rhino if available

‎src/cljs/cljs/core.cljs

Lines changed: 0 additions & 607 deletions
Large diffs are not rendered by default.

‎src/cljs/cljs/reader.cljs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -345,22 +345,4 @@ nil if the end of stream has been reached")
345345
(let [r (push-back-reader s)]
346346
(read r true nil false)))
347347

348-
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Tests ;;;;;;;;;;;;;;;;
349-
350-
(defn test-reader
351-
[]
352-
(assert (= 1 (read-string "1")))
353-
(assert (= 2 (read-string "#_nope 2")))
354-
(assert (= [3 4] (read-string "[3 4]")))
355-
(assert (= "foo" (read-string "\"foo\"")))
356-
(assert (= :hello (read-string ":hello")))
357-
(assert (= 'goodbye (read-string "goodbye")))
358-
(assert (= #{1 2 3} (read-string "#{1 2 3}")))
359-
(assert (= '(7 8 9) (read-string "(7 8 9)")))
360-
(assert (= '(deref foo) (read-string "@foo")))
361-
(assert (= '(quote bar) (read-string "'bar")))
362-
(assert (= \a (read-string "\\a")))
363-
(assert (= {:tag 'String} (meta (read-string "^String {:a 1}"))))
364-
(assert (= [:a 'b #{'c {:d [:e :f :g]}}]
365-
(read-string "[:a b #{c {:d [:e :f :g]}}]"))))
366348

‎test/cljs/cljs/core_test.cljs

Lines changed: 608 additions & 0 deletions
Large diffs are not rendered by default.

‎test/cljs/cljs/reader_test.cljs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
(ns cljs.reader-test
2+
(:require [cljs.reader :as reader]))
3+
4+
(defn test-reader
5+
[]
6+
(assert (= 1 (reader/read-string "1")))
7+
(assert (= 2 (reader/read-string "#_nope 2")))
8+
(assert (= [3 4] (reader/read-string "[3 4]")))
9+
(assert (= "foo" (reader/read-string "\"foo\"")))
10+
(assert (= :hello (reader/read-string ":hello")))
11+
(assert (= 'goodbye (reader/read-string "goodbye")))
12+
(assert (= #{1 2 3} (reader/read-string "#{1 2 3}")))
13+
(assert (= '(7 8 9) (reader/read-string "(7 8 9)")))
14+
(assert (= '(deref foo) (reader/read-string "@foo")))
15+
(assert (= '(quote bar) (reader/read-string "'bar")))
16+
(assert (= \a (reader/read-string "\\a")))
17+
(assert (= {:tag 'String} (meta (reader/read-string "^String {:a 1}"))))
18+
(assert (= [:a 'b #{'c {:d [:e :f :g]}}]
19+
(reader/read-string "[:a b #{c {:d [:e :f :g]}}]")))
20+
:ok)

‎test/cljs/cljs/test_runner.cljs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
(ns cljs.test-runner
2+
(:require [cljs.core-test :as core-test]
3+
[cljs.reader-test :as reader-test]))
4+
5+
(core-test/test-stuff)
6+
(reader-test/test-reader)
7+
8+
(println "Tests completed without exception")
9+
10+

0 commit comments

Comments
 (0)
Please sign in to comment.