forked from arrow-kt/arrow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide test coverage for currying (arrow-kt#2894)
- Loading branch information
Showing
1 changed file
with
72 additions
and
0 deletions.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/CurryingTest.kt
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,72 @@ | ||
package arrow.core | ||
|
||
import io.kotest.core.spec.style.StringSpec | ||
import io.kotest.property.checkAll | ||
import io.kotest.matchers.shouldBe | ||
|
||
class CurryingTest : StringSpec({ | ||
|
||
"Result of calling a 2-arity curried function should be same as calling the uncurried function" { | ||
checkAll<Int, Int> { a1, a2 -> | ||
val add = { p1: Int, p2: Int -> p1 + p2 } | ||
add.curried()(a1)(a2) shouldBe a1 + a2 | ||
} | ||
} | ||
|
||
"Result of calling a 3-arity curried function should be same as calling the uncurried function" { | ||
checkAll<Int, Int, Int> { a1, a2, a3 -> | ||
val add = { p1: Int, p2: Int, p3: Int -> p1 + p2 + p3 } | ||
add.curried()(a1)(a2)(a3) shouldBe a1 + a2 + a3 | ||
} | ||
} | ||
|
||
"Result of calling a 4-arity curried function should be same as calling the uncurried function" { | ||
checkAll<Int, Int, Int, Int> { a1, a2, a3, a4 -> | ||
val add = { p1: Int, p2: Int, p3: Int, p4: Int -> p1 + p2 + p3 + p4 } | ||
add.curried()(a1)(a2)(a3)(a4) shouldBe a1 + a2 + a3 + a4 | ||
} | ||
} | ||
|
||
"Result of calling a 5-arity curried function should be same as calling the uncurried function" { | ||
checkAll<Int, Int, Int, Int, Int> { a1, a2, a3, a4, a5 -> | ||
val add = { p1: Int, p2: Int, p3: Int, p4: Int, p5: Int -> p1 + p2 + p3 + p4 + p5 } | ||
add.curried()(a1)(a2)(a3)(a4)(a5) shouldBe a1 + a2 + a3 + a4 + a5 | ||
} | ||
} | ||
|
||
"Result of calling a 6-arity curried function should be same as calling the uncurried function" { | ||
checkAll<Int, Int, Int, Int, Int, Int> { a1, a2, a3, a4, a5, a6 -> | ||
val add = { p1: Int, p2: Int, p3: Int, p4: Int, p5: Int, p6: Int -> p1 + p2 + p3 + p4 + p5 + p6 } | ||
add.curried()(a1)(a2)(a3)(a4)(a5)(a6) shouldBe a1 + a2 + a3 + a4 + a5 + a6 | ||
} | ||
} | ||
|
||
"Result of calling a 7-arity curried function should be same as calling the uncurried function" { | ||
checkAll<Int, Int, Int, Int, Int, Int, Int> { a1, a2, a3, a4, a5, a6, a7 -> | ||
val add = { p1: Int, p2: Int, p3: Int, p4: Int, p5: Int, p6: Int, p7: Int -> p1 + p2 + p3 + p4 + p5 + p6 + p7 } | ||
add.curried()(a1)(a2)(a3)(a4)(a5)(a6)(a7) shouldBe a1 + a2 + a3 + a4 + a5 + a6 + a7 | ||
} | ||
} | ||
|
||
"Result of calling a 8-arity curried function should be same as calling the uncurried function" { | ||
checkAll<Int, Int, Int, Int, Int, Int, Int, Int> { a1, a2, a3, a4, a5, a6, a7, a8 -> | ||
val add = { p1: Int, p2: Int, p3: Int, p4: Int, p5: Int, p6: Int, p7: Int, p8: Int -> p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8 } | ||
add.curried()(a1)(a2)(a3)(a4)(a5)(a6)(a7)(a8) shouldBe a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8 | ||
} | ||
} | ||
|
||
"Result of calling a 9-arity curried function should be same as calling the uncurried function" { | ||
checkAll<Int, Int, Int, Int, Int, Int, Int, Int, Int> { a1, a2, a3, a4, a5, a6, a7, a8, a9 -> | ||
val add = { p1: Int, p2: Int, p3: Int, p4: Int, p5: Int, p6: Int, p7: Int, p8: Int, p9: Int -> p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8 + p9 } | ||
add.curried()(a1)(a2)(a3)(a4)(a5)(a6)(a7)(a8)(a9) shouldBe a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8 + a9 | ||
} | ||
} | ||
|
||
"Result of calling a 10-arity curried function should be same as calling the uncurried function" { | ||
checkAll<Int, Int, Int, Int, Int, Int, Int, Int, Int, Int> { a1, a2, a3, a4, a5, a6, a7, a8, a9, a10-> | ||
val add = { p1: Int, p2: Int, p3: Int, p4: Int, p5: Int, p6: Int, p7: Int, p8: Int, p9: Int, p10: Int -> p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8 + p9 + p10 } | ||
add.curried()(a1)(a2)(a3)(a4)(a5)(a6)(a7)(a8)(a9)(a10) shouldBe a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8 + a9 + a10 | ||
} | ||
} | ||
|
||
}) |