Skip to content

Commit

Permalink
dep 1.2 snapshots, welcome to the bloody edge
Browse files Browse the repository at this point in the history
  • Loading branch information
stuarthalloway committed Feb 22, 2010
1 parent a5c8825 commit ad9f0c0
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 18 deletions.
8 changes: 5 additions & 3 deletions project.clj
@@ -1,8 +1,10 @@
(defproject circumspec "0.0.6"
(defproject circumspec "0.0.7"
:dependencies [[org.clojure/clojure
"1.1.0"]
"1.2.0-master-SNAPSHOT"]
[org.clojure/clojure-contrib
"1.1.0"]
"1.2.0-master-SNAPSHOT"]
[jline
"0.9.94"]
[org.clojure/swank-clojure
"1.0"]]
:repositories {"clojure-releases" "http://build.clojure.org/releases"})
2 changes: 1 addition & 1 deletion script/repl
Expand Up @@ -5,4 +5,4 @@ for f in lib/*.jar; do
CLASSPATH=$CLASSPATH:$f
done

rlwrap java $@ -cp $CLASSPATH clojure.main -i script/repl.clj -e "(use '[clojure.contrib.duck-streams :only (spit read-lines reader writer)] '[clojure.contrib def ns-utils pprint repl-utils shell-out]) (require '[clojure.contrib.str-utils2 :as s])$REPL_SWANK" -r
java $@ -cp $CLASSPATH jline.ConsoleRunner clojure.main -i script/repl.clj -e "(use '[clojure.contrib.duck-streams :only (spit read-lines reader writer)] '[clojure.contrib def ns-utils pprint repl-utils shell-out]) (require '[clojure.contrib.str-utils2 :as s])$REPL_SWANK" -r
15 changes: 14 additions & 1 deletion src/circumspec/test.clj
@@ -1,10 +1,21 @@
(ns circumspec.test
(:use [clojure.contrib.def :only (defalias)]
[clojure.contrib.seq-utils :only (flatten)]
[clojure.contrib.str-utils :only (re-gsub)]
[circumspec.should :only (should)]
[circumspec.context :only (test-function-metadata)]
circumspec.utils))

(defn make-test-name
"Make a legal test name: Convert whitespace, /, . to dashes. Append
-test if collides with name of the thing itself"
[s]
(let [basename (re-gsub #"\s+|/|." "-" s)]
(if (and (resolve (symbol basename))
(not (.endsWith basename "-test")))
(str basename "-test")
basename)))

; TODO: does not work with macro names or ns prefixes
(defn test-function-name
"Create a test function name. If the provided desc is a var,
Expand All @@ -13,7 +24,7 @@
[desc]
(symbol (if (symbol? desc)
(str (denamespace (str desc)) "-test")
(dasherize (str desc)))))
(make-test-name (str desc)))))

(defn =>-assertion?
[form]
Expand Down Expand Up @@ -45,6 +56,8 @@
~@forms))

(defalias testing it)
;; defalias crushes :meta, so
(alter-meta! #'testing assoc :macro true)

(defn test?
"Does var refer to a test?"
Expand Down
4 changes: 0 additions & 4 deletions src/circumspec/utils.clj
Expand Up @@ -73,8 +73,4 @@
[s]
(re-gsub #".*/" "" s))

(defn dasherize
"Convert whitespace to dashes."
[s]
(re-gsub #"\s+" "-" s))

13 changes: 9 additions & 4 deletions test/circumspec/test_test.clj
@@ -1,8 +1,13 @@
(ns circumspec.test-test
(:use circumspec)
(:use circumspec circumspec.for-all)
(:require [circumspec.test :as t]))

(testing "=>-assertion?"
(it t/make-test-name
(let [whitespacey-string (string-of alpha-ascii famous-whitespace (constantly \/))]
(for-all [s (whitespacey-string)]
(should (not (re-find #" |\t|\n|/|\." (t/make-test-name s)))))))

(it "=>-assertion?"
(should (false? (t/=>-assertion? nil)))
(should (false? (t/=>-assertion? [])))
(should (false? (t/=>-assertion? '[a])))
Expand All @@ -12,11 +17,11 @@
(should (true? (t/=>-assertion? '[a => b])))
(should (true? (t/=>-assertion? '[a b => c]))))

(testing "rewrite-=>"
(it "rewrite-=>"
(should (= (t/rewrite-=> '+ '[1 2 => 3])
'(circumspec.should/should (clojure.core/= (clojure.core/apply + [1 2]) 3)))))

(testing "testing-fn"
(it "testing-fn"
(should (= '(circumspec.utils/defn! add-test
"Generated test from the testing-fn macro."
[]
Expand Down
5 changes: 0 additions & 5 deletions test/circumspec/utils_test.clj
Expand Up @@ -2,11 +2,6 @@
(:use circumspec circumspec.utils circumspec.for-all
clojure.contrib.with-ns))

(testing dasherize
(let [whitespacey-string (string-of alpha-ascii famous-whitespace)]
(for-all [s (whitespacey-string)]
(should (not (re-find #" |\t|\n" (dasherize s)))))))

(describe "class-symbol?"
(testing "always returns a boolean"
(let [ascii-symbol (symbol-of alpha-ascii)]
Expand Down

0 comments on commit ad9f0c0

Please sign in to comment.