Created
August 27, 2014 03:52
-
-
Save bvenners/2e89ef80729cc9881a67 to your computer and use it in GitHub Desktop.
Scalactic's === will consistently either allow or not allow both A === B and B === A
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 CheckedEquality._ | |
| import CheckedEquality._ | |
| scala> 1 === "one" | |
| <console>:20: error: types Int and String do not adhere to the type constraint selected for the === and !== operators; the missing implicit parameter is of type org.scalactic.EqualityConstraint[Int,String] | |
| 1 === "one" | |
| ^ | |
| scala> "one" === 1 | |
| <console>:20: error: types String and Int do not adhere to the type constraint selected for the === and !== operators; the missing implicit parameter is of type org.scalactic.EqualityConstraint[String,Int] | |
| "one" === 1 | |
| ^ | |
| scala> 1 === 1L | |
| res2: Boolean = true | |
| scala> 1L === 1 | |
| res3: Boolean = true | |
| scala> import StrictCheckedEquality._ | |
| import StrictCheckedEquality._ | |
| scala> 1 === "one" | |
| <console>:23: error: types Int and String do not adhere to the type constraint selected for the === and !== operators; the missing implicit parameter is of type org.scalactic.EqualityConstraint[Int,String] | |
| 1 === "one" | |
| ^ | |
| scala> "one" === 1 | |
| <console>:23: error: types String and Int do not adhere to the type constraint selected for the === and !== operators; the missing implicit parameter is of type org.scalactic.EqualityConstraint[String,Int] | |
| "one" === 1 | |
| ^ | |
| scala> 1 === 1L | |
| <console>:23: error: types Int and Long do not adhere to the type constraint selected for the === and !== operators; the missing implicit parameter is of type org.scalactic.EqualityConstraint[Int,Long] | |
| 1 === 1L | |
| ^ | |
| scala> 1L === 1 | |
| <console>:23: error: types Long and Int do not adhere to the type constraint selected for the === and !== operators; the missing implicit parameter is of type org.scalactic.EqualityConstraint[Long,Int] | |
| 1L === 1 | |
| ^ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment