From c633e28b40ec2f7e195842a75dc98fa6b953d898 Mon Sep 17 00:00:00 2001 From: Burak Emir Date: Fri, 22 Dec 2006 09:13:47 +0000 Subject: fixed test case + strict checking for atom --- src/library/scala/testing/UnitTest.scala | 13 +++++++++++++ src/library/scala/xml/Atom.scala | 4 ++++ 2 files changed, 17 insertions(+) (limited to 'src/library') diff --git a/src/library/scala/testing/UnitTest.scala b/src/library/scala/testing/UnitTest.scala index 38b6fb17e3..302ab6dc4a 100644 --- a/src/library/scala/testing/UnitTest.scala +++ b/src/library/scala/testing/UnitTest.scala @@ -61,6 +61,19 @@ object UnitTest { def assertTrue(actual: Boolean): Unit = assertEquals(actual, true) def assertFalse(actual: Boolean): Unit = assertEquals(actual, false) + def assertNull(actual: AnyRef): Unit = + if (actual eq null) + report.ok + else + report.fail(actual.toString, "null") + + def assertNonNull(actual: AnyRef): Unit = + if (actual ne null) + report.ok + else + report.fail(actual.toString, "null") + + def assertNotEquals[a]( actual: a, expected: a): Unit = if (actual != expected) report.ok diff --git a/src/library/scala/xml/Atom.scala b/src/library/scala/xml/Atom.scala index 74e572a556..0bbf65f979 100644 --- a/src/library/scala/xml/Atom.scala +++ b/src/library/scala/xml/Atom.scala @@ -21,6 +21,10 @@ import compat.StringBuilder; [serializable] class Atom[+A]( val data: A ) extends SpecialNode { + data match { + case null => new IllegalArgumentException("cannot construct Atom(null)") + case _ => + } final override def typeTag$:Int = -1; /** the constant "#PCDATA" -- cgit v1.2.3