Permalink
Browse files

Improve detection of simple tests.

  • Loading branch information...
1 parent 680f005 commit 11f51bf7400a25d1488982a38b4a392ee1ce6e3f @mudge committed Mar 29, 2013
Showing with 6 additions and 3 deletions.
  1. +2 −1 project.clj
  2. +4 −2 src/foreclojure_downloader/translator.clj
View
@@ -5,6 +5,7 @@
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.5.1"]
[clj-http "0.7.0"]
- [cheshire "5.0.2"]]
+ [cheshire "5.0.2"]
+ [midje "1.5.1"]]
:plugins [[lein-midje "3.0.0"] [lein-kibit "0.0.8"]]
:main foreclojure-downloader.core)
@@ -4,8 +4,10 @@
(defn- parse-simple-test
"Parse simple tests of the form (= x y) where possible."
[test]
- (next (re-find #"^(?s)\((==?)\s+(#?\".+\"|'?\(.+\)|\[.+\]|#?\{.+\}|\S+)\s+(#?\".+\"|'?\(.+\)|\[.+\]|#?\{.+\}|\S+)\)$"
- test)))
+ (let [[eq & _ :as parsed-test] (binding [*read-eval* false] (read-string test))]
+ (when (and (= (count parsed-test) 3) (or (= eq '=) (= eq '==)))
+ (next (re-find #"^(?s)\((==?)\s+(#?\".+\"|'?\(.+\)|\[.+\]|#?\{.+\}|\S+)\s+(#?\".+\"|'?\(.+\)|\[.+\]|#?\{.+\}|\S+)\)$"
+ test)))))
(defn- test->checker
"Translate a test into a Midje checker.

0 comments on commit 11f51bf

Please sign in to comment.