Skip to content

Commit

Permalink
FreeFoldable: del foldLeft, foldRight stack tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aaron levin committed Aug 24, 2017
1 parent c159b88 commit e92ce5f
Showing 1 changed file with 0 additions and 20 deletions.
20 changes: 0 additions & 20 deletions free/src/test/scala/cats/free/FreeTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -95,26 +95,6 @@ class FreeTests extends CatsSuite {
assert(10000 == a(0).foldMap(runner))
}

test("foldRight is stack safe") {
val instance = Free.catsFreeFoldableForFree[Option]
val n = 50000
val freeOption: Int => Free[Option, Int] = x => Free.pure(x)
val free = (1 to n).foldLeft(freeOption(0))((r, _) => r.flatMap(n => freeOption(n + 1)))
val result = instance.foldRight(free, Eval.now(0))((a, lb) => lb.map(_ + a)).value

assert(n == result)
}

test("foldLeft is stack safe") {
val instance = Free.catsFreeFoldableForFree[Option]
val n = 50000
val freeOption: Int => Free[Option, Int] = x => Free.pure(x)
val free = (1 to n).foldLeft(freeOption(0))((r, _) => r.flatMap(n => freeOption(n + 1)))
val result = instance.foldLeft(free, 0)(_ + _)

assert(n == result)
}

test(".runTailRec") {
val r = Free.pure[List, Int](12358)
def recurse(r: Free[List, Int], n: Int): Free[List, Int] =
Expand Down

0 comments on commit e92ce5f

Please sign in to comment.