Skip to content

Commit

Permalink
Removing test.check.
Browse files Browse the repository at this point in the history
  • Loading branch information
hanjos committed Nov 5, 2023
1 parent 64198b0 commit f3dc33d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 27 deletions.
3 changes: 1 addition & 2 deletions .clj-kondo/config.edn
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
:earmuffed-var-not-dynamic {:exclude [org.sbrubbles.conditio.vars]}
:missing-docstring {:level :warning}}

:lint-as {clojure.test.check.clojure-test/defspec clojure.core/def
org.sbrubbles.conditio.vars/defcondition clj-kondo.lint-as/def-catch-all
:lint-as {org.sbrubbles.conditio.vars/defcondition clj-kondo.lint-as/def-catch-all
org.sbrubbles.conditio.vars/defrestart clj-kondo.lint-as/def-catch-all}

:output {:exclude-files ["README.md" "src/user.clj" "build.clj" "test"]}}
Expand Down
3 changes: 1 addition & 2 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
:deps {}

:aliases
{:test {:extra-paths ["test"]
:extra-deps {org.clojure/test.check {:mvn/version "1.1.1"}}}
{:test {:extra-paths ["test"]}

;; clojure -X:test:runner
;; clojure -X:test:runner :fail-fast? false
Expand Down
34 changes: 11 additions & 23 deletions test/org/sbrubbles/conditio_test.clj
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
(ns org.sbrubbles.conditio-test
(:require
[clojure.test :refer :all]
[clojure.test.check.clojure-test :refer [defspec]]
[clojure.test.check.generators :as gen]
[clojure.test.check.properties :as prop]
[org.sbrubbles.conditio :as c])
(:import
(clojure.lang ExceptionInfo)
(java.util.regex Pattern)))
(clojure.lang ExceptionInfo)))

;; conditions
(def gen-id (gen/such-that #(some? %) gen/any-equatable))
(def gen-condition (gen/let [id gen-id
map (gen/map gen/any gen/any)]
(c/condition id map)))

(deftest conditions
(let [id :id
con (c/condition id)]
Expand Down Expand Up @@ -62,19 +53,16 @@
;; abort
(deftest abort-explodes-when-called
(is (thrown-with-msg? ExceptionInfo #"Abort"
(c/abort))))

(defspec abort-takes-non-string-values
100
(prop/for-all [v (gen/such-that #(not (nil? %)) gen/any)]
; I would've preferred an (is (thrown-with-msg?)), but it didn't work
; inside a prop/for-all, for some reason
(try
(c/abort v)
(is false)
(catch ExceptionInfo e
(is (re-find (re-pattern (Pattern/quote (str "Abort on " v)))
(.getMessage e)))))))
(c/abort)))

(is (thrown-with-msg? ExceptionInfo #"Abort on "
(c/abort 1)))

(is (thrown-with-msg? ExceptionInfo #"Abort on "
(c/abort :args)))

(is (thrown-with-msg? ExceptionInfo #"Abort on "
(c/abort {}))))

;; handle, with and with-fn
(deftest handle-and-with
Expand Down

0 comments on commit f3dc33d

Please sign in to comment.