aboutsummaryrefslogtreecommitdiff
path: root/tests/neg/equality.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-05-06 19:16:54 +0200
committerMartin Odersky <odersky@gmail.com>2016-05-23 16:11:45 +0200
commitec71e006ea5d506b55ba624999b0d2aa01b2d7c1 (patch)
tree346404d31021715a923bd0e912da197030085e52 /tests/neg/equality.scala
parentf2361d6f1604a3869679ff9fa27e7ccba5404b93 (diff)
downloaddotty-ec71e006ea5d506b55ba624999b0d2aa01b2d7c1.tar.gz
dotty-ec71e006ea5d506b55ba624999b0d2aa01b2d7c1.tar.bz2
dotty-ec71e006ea5d506b55ba624999b0d2aa01b2d7c1.zip
Add Java types to equality test
Diffstat (limited to 'tests/neg/equality.scala')
-rw-r--r--tests/neg/equality.scala21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/neg/equality.scala b/tests/neg/equality.scala
index 4a77a2d25..4434aa160 100644
--- a/tests/neg/equality.scala
+++ b/tests/neg/equality.scala
@@ -14,6 +14,12 @@ object equality {
implicit def eqNum: Eq[Num, Num] = Eq
implicit def eqOption[T, U](implicit e: Eq[T, U]): Eq[Option[T], Option[U]] = Eq
+ implicit def eqString: Eq[String, String] = Eq
+ implicit def eqInt: Eq[Int, Int] = Eq
+ implicit def eqNumber: Eq[Number, Number] = Eq
+ implicit def eqIntNumber: Eq[Int, Number] = Eq
+ implicit def eqNumberInt: Eq[Number, Int] = Eq
+
def main(args: Array[String]): Unit = {
Some(Other(3)) == None
@@ -24,6 +30,10 @@ object equality {
val m = Num(3)
n == m
+ val so: Object = "abc"
+ so == "abc"
+ "abc" == so
+
Other(1) == Other(2)
Some(x) == None
@@ -56,6 +66,13 @@ object equality {
p == f
Some(new Apple) == Some(new Pear)
+ val i = 3
+ val bi = BigInt(i)
+ i == i
+ bi == bi
+ i == bi
+ bi == i
+
n match {
case None => // error
}
@@ -75,5 +92,9 @@ object equality {
Some(n) == Some(Other(3)) // error
Some(Other(3)) == Some(n) // error
n == z // error
+ "abc" == 1 // error
+ 1 == "abc" // error
+ "abc" == bi // error
+ bi == "abc" // error
}
}