totally_lazy 0.1.36 → 0.1.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/lib/totally_lazy/sequence.rb +6 -0
- data/spec/totally_lazy/sequence_spec.rb +26 -22
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NzgwYzZmMGQ0YzA0OGNkZTdmN2JkYzFkNTgxODIzYTVjODUxNjhiYw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ODdlYWJlMmFjYjc2MDY2NGU3OWIzMTdiYjNmMWM5ZTJjNWMyYzUwZA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YTBhODEzNmM0OTFiMGNiZDIyMjg2OGFjNzBmMTUwOThlMjYxNWYxZDFjYWMx
|
10
|
+
YjE3ZWMyNjA0NDE5OTQwMTg4Y2RhOWEwZTVkMjM2ODY4YjM0MGIzMmU2NmEw
|
11
|
+
MjI0YmNjYWQzOTU0ZjY0OTZhYWNiNDliNTYyMWYwZTIxMjEzYzE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MTAwYjk2YjAzMmU0ZWE4NmRjN2Y0OTdkYTMwOTgyY2IxM2I5NTBhNjM2ODY5
|
14
|
+
NjU0Zjc4NDNmY2Q0YWUxZjgzMmQ5MDg3YmUyYzVkYTZjY2I0OTU2MjMzODg0
|
15
|
+
OWJkNDZlZmJjNmVjMWNlZWY4ZTM1MzM4YzAwMDM3ZWNjOTM5OGM=
|
@@ -205,28 +205,6 @@ describe 'Sequence' do
|
|
205
205
|
expect(sequence(some(1), none, some(2)).flat_map { |s| s }).to eq(sequence(1, 2))
|
206
206
|
end
|
207
207
|
|
208
|
-
it 'should raise exception if you try to use both lambda and block' do
|
209
|
-
expect { empty.map(->(a) { a+1 }) { |b| b+2 } }.to raise_error(RuntimeError)
|
210
|
-
expect { empty.map_concurrently(->(a) { a+1 }) { |b| b+2 } }.to raise_error(RuntimeError)
|
211
|
-
expect { empty.flat_map(->(a) { a+1 }) { |b| b+2 } }.to raise_error(RuntimeError)
|
212
|
-
expect { empty.fold(0, ->(a, b) { a+b }) { |a, b| a+b } }.to raise_error(RuntimeError)
|
213
|
-
expect { empty.fold_left(0, ->(a, b) { a+b }) { |a, b| a+b } }.to raise_error(RuntimeError)
|
214
|
-
expect { empty.fold_right(0, ->(a, b) { a+b }) { |a, b| a+b } }.to raise_error(RuntimeError)
|
215
|
-
expect { empty.reduce(->(a, b) { a+b }) { |a, b| a+b } }.to raise_error(RuntimeError)
|
216
|
-
expect { empty.reduce_left(->(a, b) { a+b }) { |a, b| a+b } }.to raise_error(RuntimeError)
|
217
|
-
expect { empty.reduce_right(->(a, b) { a+b }) { |a, b| a+b } }.to raise_error(RuntimeError)
|
218
|
-
expect { empty.find(->(_) { true }) { |_| true } }.to raise_error(RuntimeError)
|
219
|
-
expect { empty.find_index_of(->(_) { true }) { |_| true } }.to raise_error(RuntimeError)
|
220
|
-
expect { empty.take_while(->(_) { true }) { |_| true } }.to raise_error(RuntimeError)
|
221
|
-
expect { empty.drop_while(->(_) { true }) { |_| true } }.to raise_error(RuntimeError)
|
222
|
-
expect { empty.exists?(->(_) { true }) { |_| true } }.to raise_error(RuntimeError)
|
223
|
-
expect { empty.for_all?(->(_) { true }) { |_| true } }.to raise_error(RuntimeError)
|
224
|
-
expect { empty.filter(->(_) { true }) { |_| true } }.to raise_error(RuntimeError)
|
225
|
-
expect { empty.reject(->(_) { true }) { |_| true } }.to raise_error(RuntimeError)
|
226
|
-
expect { empty.group_by(->(_) { true }) { |_| true } }.to raise_error(RuntimeError)
|
227
|
-
expect { empty.each(->(v) { puts(v) }) { |v| puts(v) } }.to raise_error(RuntimeError)
|
228
|
-
end
|
229
|
-
|
230
208
|
it 'should support flatten' do
|
231
209
|
expect(sequence('Hello').map(to_characters).flatten).to eq(sequence('H', 'e', 'l', 'l', 'o'))
|
232
210
|
expect(sequence(some(1), none, some(3)).flatten).to eq(sequence(1, 3))
|
@@ -301,4 +279,30 @@ describe 'Sequence' do
|
|
301
279
|
strings_block = sequence(1, 2).map_concurrently { |value| to_string.(value) }
|
302
280
|
expect(strings_block).to eq(sequence('1', '2'))
|
303
281
|
end
|
282
|
+
|
283
|
+
it 'should allow arrays to be converted to sequences' do
|
284
|
+
expect([1,2,3,4,5].to_seq).to eq(sequence(1,2,3,4,5))
|
285
|
+
end
|
286
|
+
|
287
|
+
it 'should raise exception if you try to use both lambda and block' do
|
288
|
+
expect { empty.map(->(a) { a+1 }) { |b| b+2 } }.to raise_error(RuntimeError)
|
289
|
+
expect { empty.map_concurrently(->(a) { a+1 }) { |b| b+2 } }.to raise_error(RuntimeError)
|
290
|
+
expect { empty.flat_map(->(a) { a+1 }) { |b| b+2 } }.to raise_error(RuntimeError)
|
291
|
+
expect { empty.fold(0, ->(a, b) { a+b }) { |a, b| a+b } }.to raise_error(RuntimeError)
|
292
|
+
expect { empty.fold_left(0, ->(a, b) { a+b }) { |a, b| a+b } }.to raise_error(RuntimeError)
|
293
|
+
expect { empty.fold_right(0, ->(a, b) { a+b }) { |a, b| a+b } }.to raise_error(RuntimeError)
|
294
|
+
expect { empty.reduce(->(a, b) { a+b }) { |a, b| a+b } }.to raise_error(RuntimeError)
|
295
|
+
expect { empty.reduce_left(->(a, b) { a+b }) { |a, b| a+b } }.to raise_error(RuntimeError)
|
296
|
+
expect { empty.reduce_right(->(a, b) { a+b }) { |a, b| a+b } }.to raise_error(RuntimeError)
|
297
|
+
expect { empty.find(->(_) { true }) { |_| true } }.to raise_error(RuntimeError)
|
298
|
+
expect { empty.find_index_of(->(_) { true }) { |_| true } }.to raise_error(RuntimeError)
|
299
|
+
expect { empty.take_while(->(_) { true }) { |_| true } }.to raise_error(RuntimeError)
|
300
|
+
expect { empty.drop_while(->(_) { true }) { |_| true } }.to raise_error(RuntimeError)
|
301
|
+
expect { empty.exists?(->(_) { true }) { |_| true } }.to raise_error(RuntimeError)
|
302
|
+
expect { empty.for_all?(->(_) { true }) { |_| true } }.to raise_error(RuntimeError)
|
303
|
+
expect { empty.filter(->(_) { true }) { |_| true } }.to raise_error(RuntimeError)
|
304
|
+
expect { empty.reject(->(_) { true }) { |_| true } }.to raise_error(RuntimeError)
|
305
|
+
expect { empty.group_by(->(_) { true }) { |_| true } }.to raise_error(RuntimeError)
|
306
|
+
expect { empty.each(->(v) { puts(v) }) { |v| puts(v) } }.to raise_error(RuntimeError)
|
307
|
+
end
|
304
308
|
end
|