In my program I am trying to test my program by writing tests that verify the functionality of my defined functions. I am testing the equality of sequences after they have passed through my function.
Definition of my-reverse:
(defn my-reverse [coll]
(if (empty? coll)
[]
(conj
(my-reverse (rest coll))
(first coll)
)
)
)
I do not know why I am failing the assertion, as (my-reverse [1]) returns [1]. Here is the assertion:
(assert (identical? (my-reverse [1]) [1]))
Thank you all in advance!
identical?
only returns true
if the arguments refer to the same object, which will not be the case if your my-reverse
function constructs a new list. You can just use =
:
(assert (= (my-reverse [1]) [1]))