Skip to content

Commit

Permalink
Testing for comps
Browse files Browse the repository at this point in the history
  • Loading branch information
deusaquilus committed Mar 18, 2024
1 parent ead7480 commit 24c7578
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion decomat-core/src/test/kotlin/io/decomat/ThenTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class ThenTest: DecomatTest {
)

@Test
fun `Then1 - distinct(distinct(Is)) - thenThis`() =
fun `Then1 - distinct(distinct(Is)) - comps`() =
assert(
case(Distinct_M(Distinct_M(Is<Entity>()))).then { _ -> Res1(compInner) }.eval(Distinct(Distinct(foo))) == Res1(Distinct(foo)) // conv
)
Expand Down Expand Up @@ -101,18 +101,36 @@ public class ThenTest: DecomatTest {
case(FlatMap_M(Is(), Distinct_M(Is()))).then { a, (b) -> Res2(a, b) }.eval(FlatMap(foo, Distinct(bar))) == Res2(foo, bar)
)

@Test
fun `Then01 - flatMap(Is, Distinct) - compRight`() =
assert(
case(FlatMap_M(Is(), Distinct_M(Is()))).then { a, (b) -> Res2(comp, compRight) }.eval(FlatMap(foo, Distinct(bar))) == Res2(FlatMap(foo, Distinct(bar)), Distinct(bar))
)

@Test
fun `Then02 - flatMap(Is, Map)`() =
assert(
case(FlatMap_M(Is(), Map_M(Is(), Is()))).then { a, (b1, b2) -> Res3(a, b1, b2) }.eval(FlatMap(foo, Map(bar, baz))) == Res3(foo, bar, baz)
)

@Test
fun `Then02 - flatMap(Is, Map) - comp`() =
assert(
case(FlatMap_M(Is(), Map_M(Is(), Is()))).then { a, (b1, b2) -> Res2(comp, compRight) }.eval(FlatMap(foo, Map(bar, baz))) == Res2(FlatMap(foo, Map(bar, baz)), Map(bar, baz))
)

@Test
fun `Then10 - flatMap(Distinct, Is)`() =
assert(
case(FlatMap_M(Distinct_M(Is()), Is())).then { (a), b -> Res2(a, b) }.eval(FlatMap(Distinct(foo), bar)) == Res2(foo, bar)
)

@Test
fun `Then10 - flatMap(Distinct, Is) - compLeft`() =
assert(
case(FlatMap_M(Distinct_M(Is()), Is())).then { (a), b -> Res2(compLeft, comp) }.eval(FlatMap(Distinct(foo), bar)) == Res2(Distinct(foo), FlatMap(Distinct(foo), bar))
)

@Test
fun `Then11 - flatMap(Distinct, Distinct)`() =
assert(
Expand All @@ -131,6 +149,12 @@ public class ThenTest: DecomatTest {
case(FlatMap_M(Map_M(Is(), Is()), Is())).then { (a1, a2), b -> Res3(a1, a2, b) }.eval(FlatMap(Map(foo, bar), baz)) == Res3(foo, bar, baz)
)

@Test
fun `Then20 - flatMap(Map, Is) - compLeft`() =
assert(
case(FlatMap_M(Map_M(Is(), Is()), Is())).then { (a1, a2), b -> Res2(compLeft, comp) }.eval(FlatMap(Map(foo, bar), baz)) == Res2(Map(foo, bar), FlatMap(Map(foo, bar), baz))
)

@Test
fun `Then21 - flatMap(Map, Distinct)`() =
assert(
Expand All @@ -142,4 +166,10 @@ public class ThenTest: DecomatTest {
assert(
case(FlatMap_M(Map_M(Is(), Is()), Map_M(Is(), Is()))).then { (a1, a2), (b1, b2) -> Res4(a1, a2, b1, b2) }.eval(FlatMap(Map(foo, bar), Map(baz, waz))) == Res4(foo, bar, baz, waz)
)

@Test
fun `Then22 - flatMap(Map, Map) - comp`() =
assert(
case(FlatMap_M(Map_M(Is(), Is()), Map_M(Is(), Is()))).then { (a1, a2), (b1, b2) -> Res3(compLeft, compRight, comp) }.eval(FlatMap(Map(foo, bar), Map(baz, waz))) == Res3(Map(foo, bar), Map(baz, waz), FlatMap(Map(foo, bar), Map(baz, waz)))
)
}

0 comments on commit 24c7578

Please sign in to comment.