If you're checking multiple related properties in one test, is better to use one = or multiple =? Does which method you use affect shrinkage? tree/node-healthy? returns a boolean
(defspec add-remove-node-maintains-health
(prop/for-all [k gen/small-integer
size gen/nat]
;; +1 to prevent removing nodes from empty trees
(let [tree (make-integer-tree (+ 1 size))]
(=
(tree/node-healthy? (tree/node-add tree k))
(tree/node-healthy? (tree/node-remove-least tree))
(tree/node-healthy? (tree/node-remove-greatest tree))
(tree/node-healthy? (->> tree tree/node-random node/-k (tree/node-remove tree)))))))
or
(defspec add-remove-node-maintains-health
(prop/for-all [k gen/small-integer
size gen/nat]
;; +1 to prevent removing nodes from empty trees
(let [tree (make-integer-tree (+ 1 size))]
(= (tree/node-healthy? (tree/node-add tree k)))
(= (tree/node-healthy? (tree/node-remove-least tree)))
(= (tree/node-healthy? (tree/node-remove-greatest tree)))
(= (tree/node-healthy? (->> tree tree/node-random node/-k (tree/node-remove tree)))))))
or
(defspec add-remove-node-maintains-health
(prop/for-all [k gen/small-integer
size gen/nat]
;; +1 to prevent removing nodes from empty trees
(let [tree (make-integer-tree (+ 1 size))]
(= (and
(tree/node-healthy? (tree/node-add tree k))
(tree/node-healthy? (tree/node-remove-least tree))
(tree/node-healthy? (tree/node-remove-greatest tree))
(tree/node-healthy? (->> tree tree/node-random node/-k (tree/node-remove tree))))))))Hi Jared, I ran into a very similar brick wall. I ended up looking at chuck: https://github.com/gfredericks/test.chuck.
doesn't matter
Stylistically, is one preferred?
the body of your property is basically just a predicate
and (= x) is always true
(= false) is true. And iād worry if all of your predicates uniformly returned false and you misinterpreted this
= doesn't do anything special
(for the (= (pred) (pred) (pred))
so basically all 3 of your examples are bogus
the first sort of works, but will also report a success if all your node-healthy? calls return false
the second always is a success
and so is the third
regarding the first, if I add false or (> size 10) inside the (= block it fails So why would it pass when it should fail, if node-healthy? is false?
because (= false false false) is true
appreciate it. Thanks š