Skip to content

Commit

Permalink
Add specs for Promise#zip/Promise.zip ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
ianks committed Jun 6, 2017
1 parent 041c1d1 commit 64009ad
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions spec/concurrent/promise_spec.rb
Expand Up @@ -368,6 +368,27 @@ def get_ivar_from_args(opts)

expect(composite).to be_rejected
end

it 'preserves ordering of the executed promises' do
promise1 = Promise.execute do
# resolves after the second promise
sleep 0.2
'one'
end

promise2 = Promise.execute do
sleep 0.1
'two'
end

promise3 = Promise.execute do
'three'
end

result = promise1.zip(promise2, promise3).value

expect(result).to eql(['one', 'two', 'three'])
end
end

describe '.zip' do
Expand All @@ -386,6 +407,27 @@ def get_ivar_from_args(opts)

expect(composite).to be_rejected
end

it 'preserves ordering of the executed promises' do
promise1 = Promise.execute do
# resolves after the second promise
sleep 0.2
'one'
end

promise2 = Promise.execute do
sleep 0.1
'two'
end

promise3 = Promise.execute do
'three'
end

result = Promise.zip(promise1, promise2, promise3).value

expect(result).to eql(['one', 'two', 'three'])
end
end

describe 'aggregators' do
Expand Down

0 comments on commit 64009ad

Please sign in to comment.