Hi I'm trying to write a simple custom matcher that will compare two Sets, and if they're not equal display the differences between the two.Unfortunately the way I've written it won't compile. It says it can't find an overload for the should matcher that would match the Matcher I provided.Is there something else I can provide so it all works, or will the framework not allow this yet? I'm using ScalaTest 2.0M5b for Scala 2.10.1/*** This matcher compares two sets and displays the difference if they do not match*/trait SetMatcher {def equal[T](right: Set[T]): Matcher[Set[T]] =new Matcher[Set[T]] {def apply(left: Set[T]): MatchResult = {MatchResult(left == right,s"""$left did not equal $right|left &~ right = ${left &~ right}|right &~ left = ${right &~ left}""".stripMargin,s"$left equaled $right and it shouldn't have")}}}Also, as an aside are their plans to provide better output for when collections/arrays don't match like JUnit does?--
--
You received this message because you are subscribed to the Google
Groups "scalatest-users" group.
To post to this group, send email to scalate...@googlegroups.com
To unsubscribe from this group, send email to
scalatest-use...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/scalatest-users?hl=en
ScalaTest itself, and documentation, is available here:
http://www.artima.com/scalatest
---
You received this message because you are subscribed to the Google Groups "scalatest-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scalatest-use...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Hi Andrew,Can you elaborate on what diffs you'd like to see. I'm not sure I know what you're getting with JUnit. I tried this and see similar output to ScalaTest:
scala> assertEquals(s1, s2)Are you perhaps talking about diffs you can get in IDEs when using JUnit? Also, what does &~ do?
java.lang.AssertionError: expected:<[1, 2, 3]> but was:<[1, 2, 4]>
On Tuesday, April 30, 2013 10:40:20 AM UTC-4, Bill Venners wrote:Hi Andrew,Can you elaborate on what diffs you'd like to see. I'm not sure I know what you're getting with JUnit. I tried this and see similar output to ScalaTest:
Sure can. For example if I compare two sets of numbers Set(1,2,3) and Set(3, 4, 5) I should see the following output:Set(1,2,3) did not equal Set(3,4,5)left &~ right = Set(4,5)right &~ left = Set(1,2)Basically &~ provides the difference between two Sets (there is also a "diff" method which does the same thing). I can use this to see exactly why two Sets don't match. Obviously the real world example consists of more complicated objects that aren't easily compared by eye.
scala> assertEquals(s1, s2)Are you perhaps talking about diffs you can get in IDEs when using JUnit? Also, what does &~ do?
java.lang.AssertionError: expected:<[1, 2, 3]> but was:<[1, 2, 4]>Hmm..maybe I'm thinking of Strings only, which scalatest seems to support. I could have sworn JUnit did something similar to arrays but I guess I was imagining things.Either way, it would be a useful feature to have for comparing collections of more complicated objects.
Hi Andrew,
As far as your trouble with the custom matcher, I'd try renaming it from equal. I suspect you could get rid of the ambiguity by using a different name.
--
--
You received this message because you are subscribed to the Google
Groups "scalatest-users" group.
To post to this group, send email to scalate...@googlegroups.com
To unsubscribe from this group, send email to
scalatest-use...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/scalatest-users?hl=en
ScalaTest itself, and documentation, is available here:
http://www.artima.com/scalatest
---
You received this message because you are subscribed to the Google Groups "scalatest-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scalatest-use...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Hi Andrew,
I did try this off of trunk, so maybe that's why it worked for me, given we are in the middle of a big matchers refactor. But does anything here look different from how you were running?