From fa99242159242f676b6b234693060d422762cebd Mon Sep 17 00:00:00 2001 From: paltherr Date: Mon, 11 Apr 2005 14:57:26 +0000 Subject: - Added method "ne" in class AnyRef --- test/files/run/runtime.check | 19 +++++++++++++++++++ test/files/run/runtime.scala | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) (limited to 'test/files') diff --git a/test/files/run/runtime.check b/test/files/run/runtime.check index bbe28252c7..990a087da0 100644 --- a/test/files/run/runtime.check +++ b/test/files/run/runtime.check @@ -43,3 +43,22 @@ M0 >>> Test2 +<<< Test3 +Ok +Ok +Ok +Ok +Ok +Ok +Ok +Ok +Ok +Ok +Ok +Ok +Ok +Ok +Ok +Ok +>>> Test3 + diff --git a/test/files/run/runtime.scala b/test/files/run/runtime.scala index 135480aa6d..64f78db7c6 100644 --- a/test/files/run/runtime.scala +++ b/test/files/run/runtime.scala @@ -132,6 +132,47 @@ object Test2Test { } } +//############################################################################ +// Test 3 - Methods eq and ne + +object Test3Test { + + class Foo { override def equals(that: Any) = throw new Error("abort"); } + + def check(expected: Boolean, actual1: Boolean, actual2: Boolean): Unit = + System.out.println( + if ((actual1 == expected) && (actual2 == !expected)) "Ok" else "KO: " + + "expected: " + expected + " - " + (!expected) + ", " + + "found: " + actual1 + " - " + actual1); + + def main(args: Array[String]): Unit = { + val foo1: AnyRef = null; + val foo2: AnyRef = new Foo(); + val foo3: AnyRef = new Foo(); + + check(true , null eq null, null ne null); + check(true , null eq foo1, null ne foo1); + check(false, null eq foo2, null ne foo2); + check(false, null eq foo3, null ne foo3); + + check(true , foo1 eq null, foo1 ne null); + check(true , foo1 eq foo1, foo1 ne foo1); + check(false, foo1 eq foo2, foo1 ne foo2); + check(false, foo1 eq foo3, foo1 ne foo3); + + check(false, foo2 eq null, foo2 ne null); + check(false, foo2 eq foo1, foo2 ne foo1); + check(true , foo2 eq foo2, foo2 ne foo2); + check(false, foo2 eq foo3, foo2 ne foo3); + + check(false, foo3 eq null, foo3 ne null); + check(false, foo3 eq foo1, foo3 ne foo1); + check(false, foo3 eq foo2, foo3 ne foo2); + check(true , foo3 eq foo3, foo3 ne foo3); + } + +} + //############################################################################ // Main @@ -158,6 +199,7 @@ object Test { test("Test0" , Test0Test.main(args)); test("Test1" , Test1Test.main(args)); test("Test2" , Test2Test.main(args)); + test("Test3" , Test3Test.main(args)); if (errors > 0) { System.out.println(); -- cgit v1.2.3