File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -141,10 +141,10 @@ def flat_map(&block)
141
141
#
142
142
# @return [Promise]
143
143
def zip ( *others )
144
- others . reduce ( self ) do |p1 , p2 |
145
- p1 . flat_map do |result1 |
146
- p2 . then do |result2 |
147
- [ result1 , result2 ] . flatten
144
+ others . reduce ( self . then { | x | [ x ] } ) do |p1 , p2 |
145
+ p1 . flat_map do |results |
146
+ p2 . then do |next_result |
147
+ results << next_result
148
148
end
149
149
end
150
150
end
Original file line number Diff line number Diff line change @@ -294,12 +294,12 @@ module Concurrent
294
294
describe '#zip' do
295
295
let ( :promise1 ) { Promise . new ( executor : executor ) { 1 } }
296
296
let ( :promise2 ) { Promise . new ( executor : executor ) { 2 } }
297
- let ( :promise3 ) { Promise . new ( executor : executor ) { 3 } }
297
+ let ( :promise3 ) { Promise . new ( executor : executor ) { [ 3 ] } }
298
298
299
299
it 'yields the results as an array' do
300
300
composite = promise1 . zip ( promise2 , promise3 ) . execute
301
301
sleep 0.1
302
- expect ( composite . value ) . to eq ( [ 1 , 2 , 3 ] )
302
+ expect ( composite . value ) . to eq ( [ 1 , 2 , [ 3 ] ] )
303
303
end
304
304
305
305
it 'fails if one component fails' do
You can’t perform that action at this time.
0 commit comments