Created
July 29, 2014 04:40
-
-
Save bvenners/34c6ca9787cc1ee146cf to your computer and use it in GitHub Desktop.
Now playing in ScalaTest master...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// This is not yet at a good point for a milestone release, but I've been doing a lot of | |
// work to try and improve equality and containership checks in ScalaTest and Scalactic. One part of it is | |
// that I figured out how to get equal, be, and contain matchers to participate in the kind of type checking | |
// that previously only worked with === and should ===. The difficulty was that equal, be, and contain | |
// can be used with logical operators and, or, and not (whereas === did not). Here are some examples: | |
// | |
scala> 1 shouldBe 1L | |
scala> 1 shouldBe "one" | |
<console>:20: error: could not find implicit value for parameter | |
evidence: org.scalactic.enablers.EvidenceThat[String]#CanEqual[Int] | |
1 shouldBe "one" | |
^ | |
scala> 1L shouldEqual 1 | |
scala> "one" shouldEqual 1 | |
<console>:20: error: could not find implicit value for parameter | |
evidence: org.scalactic.enablers.EvidenceThat[Int]#CanEqual[String] | |
"one" shouldEqual 1 | |
^ | |
scala> List(1, 2, 3) should (have length 3 and not be Vector(3, 2, 1)) | |
scala> List(1, 2, 3) should (have length 3 and not be Set(3, 2, 1)) | |
<console>:20: error: could not find implicit value for parameter | |
typeClass2: org.scalactic.enablers.EvidenceThat[scala.collection.immutable.Set[Int]]#CanEqual[List[Int]] | |
List(1, 2, 3) should (have length 3 and not be Set(3, 2, 1)) | |
^ | |
scala> List(1, 2) should contain (2) | |
scala> List(1, 2) should contain ("two") | |
<console>:20: error: could not find implicit value for parameter | |
ypeClass1: org.scalactic.enablers.EvidenceThat[String]#CanBeContainedIn[List[Int]] | |
List(1, 2) should contain ("two") | |
^ | |
scala> List(1, 2) should contain oneOf (2, 3) | |
scala> List(1, 2) should contain oneOf ("two", "three") | |
<console>:20: error: could not find implicit value for parameter | |
evidence: org.scalactic.enablers.EvidenceThat[String]#CanBeContainedIn[List[Int]] | |
List(1, 2) should contain oneOf ("two", "three") | |
^ | |
scala> List(1, 2) should (have length 2 and contain oneOf (2, 3)) | |
scala> List(1, 2) should (have length 2 and contain oneOf ("two", "three")) | |
<console>:20: error: could not find implicit value for parameter | |
typeClass2: org.scalactic.enablers.EvidenceThat[String]#CanBeContainedIn[List[Int]] | |
List(1, 2) should (have length 2 and contain oneOf ("two", "three")) | |
^ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment