Skip to content

Commit 16a8afd

Browse files
committed
Fixed test issue due to non-unit return type
1 parent bce08ca commit 16a8afd

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

scala-core-modules/scala-core-fp/src/test/scala/com/baeldung/scala/currying/CurryingUnitTest.scala

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import org.scalatest.matchers.should.Matchers
66
class CurryingUnitTest extends Matchers {
77

88
@Test
9-
def givenMultipleArgumentsFunction_whenCurried_thenReturnCurriedFunction() = {
9+
def givenMultipleArgumentsFunction_whenCurried_thenReturnCurriedFunction()
10+
: Unit = {
1011
val sum: (Int, Int) => Int = (x, y) => x + y
1112
val curriedSum: Int => Int => Int = sum.curried
1213

@@ -15,7 +16,8 @@ class CurryingUnitTest extends Matchers {
1516
}
1617

1718
@Test
18-
def givenMultipleArgumentsMethod_whenCurried_thenReturnCurriedFunction() = {
19+
def givenMultipleArgumentsMethod_whenCurried_thenReturnCurriedFunction()
20+
: Unit = {
1921
def sum(x: Int, y: Int): Int = x + y
2022

2123
val curriedSum: Int => Int => Int = (sum _).curried
@@ -25,7 +27,8 @@ class CurryingUnitTest extends Matchers {
2527
}
2628

2729
@Test
28-
def givenMultipleArgumentListsMethod_whenCurried_thenReturnCurriedFunction() = {
30+
def givenMultipleArgumentListsMethod_whenCurried_thenReturnCurriedFunction()
31+
: Unit = {
2932
def sum(x: Int)(y: Int): Int = x + y
3033

3134
val curriedSum: Int => Int => Int = sum
@@ -35,15 +38,17 @@ class CurryingUnitTest extends Matchers {
3538
}
3639

3740
@Test
38-
def givenCurriedFunction_whenPartialApplied_thenReturnLowerArityFunction() = {
41+
def givenCurriedFunction_whenPartialApplied_thenReturnLowerArityFunction()
42+
: Unit = {
3943
val sum: Int => Int => Int = x => y => x + y
4044
val increment: Int => Int = sum(1)
4145

4246
increment(1) shouldBe 2
4347
}
4448

4549
@Test
46-
def givenMultipleArgumentListsMethod_whenPartialApplied_thenReturnLowerArityMethod() = {
50+
def givenMultipleArgumentListsMethod_whenPartialApplied_thenReturnLowerArityMethod()
51+
: Unit = {
4752
def sum(x: Int)(y: Int): Int = x + y
4853

4954
val increment: Int => Int = sum(1)
@@ -52,7 +57,8 @@ class CurryingUnitTest extends Matchers {
5257
}
5358

5459
@Test
55-
def givenMultipleArgumentsFindMethod_whenCalled_thenPredicateFunctionNeedsExplicitType() = {
60+
def givenMultipleArgumentsFindMethod_whenCalled_thenPredicateFunctionNeedsExplicitType()
61+
: Unit = {
5662
def find[A](xs: List[A], predicate: A => Boolean): Option[A] = {
5763
xs match {
5864
case Nil => None
@@ -65,7 +71,8 @@ class CurryingUnitTest extends Matchers {
6571
}
6672

6773
@Test
68-
def givenMultipleArgumentListFindMethod_whenCalled_thenPredicateFunctionDoesNotNeedExplicitType() = {
74+
def givenMultipleArgumentListFindMethod_whenCalled_thenPredicateFunctionDoesNotNeedExplicitType()
75+
: Unit = {
6976
def find[A](xs: List[A])(predicate: A => Boolean): Option[A] = {
7077
xs match {
7178
case Nil => None
@@ -78,7 +85,8 @@ class CurryingUnitTest extends Matchers {
7885
}
7986

8087
@Test
81-
def givenGenericMultipleArgumentListSumMethod_whenPartialApplied_thenReturnSimpleMethods() = {
88+
def givenGenericMultipleArgumentListSumMethod_whenPartialApplied_thenReturnSimpleMethods()
89+
: Unit = {
8290
def sumF(f: Int => Int)(x: Int, y: Int): Int = f(x) + f(y)
8391
val sum: (Int, Int) => Int = sumF(identity)
8492
val sumSquare: (Int, Int) => Int = sumF(x => x * x)
@@ -92,15 +100,17 @@ class CurryingUnitTest extends Matchers {
92100
}
93101

94102
@Test
95-
def givenMultipleArgumentsFunction_whenUseItAsOneArgumentFunction_thenNeedsExplicitArgumentPassing() = {
103+
def givenMultipleArgumentsFunction_whenUseItAsOneArgumentFunction_thenNeedsExplicitArgumentPassing()
104+
: Unit = {
96105
val sum: (Int, Int) => Int = (x, y) => x + y
97106
val numbers: List[Int] = List(1, 2, 3)
98107

99108
numbers.map(n => sum(1, n)) shouldBe List(2, 3, 4)
100109
}
101110

102111
@Test
103-
def givenCurriedFunction_whenUseItAsOneArgumentFunction_thenDoesNotNeedExplicitArgumentPassing() = {
112+
def givenCurriedFunction_whenUseItAsOneArgumentFunction_thenDoesNotNeedExplicitArgumentPassing()
113+
: Unit = {
104114
val curriedSum: Int => Int => Int = x => y => x + y
105115
val numbers: List[Int] = List(1, 2, 3)
106116

0 commit comments

Comments
 (0)