Fork me on GitHub
#test-check
<
2016-09-30
>
liamd18:09:35

i was wondering how to write good properties for property based testing

liamd18:09:51

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))})

liamd18:09:59

which is pretty simple

liamd18:09:50

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

liamd18:09:56

is this too simple for property based testing?

lucasbradstreet20:09:56

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

gfredericks22:09:37

you could probably come up with a distance-scaling property

gfredericks22:09:54

a relationship between (distance p1 p2) and (distance (f p1) (f p2))

gfredericks22:09:35

or more generally the 2d-vector representing the offset between them