Skip to content

Commit 7872b6a

Browse files
author
Christopher Marshall
committed
Adds test that factories are reusable
1 parent 8cf1273 commit 7872b6a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

compat/src/test/scala/test/scala/collection/FactoryTest.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,20 @@ class FactoryTest {
4343
Assert.assertEquals(1, counter) // One element has been evaluated because Stream is not lazy in its head
4444
}
4545

46+
47+
@Test
48+
def factoriesAreReusable(): Unit = {
49+
def generically[M[X] <: Iterable[X]](in: M[Int], factory: Factory[Int, M[Int]]): Unit = {
50+
val l = Iterator(-3, -2, -1).to(factory)
51+
val m = in.iterator.to(factory)
52+
Assert.assertEquals(in, m)
53+
}
54+
55+
generically[List](List(1, 2, 3), List)
56+
generically[Seq](Seq(1, 2, 3), Seq)
57+
generically[IndexedSeq](IndexedSeq(1, 2, 3), IndexedSeq)
58+
generically[Vector](Vector(1, 2, 3), Vector)
59+
generically[Set](Set(1, 2, 3), Set)
60+
}
61+
4662
}

0 commit comments

Comments
 (0)