Skip to content

Commit 83fb22a

Browse files
committed
more testing
1 parent 3591652 commit 83fb22a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/test/scala/scala/collection/immutable/TestLazyListExtensions.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,14 @@ class TestLazyListExtensions {
107107
val cyc = xs.cycle
108108
assertEquals(LazyList(1, 2, 3), cyc.take(3))
109109
}
110+
@Test
111+
def testSecondCallIsSafeButNotIdempotent(): Unit = {
112+
val xs = LazyList(1, 2, 3)
113+
// this is safe to do
114+
val twice = xs.cycle.cycle
115+
// and the contents are as expected
116+
assertEquals(LazyList(1, 2, 3, 1, 2, 3, 1, 2), twice.take(8))
117+
// but the result is not a cycle. TODO do we care?
118+
assertFalse(twice.tail eq twice.tail.tail.tail.tail)
119+
}
110120
}

0 commit comments

Comments
 (0)