summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/library/scala/testing/UnitTest.scala13
-rw-r--r--src/library/scala/xml/Atom.scala4
-rw-r--r--test/files/jvm/xml03syntax.check3
-rw-r--r--test/files/jvm/xml03syntax.scala13
4 files changed, 27 insertions, 6 deletions
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"
diff --git a/test/files/jvm/xml03syntax.check b/test/files/jvm/xml03syntax.check
index b81c53e9b1..992f71d3bd 100644
--- a/test/files/jvm/xml03syntax.check
+++ b/test/files/jvm/xml03syntax.check
@@ -1,6 +1,5 @@
-<hello>()</hello>
passed ok
-<hello>()</hello>
+passed ok
passed ok
<hello>world</hello>
passed ok
diff --git a/test/files/jvm/xml03syntax.scala b/test/files/jvm/xml03syntax.scala
index 7ae6473302..e193af24d3 100644
--- a/test/files/jvm/xml03syntax.scala
+++ b/test/files/jvm/xml03syntax.scala
@@ -13,13 +13,18 @@ object Test {
import NodeSeq.view
import testing.UnitTest._
- val x0 = <hello>{}</hello>
- val x00 = <hello>{ }</hello>
+ val xNull = <hello>{null}</hello> // these used to be Atom(unit), changed to empty children
+
+ assertSameElements( xNull.child, Nil )
+
+ val x0 = <hello>{}</hello> // these used to be Atom(unit), changed to empty children
+ val x00 = <hello>{ }</hello> // dto.
+
val xa = <hello>{ "world" }</hello>
- assertEquals( handle[Unit](x0), {} )
- assertEquals( handle[Unit](x00), {} )
+ assertSameElements( x0.child, Nil )
+ assertSameElements( x00.child, Nil )
assertEquals( handle[String](xa),"world" )
val xb = <hello>{ 1.5 }</hello>