Include generated-so-far when throwing for not-enough-distinct
Gary Fredericks
8 years ago
550 | 550 |
(throw (ex-info "Couldn't generate enough distinct elements!"
|
551 | 551 |
{:gen gen
|
552 | 552 |
:max-tries max-tries
|
553 | |
:num-elements num-elements}))
|
|
553 |
:num-elements num-elements
|
|
554 |
:so-far (->> rose-trees
|
|
555 |
(persistent!)
|
|
556 |
(core/map rose/root))}))
|
554 | 557 |
|
555 | 558 |
|
556 | 559 |
(or (= max-tries tries)
|
422 | 422 |
(= 4 (count (distinct boolean-sets)))))
|
423 | 423 |
|
424 | 424 |
(deftest can't-generate-set-of-five-booleans
|
425 | |
(is (thrown-with-msg? #?(:clj Exception :cljs js/Error)
|
426 | |
#"Couldn't generate enough distinct elements"
|
427 | |
(gen/generate (gen/set gen/boolean {:num-elements 5})))))
|
|
425 |
(let [ex (try
|
|
426 |
(gen/generate (gen/set gen/boolean {:num-elements 5}))
|
|
427 |
(is false)
|
|
428 |
(catch #?(:clj Exception :cljs js/Error) e
|
|
429 |
e))]
|
|
430 |
(is (re-find #"Couldn't generate enough distinct elements"
|
|
431 |
#? (:clj (.getMessage ^Exception ex) :cljs (.-message ex))))
|
|
432 |
(is (#{[true false] [false true]} (-> ex ex-data :so-far)))))
|
428 | 433 |
|
429 | 434 |
;; Generating proper matrices
|
430 | 435 |
;; ---------------------------------------------------------------------------
|