Skip to content

Commit

Permalink
Merge pull request #83 from bhb/use-expound-in-check
Browse files Browse the repository at this point in the history
[WIP] Use expound for `check` results
  • Loading branch information
bhb authored Apr 27, 2018
2 parents d5d1d6e + b504537 commit 689a962
Show file tree
Hide file tree
Showing 8 changed files with 588 additions and 69 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ All notable changes to this project will be documented in this file. This change
## [Unreleased]

### Added
- Optional colorized output
- [Optional colorized output](https://github.com/bhb/expound/issues/44)
- [`explain-results` and `explain-results-str` functions print human-optimized output for `clojure.spec.test.alpha/check` results](https://github.com/bhb/expound/issues/72)

## [0.5.0] - 2018-02-06

Expand Down
1 change: 1 addition & 0 deletions bin/deps.edn
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{:deps
{expound/expound {:local/root ".."}
orchestra {:mvn/version "0.3.0"}
org.clojure/test.check {:mvn/version "0.9.0"}
}}
35 changes: 34 additions & 1 deletion bin/sample.clj
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,40 @@

(display-explain
:predicate-messages/score
101))
101)

(println "----- check results -----")

(doseq [sym-to-check (st/checkable-syms)]
(println "trying to check" sym-to-check "...")
(try
(st/with-instrument-disabled
(orch.st/with-instrument-disabled
(expound/explain-results (st/check sym-to-check {:clojure.spec.test.check/opts {:num-tests 5}}))))
(catch Exception e
(println "caught exception: " (.getMessage e)))))

(s/fdef some-func
:args (s/cat :x int?))

(st/with-instrument-disabled
(orch.st/with-instrument-disabled
(expound/explain-results (st/check `some-func)))) (s/fdef results-str-fn1
:args (s/cat :x nat-int? :y nat-int?)
:ret pos-int?)
(defn results-str-fn1 [x y]
(+ x y))

(s/fdef results-str-fn2
:args (s/cat :x nat-int? :y nat-int?)
:fn #(let [x (-> % :args :x)
y (-> % :args :y)
ret (-> % :ret)]
(< x ret)))
(defn results-str-fn2 [x y]
(+ x y))

(expound/explain-result (st/check-fn `resultsf-str-fn1 (s/spec `results-str-fn2))))

(go)

Loading

0 comments on commit 689a962

Please sign in to comment.