Skip to content

Commit

Permalink
Add test for Foldable[Stream].foldRight stack safety
Browse files Browse the repository at this point in the history
Resolves typelevel#828. I can't reproduce the behavior that I reported in that
issue. I'm not sure why I had trouble at first - maybe I was using
`Stream.foldRight` instead of `Foldable[Stream].foldRight`? I don't
think I was though, so this is a bit odd to me.
  • Loading branch information
ceedubs committed Jan 30, 2016
1 parent 9780e8f commit e080f36
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/src/test/scala/cats/tests/StreamTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,13 @@ class StreamTests extends CatsSuite {
}
}
}

test("Foldable[Stream].foldRight is stack-safe for long streams"){
val s: Stream[Boolean] = Stream.fill(100000)(true) ++ Stream.continually(false)

val x = Foldable[Stream].foldRight(s, Eval.now(true))((a,b) =>
if (a) b else Eval.now(false))

x.value should === (false)
}
}

0 comments on commit e080f36

Please sign in to comment.