summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2014-01-08 06:27:54 -0800
committerJason Zaugg <jzaugg@gmail.com>2014-01-08 06:27:54 -0800
commitd38a7663239ea4f4a5a0844d4e27b83f1883938c (patch)
treefb36b3f1ae999b94c64e6b1d1343c79b0c3e2601 /test
parentcafeb34d0480aa0abb088a4315fbe087d0769158 (diff)
parentfeebc7131c669b212e6a6ff73585a879baff2c48 (diff)
downloadscala-d38a7663239ea4f4a5a0844d4e27b83f1883938c.tar.gz
scala-d38a7663239ea4f4a5a0844d4e27b83f1883938c.tar.bz2
scala-d38a7663239ea4f4a5a0844d4e27b83f1883938c.zip
Merge pull request #3301 from Ichoran/issue/7837
Resolves SI-7837, failure in quickSort.
Diffstat (limited to 'test')
-rw-r--r--test/junit/scala/collection/ArraySortingTest.scala29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/junit/scala/collection/ArraySortingTest.scala b/test/junit/scala/collection/ArraySortingTest.scala
new file mode 100644
index 0000000000..4e54b39ce7
--- /dev/null
+++ b/test/junit/scala/collection/ArraySortingTest.scala
@@ -0,0 +1,29 @@
+package scala.collection.mutable
+
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+import org.junit.Test
+
+/* Tests various maps by making sure they all agree on the same answers. */
+@RunWith(classOf[JUnit4])
+class ArraySortingTest {
+
+ class CantSortMe(val i: Int) {
+ override def equals(a: Any) = throw new IllegalArgumentException("I cannot be equalled!")
+ }
+
+ object CanOrder extends Ordering[CantSortMe] {
+ def compare(a: CantSortMe, b: CantSortMe) = a.i compare b.i
+ }
+
+ // Tests SI-7837
+ @Test
+ def sortByTest() {
+ val test = Array(1,2,3,4,1,3,5,7,1,4,8,1,1,1,1)
+ val cant = test.map(i => new CantSortMe(i))
+ java.util.Arrays.sort(test)
+ scala.util.Sorting.quickSort(cant)(CanOrder)
+ assert( test(6) == 1 )
+ assert( (test,cant).zipped.forall(_ == _.i) )
+ }
+}