Skip to content

Commit

Permalink
Add a test checking that Stream.from preserves laziness.
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrf committed Apr 18, 2018
1 parent df77c9b commit 2106104
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/test/scala/collection/FactoryTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,12 @@ class FactoryTest {
Assert.assertEquals(1, counter) // One element has been evaluated because Stream is not lazy in its head
}

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

}

0 comments on commit 2106104

Please sign in to comment.