Skip to content

Commit 2106104

Browse files
committed
Add a test checking that Stream.from preserves laziness.
1 parent df77c9b commit 2106104

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/test/scala/collection/FactoryTest.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,12 @@ class FactoryTest {
2828
Assert.assertEquals(1, counter) // One element has been evaluated because Stream is not lazy in its head
2929
}
3030

31+
@Test
32+
def streamFromPreservesLaziness(): Unit = {
33+
var counter = 0
34+
val source = Stream.continually { counter += 1; 1 }
35+
val result = Stream.from(source)
36+
Assert.assertEquals(1, counter) // One element has been evaluated because Stream is not lazy in its head
37+
}
38+
3139
}

0 commit comments

Comments
 (0)