@@ -6,7 +6,8 @@ import org.scalatest.matchers.should.Matchers
6
6
class CurryingUnitTest extends Matchers {
7
7
8
8
@ Test
9
- def givenMultipleArgumentsFunction_whenCurried_thenReturnCurriedFunction () = {
9
+ def givenMultipleArgumentsFunction_whenCurried_thenReturnCurriedFunction ()
10
+ : Unit = {
10
11
val sum : (Int , Int ) => Int = (x, y) => x + y
11
12
val curriedSum : Int => Int => Int = sum.curried
12
13
@@ -15,7 +16,8 @@ class CurryingUnitTest extends Matchers {
15
16
}
16
17
17
18
@ Test
18
- def givenMultipleArgumentsMethod_whenCurried_thenReturnCurriedFunction () = {
19
+ def givenMultipleArgumentsMethod_whenCurried_thenReturnCurriedFunction ()
20
+ : Unit = {
19
21
def sum (x : Int , y : Int ): Int = x + y
20
22
21
23
val curriedSum : Int => Int => Int = (sum _).curried
@@ -25,7 +27,8 @@ class CurryingUnitTest extends Matchers {
25
27
}
26
28
27
29
@ Test
28
- def givenMultipleArgumentListsMethod_whenCurried_thenReturnCurriedFunction () = {
30
+ def givenMultipleArgumentListsMethod_whenCurried_thenReturnCurriedFunction ()
31
+ : Unit = {
29
32
def sum (x : Int )(y : Int ): Int = x + y
30
33
31
34
val curriedSum : Int => Int => Int = sum
@@ -35,15 +38,17 @@ class CurryingUnitTest extends Matchers {
35
38
}
36
39
37
40
@ Test
38
- def givenCurriedFunction_whenPartialApplied_thenReturnLowerArityFunction () = {
41
+ def givenCurriedFunction_whenPartialApplied_thenReturnLowerArityFunction ()
42
+ : Unit = {
39
43
val sum : Int => Int => Int = x => y => x + y
40
44
val increment : Int => Int = sum(1 )
41
45
42
46
increment(1 ) shouldBe 2
43
47
}
44
48
45
49
@ Test
46
- def givenMultipleArgumentListsMethod_whenPartialApplied_thenReturnLowerArityMethod () = {
50
+ def givenMultipleArgumentListsMethod_whenPartialApplied_thenReturnLowerArityMethod ()
51
+ : Unit = {
47
52
def sum (x : Int )(y : Int ): Int = x + y
48
53
49
54
val increment : Int => Int = sum(1 )
@@ -52,7 +57,8 @@ class CurryingUnitTest extends Matchers {
52
57
}
53
58
54
59
@ Test
55
- def givenMultipleArgumentsFindMethod_whenCalled_thenPredicateFunctionNeedsExplicitType () = {
60
+ def givenMultipleArgumentsFindMethod_whenCalled_thenPredicateFunctionNeedsExplicitType ()
61
+ : Unit = {
56
62
def find [A ](xs : List [A ], predicate : A => Boolean ): Option [A ] = {
57
63
xs match {
58
64
case Nil => None
@@ -65,7 +71,8 @@ class CurryingUnitTest extends Matchers {
65
71
}
66
72
67
73
@ Test
68
- def givenMultipleArgumentListFindMethod_whenCalled_thenPredicateFunctionDoesNotNeedExplicitType () = {
74
+ def givenMultipleArgumentListFindMethod_whenCalled_thenPredicateFunctionDoesNotNeedExplicitType ()
75
+ : Unit = {
69
76
def find [A ](xs : List [A ])(predicate : A => Boolean ): Option [A ] = {
70
77
xs match {
71
78
case Nil => None
@@ -78,7 +85,8 @@ class CurryingUnitTest extends Matchers {
78
85
}
79
86
80
87
@ Test
81
- def givenGenericMultipleArgumentListSumMethod_whenPartialApplied_thenReturnSimpleMethods () = {
88
+ def givenGenericMultipleArgumentListSumMethod_whenPartialApplied_thenReturnSimpleMethods ()
89
+ : Unit = {
82
90
def sumF (f : Int => Int )(x : Int , y : Int ): Int = f(x) + f(y)
83
91
val sum : (Int , Int ) => Int = sumF(identity)
84
92
val sumSquare : (Int , Int ) => Int = sumF(x => x * x)
@@ -92,15 +100,17 @@ class CurryingUnitTest extends Matchers {
92
100
}
93
101
94
102
@ Test
95
- def givenMultipleArgumentsFunction_whenUseItAsOneArgumentFunction_thenNeedsExplicitArgumentPassing () = {
103
+ def givenMultipleArgumentsFunction_whenUseItAsOneArgumentFunction_thenNeedsExplicitArgumentPassing ()
104
+ : Unit = {
96
105
val sum : (Int , Int ) => Int = (x, y) => x + y
97
106
val numbers : List [Int ] = List (1 , 2 , 3 )
98
107
99
108
numbers.map(n => sum(1 , n)) shouldBe List (2 , 3 , 4 )
100
109
}
101
110
102
111
@ Test
103
- def givenCurriedFunction_whenUseItAsOneArgumentFunction_thenDoesNotNeedExplicitArgumentPassing () = {
112
+ def givenCurriedFunction_whenUseItAsOneArgumentFunction_thenDoesNotNeedExplicitArgumentPassing ()
113
+ : Unit = {
104
114
val curriedSum : Int => Int => Int = x => y => x + y
105
115
val numbers : List [Int ] = List (1 , 2 , 3 )
106
116
0 commit comments