My question ist about Clojures deftest macro or more generally about how to compare lists created by functions. But i´m new to Clojure and can´t recognize the specific cause. Maybe anyone else have an idea?
First the reported message:
FAIL in (to-symbol-list-test) (util_test.clj:105)
expected: (= (quote (a (not b) c)) (to-symbol-list ["a" "(not b)" "c"]))
actual: (not (= (a (not b) c) (a (not b) c)))
But it is obviously that (= (a (not b) c) (a (not b) c)) quoted should be true instead.
Second the specific test code:
(deftest to-symbol-list-test
(is (= '(a (not b) c) (to-symbol-list ["a" "(not b)" "c"]))))
Third the definition of to-symbol-list:
(defn to-symbol-list [term]
"Converts a vector based term into a list based term
by converting its elements into symbols recursivly"
(postwalk
#(if (string? %)
(symbol %)
(reverse (into '() %)))
term))
The function even should convert nested vectors. It´s an example, other functions behave in the same manner. I guessed it could cause by different types. For example list vs lazy-seq and i compare the lazy function instead of the data, but the types seems to be correct. In REPL i get:
(type (to-symbol-list ["a" "(not b)" "c"]))
=> clojure.lang.PersistentList
(symbol "(not b)")
– cfrick