What do round brackets mean in the output of clojure.test failures?

160 views Asked by At

I have the following output in one of my tests:

Assertion failed:
Expected :[[] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] ["seq07"] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] []]
Actual   :[() () () () () () () () () () () () () () () () () () () () () () () () () () ("seq07") () () () () () () () () () () () () () () () () () () () () () () () () () () () () () () () () ()]

What do () and ("seq07") mean in this output?

2

There are 2 answers

0
Erez Rabih On BEST ANSWER

() is a notation for list whereas [] is a notation for vectors

() is an empty list and ("seq07") is a list that contains a single member - the string seq07

you can read more about clojure lists here

EDIT: just found this interesting SO question about lists vs vectors

0
Steffan Westcott On

As noted in another answer, () is an empty list and [] is an empty vector.

Note however that = compares the contents of lists and vectors, it ignores the type of the container:

(= '("seq07") ["seq07"])           ;; => true
(= '(()) [[]])                     ;; => true

The assertion failure in the question is due to the actual vector having fewer elements than the expected vector:

(= ['("seq07")] ['("seq07") '()])  ;; => false