Skip to content

Instantly share code, notes, and snippets.

@trikitrok
Last active July 29, 2019 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trikitrok/2b0e460147bf47696ccc43b88faa49e9 to your computer and use it in GitHub Desktop.
Save trikitrok/2b0e460147bf47696ccc43b88faa49e9 to your computer and use it in GitHub Desktop.
(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