Skip to content

Commit d55ce31

Browse files
committed
More extensive tests
Try both sides of ==. Try directly implemented as well as inherited methods.
1 parent c186c79 commit d55ce31

File tree

1 file changed

+37
-4
lines changed

1 file changed

+37
-4
lines changed

tests/run/vc-equals.scala

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,43 @@ object Test extends App {
77
}
88
}
99

10-
val c = new C(Array(1, 2,3))
10+
def test1() = {
11+
val c = new C(Array(1, 2,3))
1112

12-
assert(c `equals` new C(Array(1, 2, 3)))
13-
assert(c == (new C(Array(1, 2, 3)): Any))
14-
assert(c == new C(Array(1, 2, 3)))
13+
assert(c `equals` new C(Array(1, 2, 3)))
14+
assert(c == (new C(Array(1, 2, 3)): Any))
15+
assert(c == new C(Array(1, 2, 3)))
16+
17+
assert(new C(Array(1, 2, 3)) == c)
18+
assert((new C(Array(1, 2, 3)): Any) == c)
19+
assert(new C(Array(1, 2, 3)) == c)
20+
}
21+
22+
trait Eql extends Any {
23+
def deep: Any
24+
override def equals(that: Any) = that match {
25+
case that: D => deep == that.s.deep
26+
case _ => false
27+
}
28+
}
29+
30+
class D(val s: Array[Int]) extends AnyVal with Eql {
31+
def deep = s.deep
32+
}
33+
34+
def test2() = {
35+
val c = new D(Array(1, 2,3))
36+
37+
assert(c `equals` new D(Array(1, 2, 3)))
38+
assert(c == (new D(Array(1, 2, 3)): Any))
39+
assert(c == new D(Array(1, 2, 3)))
40+
41+
assert(new D(Array(1, 2, 3)) == c)
42+
assert((new D(Array(1, 2, 3)): Any) == c)
43+
assert(new D(Array(1, 2, 3)) == c)
44+
}
45+
46+
test1()
47+
test2()
1548

1649
}

0 commit comments

Comments
 (0)