i was wondering how to write good properties for property based testing
for instance i have this function:
(defn pixel->tile [position tile-size]
{:x (Math/floor (/ (:x position) tile-size))
:y (Math/floor (/ (:y position) tile-size))})
which is pretty simple
i suppose i’d want to check that the output is non-nil and > 0? but that doesn’t seem to ensure the logic of it
is this too simple for property based testing?
It’s a pretty simple function, so it might be hard to come up with something much better. You could check whether the returned x is <= to the position x
you could probably come up with a distance-scaling property
a relationship between (distance p1 p2) and (distance (f p1) (f p2))
or more generally the 2d-vector representing the offset between them