-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ben Hutchison
committed
Jul 14, 2016
1 parent
579e0b4
commit e089220
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package cats | ||
package tests | ||
|
||
class ReducibleTestsAdditional extends CatsSuite { | ||
|
||
test("Reducible[NonEmptyList].reduceM stack safety") { | ||
def nonzero(acc: Long, x: Long): Option[Long] = | ||
if (x == 0) None else Some(acc + x) | ||
|
||
val n = 100000L | ||
val expected = n*(n+1)/2 | ||
(1L to n).toList.toNel.foreach { nel => | ||
val actual = nel.reduceM(Option.apply)(nonzero) | ||
assert(actual.get == expected) | ||
} | ||
} | ||
|
||
} | ||
|
||
|