diff options
author | Simon Ochsenreither <simon@ochsenreither.de> | 2013-06-21 18:31:11 +0200 |
---|---|---|
committer | Simon Ochsenreither <simon@ochsenreither.de> | 2013-06-25 02:23:52 +0200 |
commit | c0052870674b2f0c0310d4dbb0927023285e63c0 (patch) | |
tree | f6f2ff0b1680b326094f9dfb27f2381b67a3bd9f /test | |
parent | 2a17db002758379fe0b9ee2a4e41ac9e3ca6c30d (diff) | |
download | scala-c0052870674b2f0c0310d4dbb0927023285e63c0.tar.gz scala-c0052870674b2f0c0310d4dbb0927023285e63c0.tar.bz2 scala-c0052870674b2f0c0310d4dbb0927023285e63c0.zip |
SI-7590 TreeSet should fail fast if Ordering is null
While migrating scala.tools.nsc.util.TreeSet to
scala.collection.mutable.TreeSet, I messed up initialization order
and realized that TreeSet accepts null as an Ordering and only fails
much later.
This change makes mutable.TreeSet and immutable.TreeSet fail
immediately.
Diffstat (limited to 'test')
-rw-r--r-- | test/files/scalacheck/si4147.scala | 5 | ||||
-rw-r--r-- | test/files/scalacheck/treeset.scala | 3 |
2 files changed, 7 insertions, 1 deletions
diff --git a/test/files/scalacheck/si4147.scala b/test/files/scalacheck/si4147.scala index 1453440ef1..05507b1b18 100644 --- a/test/files/scalacheck/si4147.scala +++ b/test/files/scalacheck/si4147.scala @@ -1,4 +1,4 @@ -import org.scalacheck.Prop.forAll +import org.scalacheck.Prop.{forAll, throws} import org.scalacheck.Properties import org.scalacheck.ConsoleReporter.testStatsEx import org.scalacheck.Gen @@ -64,4 +64,7 @@ object Test extends Properties("Mutable TreeSet") { view.filter(_ < 50) == Set[Int]() && view.filter(_ >= 150) == Set[Int]() } } + + property("ordering must not be null") = + throws(mutable.TreeSet.empty[Int](null), classOf[NullPointerException]) } diff --git a/test/files/scalacheck/treeset.scala b/test/files/scalacheck/treeset.scala index 98e38c8219..018c1b9e29 100644 --- a/test/files/scalacheck/treeset.scala +++ b/test/files/scalacheck/treeset.scala @@ -149,4 +149,7 @@ object Test extends Properties("TreeSet") { val result = subject.foldLeft(subject)((acc, elt) => acc - elt) result.isEmpty } + + property("ordering must not be null") = + throws(TreeSet.empty[Int](null), classOf[NullPointerException]) } |