@@ -22,68 +22,68 @@ class LazyZipOpsTest {
22
22
private val sortedSet = TreeSet (1 , 2 , 3 )
23
23
24
24
@ Test
25
- def tuple2Zipped_map (): Unit = {
25
+ def lazyZip2_map (): Unit = {
26
26
val res : List [(Int , Int )] = zipped2.map((a, b) => (a, b))
27
27
28
28
assertEquals(List ((1 , 1 ), (2 , 2 ), (3 , 3 )), res)
29
29
}
30
30
31
31
@ Test
32
- def tuple2Zipped_flatMap (): Unit = {
32
+ def lazyZip2_flatMap (): Unit = {
33
33
val res : List [(Int , Int )] = zipped2.flatMap((a, b) => List ((a, b)))
34
34
35
35
assertEquals(List ((1 , 1 ), (2 , 2 ), (3 , 3 )), res)
36
36
}
37
37
38
38
@ Test
39
- def tuple2Zipped_filter (): Unit = {
39
+ def lazyZip2_filter (): Unit = {
40
40
val res : List [(Int , Int )] = zipped2.filter((a, _) => a % 2 == 0 )
41
41
42
42
assertEquals(List ((2 , 2 )), res)
43
43
}
44
44
45
45
@ Test
46
- def tuple2Zipped_exists (): Unit = {
46
+ def lazyZip2_exists (): Unit = {
47
47
assertTrue(zipped2.exists((a, b) => a + b > 5 ))
48
48
assertFalse(zipped2.exists((a, b) => a + b < 0 ))
49
49
}
50
50
51
51
@ Test
52
- def tuple2Zipped_forall (): Unit = {
52
+ def lazyZip2_forall (): Unit = {
53
53
assertTrue(zipped2.forall((a, b) => a + b > 0 ))
54
54
assertFalse(zipped2.forall((a, b) => a + b > 2 ))
55
55
}
56
56
57
57
@ Test
58
- def tuple2Zipped_foreach (): Unit = {
58
+ def lazyZip2_foreach (): Unit = {
59
59
var res = " "
60
60
zipped2.foreach((a, b) => res += s " [ $a, $b] " )
61
61
62
62
assertEquals(" [1,1][2,2][3,3]" , res)
63
63
}
64
64
65
65
@ Test
66
- def tuple2Zipped_toIterable (): Unit = {
66
+ def lazyZip2_toIterable (): Unit = {
67
67
val iter : Iterable [(Int , Int )] = zipped2
68
68
69
69
assertEquals(List ((1 , 1 ), (2 , 2 ), (3 , 3 )), iter.to(List ))
70
70
}
71
71
72
72
@ Test
73
- def tuple2Zipped_empty (): Unit = {
73
+ def lazyZip2_empty (): Unit = {
74
74
assertTrue(Nil .lazyZip(xs).isEmpty)
75
75
assertTrue(xs.lazyZip(Nil ).isEmpty)
76
76
}
77
77
78
78
@ Test
79
- def tuple2Zipped_withOrdering (): Unit = {
79
+ def lazyZip2_withOrdering (): Unit = {
80
80
val res : TreeSet [Int ] = sortedSet.lazyZip(ws).map(_ + _)
81
81
82
82
assertEquals(TreeSet (2 , 4 , 6 ), res)
83
83
}
84
84
85
85
@ Test
86
- def tuple2Zipped_withMap (): Unit = {
86
+ def lazyZip2_withMap (): Unit = {
87
87
val res : Map [Int , (String , String )] = map.lazyZip(ys).map { case ((k, v), s) => k -> (s, v) }
88
88
89
89
assertThat(res, either(
@@ -93,75 +93,75 @@ class LazyZipOpsTest {
93
93
}
94
94
95
95
@ Test
96
- def tuple2Zipped_withSortedMap (): Unit = {
96
+ def lazyZip2_withSortedMap (): Unit = {
97
97
val res : TreeMap [Int , (String , String )] = sortedMap.lazyZip(ys).map { case ((k, v), s) => k -> (s, v) }
98
98
99
99
assertEquals(Map (1 -> (" a" , " foo" ), 2 -> (" b" , " bar" )), res)
100
100
}
101
101
102
102
@ Test
103
- def tuple3Zipped_map (): Unit = {
103
+ def lazyZip3_map (): Unit = {
104
104
val res : List [(Int , Int , String )] = zipped3.map((a, b, c) => (a, b, c))
105
105
106
106
assertEquals(List ((1 , 1 , " a" ), (2 , 2 , " b" ), (3 , 3 , " c" )), res)
107
107
}
108
108
109
109
@ Test
110
- def tuple3Zipped_flatMap (): Unit = {
110
+ def lazyZip3_flatMap (): Unit = {
111
111
val res : List [(Int , Int , String )] = zipped3.flatMap((a, b, c) => List ((a, b, c)))
112
112
113
113
assertEquals(List ((1 , 1 , " a" ), (2 , 2 , " b" ), (3 , 3 , " c" )), res)
114
114
}
115
115
116
116
@ Test
117
- def tuple3Zipped_filter (): Unit = {
117
+ def lazyZip3_filter (): Unit = {
118
118
val res : List [(Int , Int , String )] = zipped3.filter((a, _, _) => a % 2 != 0 )
119
119
120
120
assertEquals(List ((1 , 1 , " a" ), (3 , 3 , " c" )), res)
121
121
}
122
122
123
123
@ Test
124
- def tuple3Zipped_exists (): Unit = {
124
+ def lazyZip3_exists (): Unit = {
125
125
assertTrue(zipped3.exists((a, b, _) => a + b > 5 ))
126
126
assertFalse(zipped3.exists((a, b, _) => a + b < 0 ))
127
127
}
128
128
129
129
@ Test
130
- def tuple3Zipped_forall (): Unit = {
130
+ def lazyZip3_forall (): Unit = {
131
131
assertTrue(zipped3.forall((a, b, _) => (a + b) % 2 == 0 ))
132
132
assertFalse(zipped3.forall((a, b, _) => a + b > 5 ))
133
133
}
134
134
135
135
@ Test
136
- def tuple3Zipped_foreach (): Unit = {
136
+ def lazyZip3_foreach (): Unit = {
137
137
var res = " "
138
138
zipped3.foreach((a, b, c) => res += s " [ $a, $b, $c] " )
139
139
140
140
assertEquals(" [1,1,a][2,2,b][3,3,c]" , res)
141
141
}
142
142
143
143
@ Test
144
- def tuple3Zipped_toIterable (): Unit = {
144
+ def lazyZip3_toIterable (): Unit = {
145
145
val iter : Iterable [(Int , Int , String )] = zipped3
146
146
147
147
assertEquals(List ((1 , 1 , " a" ), (2 , 2 , " b" ), (3 , 3 , " c" )), iter.to(List ))
148
148
}
149
149
150
150
@ Test
151
- def tuple3Zipped_empty (): Unit = {
151
+ def lazyZip3_empty (): Unit = {
152
152
assertTrue(zipped2.lazyZip(Nil ).isEmpty)
153
153
assertTrue(Nil .lazyZip(Nil ).lazyZip(xs).isEmpty)
154
154
}
155
155
156
156
@ Test
157
- def tuple3Zipped_withOrdering (): Unit = {
157
+ def lazyZip3_withOrdering (): Unit = {
158
158
val res : TreeSet [Int ] = sortedSet.lazyZip(xs).lazyZip(ws).map(_ + _ + _)
159
159
160
160
assertEquals(TreeSet (3 , 6 , 9 ), res)
161
161
}
162
162
163
163
@ Test
164
- def tuple3Zipped_withMap (): Unit = {
164
+ def lazyZip3_withMap (): Unit = {
165
165
val res : Map [Int , (Int , String , String )] = map.lazyZip(ws).lazyZip(ys).map { case ((k, v), w, y) => k -> (w, y, v) }
166
166
167
167
assertThat(res, either(
@@ -171,76 +171,76 @@ class LazyZipOpsTest {
171
171
}
172
172
173
173
@ Test
174
- def tuple3Zipped_withSortedMap (): Unit = {
174
+ def lazyZip3_withSortedMap (): Unit = {
175
175
val res : TreeMap [Int , (Int , String , String )] = sortedMap.lazyZip(ws).lazyZip(ys)
176
176
.map { case ((k, v), w, y) => k -> (w, y, v) }
177
177
178
178
assertEquals(Map (1 -> (1 , " a" , " foo" ), 2 -> (2 , " b" , " bar" )), res)
179
179
}
180
180
181
181
@ Test
182
- def tuple4Zipped_map (): Unit = {
182
+ def lazyZip4_map (): Unit = {
183
183
val res : List [(Int , Int , String , Boolean )] = zipped4.map((a, b, c, d) => (a, b, c, d))
184
184
185
185
assertEquals(List ((1 , 1 , " a" , true ), (2 , 2 , " b" , false ), (3 , 3 , " c" , true )), res)
186
186
}
187
187
188
188
@ Test
189
- def tuple4Zipped_flatMap (): Unit = {
189
+ def lazyZip4_flatMap (): Unit = {
190
190
val res : List [(Int , Int , String , Boolean )] = zipped4.flatMap((a, b, c, d) => List ((a, b, c, d)))
191
191
192
192
assertEquals(List ((1 , 1 , " a" , true ), (2 , 2 , " b" , false ), (3 , 3 , " c" , true )), res)
193
193
}
194
194
195
195
@ Test
196
- def tuple4Zipped_filter (): Unit = {
196
+ def lazyZip4_filter (): Unit = {
197
197
val res : List [(Int , Int , String , Boolean )] = zipped4.filter((_, _, _, d) => d)
198
198
199
199
assertEquals(List ((1 , 1 , " a" , true ), (3 , 3 , " c" , true )), res)
200
200
}
201
201
202
202
@ Test
203
- def tuple4Zipped_exists (): Unit = {
203
+ def lazyZip4_exists (): Unit = {
204
204
assertTrue(zipped4.exists((a, b, c, d) => a + b > 5 && ! c.isEmpty && d))
205
205
assertFalse(zipped4.exists((a, b, c, d) => a + b > 5 && ! c.isEmpty && ! d))
206
206
}
207
207
208
208
@ Test
209
- def tuple4Zipped_forall (): Unit = {
209
+ def lazyZip4_forall (): Unit = {
210
210
assertTrue(zipped4.forall((a, b, _, _) => (a + b) % 2 == 0 ))
211
211
assertFalse(zipped4.forall((a, b, _, d) => a + b > 0 && d))
212
212
}
213
213
214
214
@ Test
215
- def tuple4Zipped_foreach (): Unit = {
215
+ def lazyZip4_foreach (): Unit = {
216
216
var res = " "
217
217
zipped4.foreach((a, b, c, d) => res += s " [ $a, $b, $c, $d] " )
218
218
219
219
assertEquals(" [1,1,a,true][2,2,b,false][3,3,c,true]" , res)
220
220
}
221
221
222
222
@ Test
223
- def tuple4Zipped_toIterable (): Unit = {
223
+ def lazyZip4_toIterable (): Unit = {
224
224
val iter : Iterable [(Int , Int , String , Boolean )] = zipped4
225
225
226
226
assertEquals(List ((1 , 1 , " a" , true ), (2 , 2 , " b" , false ), (3 , 3 , " c" , true )), iter.to(List ))
227
227
}
228
228
229
229
@ Test
230
- def tuple4Zipped_empty (): Unit = {
230
+ def lazyZip4_empty (): Unit = {
231
231
assertTrue(zipped3.lazyZip(Nil ).isEmpty)
232
232
assertTrue(Nil .lazyZip(Nil ).lazyZip(Nil ).lazyZip(xs).isEmpty)
233
233
}
234
234
235
235
@ Test
236
- def tuple4Zipped_withOrdering (): Unit = {
236
+ def lazyZip4_withOrdering (): Unit = {
237
237
val res : TreeSet [Int ] = sortedSet.lazyZip(xs).lazyZip(ws).lazyZip(ws).map(_ + _ + _ + _)
238
238
239
239
assertEquals(TreeSet (4 , 8 , 12 ), res)
240
240
}
241
241
242
242
@ Test
243
- def tuple4Zipped_withMap (): Unit = {
243
+ def lazyZip4_withMap (): Unit = {
244
244
val res : Map [Int , (Int , Int , String , String )] = map.lazyZip(ws).lazyZip(xs).lazyZip(ys)
245
245
.map { case ((k, v), w, x, y) => k -> (w, x, y, v) }
246
246
@@ -251,7 +251,7 @@ class LazyZipOpsTest {
251
251
}
252
252
253
253
@ Test
254
- def tuple4Zipped_withSortedMap (): Unit = {
254
+ def lazyZip4_withSortedMap (): Unit = {
255
255
val res : TreeMap [Int , (Int , Int , String , String )] = sortedMap.lazyZip(ws).lazyZip(xs).lazyZip(ys)
256
256
.map { case ((k, v), w, x, y) => k -> (w, x, y, v) }
257
257
0 commit comments