code.test.checker.common
->checker
added in 3.0
(->checker x)creates a ‘satisfies’ checker if not already a checker
((->checker 1) 1) => true
((->checker (exactly 1)) 1) => true
anything
added in 3.0
(anything x)approx
added in 3.0
(approx v)(approx v threshold)checker that allows approximate verifications
((approx 1) 1.000001) => true
((approx 1) 1.1) => false
((approx 1 0.0000001) 1.001) => false
capture
macro
added in 3.0
(capture)(capture checker)(capture checker sym)adds a form to capture test input
checker
added in 3.0
(checker m)creates a ‘code.test.checker.common.Checker’ object
(checker {:tag :anything :fn (fn x true)}) => code.test.checker.common.Checker
checker?
added in 3.0
(checker? x)checks to see if a datastructure is a ‘code.test.checker.common.Checker’
(checker? (checker {:tag :anything :fn (fn x true)})) => true
exactly
added in 3.0
(exactly v)(exactly v function)checker that allows exact verifications
((exactly 1) 1) => true
((exactly Long) 1) => false
((exactly number?) 1) => false
function-string
added in 3.0
(function-string func)returns the string representation of a function
(function-string every?) => “every?”
(function-string reset!) => “reset!”
satisfies
added in 3.0
(satisfies v)(satisfies v function)checker that allows loose verifications
((satisfies 1) 1) => true
((satisfies Long) 1) => true
((satisfies number?) 1) => true
((satisfies #{1 2 3}) 1) => true
((satisfies 1 2 3) 1) => false
((satisfies number?) “e”) => false
((satisfies #“hello”) #“hello”) => true
stores
added in 3.0
(stores v)a checker that looks into a ref object
((stores 1) (volatile! 1)) => true
((stores 1) 1) => false
succeeded?
added in 3.0
(succeeded? {:keys [status data]})determines if the results of a check have succeeded
(-> (satisfies Long) (verify 1) succeeded?) => true
(-> (satisfies even?) (verify 1) succeeded?) => false
throws
added in 3.0
(throws)(throws e)(throws e msg)checker that determines if an exception has been thrown
((throws Exception “Hello There”) (res/result {:status :exception :data (Exception. “Hello There”)})) => true
verify
added in 3.0
(verify ck result)verifies a value with it’s associated check
(verify (satisfies 2) 1) => (contains-in {:status :success :data false :checker {:tag :satisfies :doc string? :expect 2} :actual 1 :from :verify})
(verify (->checker #(/ % 0)) 1) => (contains {:status :exception :data java.lang.ArithmeticException :from :verify})