Skip to content

Commit

Permalink
Add forEach test
Browse files Browse the repository at this point in the history
  • Loading branch information
natsukagami committed Oct 10, 2023
1 parent adddeb8 commit e1a5d5c
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import java.util.concurrent._
import java.util.concurrent.LinkedTransferQueue
import scala.collection.mutable.ArrayBuffer
import scala.util.Using
import scala.compiletime.ops.boolean

class LinkedTransferQueueTest extends JSR166Test {
@Test def testConstructor1() = {
Expand Down Expand Up @@ -343,7 +342,7 @@ class LinkedTransferQueueTest extends JSR166Test {
/** An add following remove(x) succeeds
*/
@Test def testRemoveElementAndAdd() = {
val q = LinkedTransferQueue[Item]()
val q = new LinkedTransferQueue[Item]()
mustAdd(q, one)
mustAdd(q, two)
mustRemove(q, one)
Expand Down Expand Up @@ -698,8 +697,7 @@ class LinkedTransferQueueTest extends JSR166Test {
threadStarted.await()
val oneConsumer = new Callable[Boolean]() {
override def call() =
q.hasWaitingConsumer()
&& q.getWaitingConsumerCount() == 1
q.hasWaitingConsumer() && q.getWaitingConsumerCount() == 1

}
waitForThreadToEnterWaitState(t, oneConsumer)
Expand Down Expand Up @@ -1015,6 +1013,17 @@ class LinkedTransferQueueTest extends JSR166Test {
assertFalse(q.remove(null));
}
}

/* ==== Not from JSR166 ==== */
@Test def testForEach() = {
val q = new LinkedTransferQueue[Item]()
q.add(itemFor(one))
q.add(itemFor(two))

q.forEach { x =>
assertTrue(x == itemFor(one) || x == itemFor(two))
}
}
}

object LinkedTransferQueueTest {
Expand Down

0 comments on commit e1a5d5c

Please sign in to comment.