Last active
July 29, 2019 17:05
-
-
Save trikitrok/2b0e460147bf47696ccc43b88faa49e9 to your computer and use it in GitHub Desktop.
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
(ns fizzbuzz-pbt.core-test | |
(:require | |
[midje.sweet :refer :all] | |
[clojure.set :as set] | |
[clojure.test.check.generators :as gen] | |
[midje.experimental :refer [for-all]] | |
[fizzbuzz-pbt.core :as sut])) | |
(defn- multiples-of [n] | |
(iterate #(+ % n) n)) | |
(defn- fizzbuzz-for [n] | |
(nth (sut/fizzbuzz) (dec n))) | |
(def multiples-of-3 (set (take-while #(< % 101) (multiples-of 3)))) | |
(def multiples-of-5 (set (take-while #(< % 101) (multiples-of 5)))) | |
(facts | |
"about fizzbuzz" | |
(fact | |
"multiples of 3 but not 5 are Fizz" | |
(for-all | |
[n (gen/elements | |
(set/difference | |
multiples-of-3 | |
multiples-of-5))] | |
{:num-tests 100} | |
(fizzbuzz-for n) => "Fizz"))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment