From c0052870674b2f0c0310d4dbb0927023285e63c0 Mon Sep 17 00:00:00 2001 From: Simon Ochsenreither Date: Fri, 21 Jun 2013 18:31:11 +0200 Subject: 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. --- test/files/scalacheck/si4147.scala | 5 ++++- test/files/scalacheck/treeset.scala | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'test/files') 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]) } -- cgit v1.2.3