2
votes

I've grabbed some Scala CSV parsing code from here:

Use Scala parser combinator to parse CSV files

And then I tried to write a basic test for it:

assertEquals(List(List()), CSV.parse(""))

And this fails, with message:

java.lang.AssertionError: expected: scala.collection.immutable.$colon$colon but was: scala.collection.immutable.$colon$colon

Any ideas? The output from CSV.parse is an empty List[List[String]] but seems to have a different hashCode than List(Nil) or ListList[String] etc. I can't seem to find any way to compose a list which is equal to the output of CSV.parse("").

UPDATE:

Here is the failure using REPL:

scala> assertEquals(List(Nil), CSV.parse("")) 
java.lang.AssertionError: expected: scala.collection.immutable.$colon$colon<List(List())> but was: scala.collection.immutable.$colon$colon<List(List())>
1

1 Answers

2
votes

Edited: I tried the parser you supplied in the link:

scala> CSV.parse("")
res7: List[List[String]] = List(List(""))

So apparently, it doesn't return a List with an empty List, but a List with a List with the empty string. So your test should fail.