File tree Expand file tree Collapse file tree 2 files changed +13
-11
lines changed Expand file tree Collapse file tree 2 files changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -1284,7 +1284,7 @@ def evaluate_to(*args, &block)
1284
1284
# @return [self]
1285
1285
# @raise [Exception] also raise reason on rejection.
1286
1286
def evaluate_to! ( *args , &block )
1287
- promise . evaluate_to! ( *args , block )
1287
+ promise . evaluate_to ( *args , block ) . wait!
1288
1288
end
1289
1289
1290
1290
# Creates new future wrapping receiver, effectively hiding the resolve method and similar.
@@ -1343,8 +1343,8 @@ def resolve_with(new_state, raise_on_reassign = true)
1343
1343
def evaluate_to ( *args , block )
1344
1344
resolve_with Fulfilled . new ( block . call ( *args ) )
1345
1345
rescue Exception => error
1346
- # TODO (pitr-ch 30-Jul-2016): figure out what should be rescued, there is an issue about it
1347
1346
resolve_with Rejected . new ( error )
1347
+ raise error unless error . is_a? ( StandardError )
1348
1348
end
1349
1349
end
1350
1350
@@ -1368,10 +1368,6 @@ def reject(reason, raise_on_reassign)
1368
1368
end
1369
1369
1370
1370
public :evaluate_to
1371
-
1372
- def evaluate_to! ( *args , block )
1373
- evaluate_to ( *args , block ) . wait!
1374
- end
1375
1371
end
1376
1372
1377
1373
# @abstract
Original file line number Diff line number Diff line change @@ -448,11 +448,17 @@ def behaves_as_delay(delay, value)
448
448
end
449
449
450
450
it 'resolves future when Exception raised' do
451
- f = future { raise Exception , 'reject' }
452
- f . wait 1
453
- expect ( f ) . to be_resolved
454
- expect ( f ) . to be_rejected
455
- expect { f . value! } . to raise_error ( Exception , 'reject' )
451
+ message = 'reject by an Exception'
452
+ future = future { raise Exception , message }
453
+ expect ( future . wait ( 0.1 ) ) . to eq true
454
+ future . wait
455
+ expect ( future ) . to be_resolved
456
+ expect ( future ) . to be_rejected
457
+
458
+ expect ( future . reason ) . to be_instance_of Exception
459
+ expect ( future . result ) . to be_instance_of Array
460
+ expect ( future . value ) . to be_nil
461
+ expect { future . value! } . to raise_error ( Exception , message )
456
462
end
457
463
458
464
it 'runs' do
You can’t perform that action at this time.
0 commit comments