Comparing maps with specs2

158 views
Skip to first unread message

Edmondo Porcu

unread,
May 7, 2013, 11:46:32 AM5/7/13
to specs2...@googlegroups.com

Hello guys,

I have a strange problem comparing two maps : I have a test failing with no clear reason :

 

 

'ArrayBuffer('(ASK,0.0)'): scala.collection.immutable.Map$Map1[scala.Tuple2]'

is not equal to

'ArrayBuffer('(ASK,0.0)'): scala.collection.immutable.Map$Map1[scala.Tuple2]'

Expected :Map(ASK -> 0.0)

Actual   :Map(ASK -> 0.0)

<Click to see difference>

 

 

java.lang.Exception: 'ArrayBuffer('(ASK,0.0)'): scala.collection.immutable.Map$Map1[scala.Tuple2]'

is not equal to

'ArrayBuffer('(ASK,0.0)'): scala.collection.immutable.Map$Map1[scala.Tuple2]'

 

I am comparing two maps, what has it to do with ArrayBuffers?

 

Thanks for your help

 

Edmondo Porcu

 

 


______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________

etorreborre

unread,
May 7, 2013, 4:49:31 PM5/7/13
to specs2...@googlegroups.com
Hi Edmondo,

I'm going to have a look at the "ArrayBuffer" part (this must be a display error on my side) but the likely reason for your issue is that you have 2 maps with different objects and similar string representation. 

For example: Map(1 -> "2") and Map(1 -> 2)

Cheers,

Eric.

Edmondo Porcu

unread,
May 7, 2013, 4:53:04 PM5/7/13
to specs2...@googlegroups.com

Hello Eric,

That’s a problem with Salat MongoDB deserializer. I find out something crazy: the deserializer sets the internal type to other values:

 

https://github.com/novus/salat/issues/87 Look the picture I link in the issue J)

 

Best regards

--
You received this message because you are subscribed to the Google Groups "specs2-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to specs2-users...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


 
 

______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________

etorreborre

unread,
May 8, 2013, 1:10:27 AM5/8/13
to specs2...@googlegroups.com
Thanks for your explanation.

In the latest 1.15-SNAPSHOT you will get a verbose but more helpful failure message giving the class of each element:

[error]    Map(1: java.lang.Integer -> 2: java.lang.String, 2: java.lang.Integer -> 3: java.lang.String): scala.collection.immutable.Map$Map2'
[error]    is not equal to
[error]   'Map(1: java.lang.Integer -> 2: java.lang.Integer, 2: java.lang.Integer -> 3: java.lang.Integer): scala.collection.immutable.Map$Map2'

E.
Reply all
Reply to author
Forward
0 new messages