Last active
December 31, 2015 16:29
-
-
Save mpilquist/8014394 to your computer and use it in GitHub Desktop.
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
scala> import org.scalatest._ | |
scala> import Matchers._ | |
scala> import Inspectors._ | |
scala> trap { List('a', 'b') should have length 1 } | |
res0: Throwable = org.scalatest.exceptions.TestFailedException: List(a, b) had length 2 instead of expected length 1 | |
scala> trap { List(1, 2, 3) should contain (4) } | |
res1: Throwable = org.scalatest.exceptions.TestFailedException: List(1, 2, 3) did not contain element 4 | |
scala> trap { forEvery (List(1, 2, 3)) { x => x should be < 2 } } | |
res2: Throwable = | |
org.scalatest.exceptions.TestFailedException: forEvery failed, because: | |
at index 1, 2 was not less than 2 (<console>:21), | |
at index 2, 3 was not less than 2 (<console>:21) | |
in List(1, 2, 3) | |
scala> import org.scalautils.StringNormalizations._ | |
scala> trap { (Array("Doe", "Me") should contain oneOf ("X", "RAY", "BEAM")) (after being lowerCased) } | |
res3: Throwable = org.scalatest.exceptions.TestFailedException: Array(Doe, Me) did not contain one of ("X", "RAY", "BEAM") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Paul,
By the way, in 2.1.0-RC3 I added toEquality and toEquivalance methods to Uniformity and Normalization, so that you need not use the English-like syntax to go, for example, from a Uniformity to an Equality. Instead of:
(result === "hello")(after being lowerCased)
You can just write:
(result === "hello")(lowerCased.toEquality)
I got the memo from multiple sources that even some of the folks who like seeing English-like DSLs in test code don't want to see it in the production code.
Bill