Created
August 6, 2015 10:41
-
-
Save zcaudate/f50595ae9da76d133421 to your computer and use it in GitHub Desktop.
generative testing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn count-elements [coll1 coll2] | |
(+ (count coll1) (count coll2) 1)) | |
(defn count-elements-tester [f] | |
(let [n (rand-int 6) | |
m (rand-int 6) | |
output (+ n m) | |
inputs [(range n) (range m)] | |
actual (apply f inputs)] | |
(if (= actual output) | |
{:result :success} | |
{:result :error :inputs inputs :output output :actual actual}))) | |
(filter #(-> % :result (= :error)) (map count-elements-tester (repeat 10 count-elements))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment