File tree Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Original file line number Diff line number Diff line change 1
1
require 'promise'
2
2
3
- describe 'Promise#collect ' do
3
+ describe 'Promise#trace ' do
4
4
it 'calls the block with all the previous results' do
5
5
x = 42
6
6
7
- Promise . value ( 1 ) . then { 2 } . then { 3 } . collect { |a , b , c |
7
+ Promise . value ( 1 ) . then { 2 } . then { 3 } . trace { |a , b , c |
8
8
x = a + b + c
9
9
}
10
10
11
11
x . should == 6
12
12
end
13
13
14
- it 'calls the then after the collect ' do
14
+ it 'calls the then after the trace ' do
15
15
x = 42
16
16
17
- Promise . value ( 1 ) . then { 2 } . then { 3 } . collect { |a , b , c |
17
+ Promise . value ( 1 ) . then { 2 } . then { 3 } . trace { |a , b , c |
18
18
a + b + c
19
19
} . then { |v | x = v }
20
20
26
26
27
27
Promise . value ( 1 ) . then {
28
28
Promise . when Promise . value ( 2 ) , Promise . value ( 3 )
29
- } . collect { |a , b |
29
+ } . trace { |a , b |
30
30
x = a + b [ 0 ] + b [ 1 ]
31
31
}
32
32
Original file line number Diff line number Diff line change @@ -174,8 +174,8 @@ def always(&block)
174
174
alias finally always
175
175
alias ensure always
176
176
177
- def collect ( &block )
178
- self ^ Collect . new ( block )
177
+ def trace ( &block )
178
+ self ^ Trace . new ( block )
179
179
end
180
180
181
181
def inspect
@@ -194,7 +194,7 @@ def inspect
194
194
result
195
195
end
196
196
197
- class Collect < self
197
+ class Trace < self
198
198
def self . it ( promise )
199
199
unless promise . realized?
200
200
raise ArgumentError , "the promise hasn't been realized"
@@ -211,7 +211,7 @@ def self.it(promise)
211
211
212
212
def initialize ( block )
213
213
super -> {
214
- block . call ( *Collect . it ( self ) . reverse )
214
+ block . call ( *Trace . it ( self ) . reverse )
215
215
}
216
216
end
217
217
end
You can’t perform that action at this time.
0 commit comments