From e8e504c0f27d3d594625c9101e5f4fab9b38865e Mon Sep 17 00:00:00 2001 From: Aleksandar Pokopec Date: Sun, 22 Nov 2009 22:47:08 +0000 Subject: Priority queue reverse is undefined - overriden... Priority queue reverse is undefined - overriden to throw an exception. Reverse iterator seems to have sense - it is overriden and is defined, and some methods in SeqLike are implemented in terms of it. --- test/files/run/priorityQueue.scala | 40 ++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) (limited to 'test/files/run') diff --git a/test/files/run/priorityQueue.scala b/test/files/run/priorityQueue.scala index e582448342..54090091ec 100644 --- a/test/files/run/priorityQueue.scala +++ b/test/files/run/priorityQueue.scala @@ -21,7 +21,7 @@ object Test { testDrops testUpdates testEquality - testSeq + testMisc } def testInsertionsAndEqualities { @@ -232,9 +232,10 @@ object Test { assertPriorityDestructive(pq2) } - def testSeq { + def testMisc { val pq = new PriorityQueue[Int] pq ++= (0 until 100) + assert(pq.size == 100) val (p1, p2) = pq.partition(_ < 50) assertPriorityDestructive(p1) @@ -246,14 +247,33 @@ object Test { pq.clear pq ++= (0 until 10) pq += 5 - //val ind = pq.lastIndexWhere(_ == 5) - //println(ind) - //println(pq) - //assert(ind == 5) - //assertPriorityDestructive(pq) - - //pq.clear - //pq ++= (0 until 10) + assert(pq.size == 11) + + val ind = pq.lastIndexWhere(_ == 5) + assert(ind == 5) + assertPriorityDestructive(pq) + + pq.clear + pq ++= (0 until 10) + assert(pq.lastIndexWhere(_ == 9) == 0) + assert(pq.lastIndexOf(8) == 1) + assert(pq.lastIndexOf(7) == 2) + + pq += 5 + pq += 9 + assert(pq.lastIndexOf(9) == 1) + assert(pq.lastIndexWhere(_ % 2 == 1) == 10) + assert(pq.lastIndexOf(5) == 6) + + val lst = pq.reverseIterator.toList + for (i <- 0 until 5) assert(lst(i) == i) + assert(lst(5) == 5) + assert(lst(6) == 5) + assert(lst(7) == 6) + assert(lst(8) == 7) + assert(lst(9) == 8) + assert(lst(10) == 9) + assert(lst(11) == 9) } } -- cgit v1.2.3