You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The ScalaDoc for Streaming.thunk says that the thunk may not be pure. However, it doesn't seem to support this use-case. In the following example, I would expect the output to be List(1, 2, 3, 4), but it is List(1, 1, 1, 1).
test("thunk is evaluated for each item") {
// don't want the stream to be too bigimplicitvalarbInt=Arbitrary(Gen.choose(-10, 20))
forAll { (start: Int, end: Int) =>vari= start -1valstream=Streaming.thunk{ () => i +=1; i}.takeWhile(_ <= end)
stream.toList should === ((start to end).toList)
}
}
The text was updated successfully, but these errors were encountered:
ceedubs
added a commit
to ceedubs/cats
that referenced
this issue
Nov 19, 2015
The .thunk method is not supposed to memoize the results,
allowing the caller to provide an impure function which
returns different values on different calls.
However, .thunk's definition used .knot with memoization,
which completely defeated the point. This commit removes
the memoization allowing this method to function correctly.
Fixes#677.
The ScalaDoc for
Streaming.thunk
says that the thunk may not be pure. However, it doesn't seem to support this use-case. In the following example, I would expect the output to beList(1, 2, 3, 4)
, but it isList(1, 1, 1, 1)
.Here is a test that helped me catch this:
The text was updated successfully, but these errors were encountered: