@@ -349,7 +349,6 @@ def behaves_as_delay(delay, value)
349349 end
350350 end
351351
352-
353352 it 'chains' do
354353 future0 = future { 1 } . then { |v | v + 2 } # both executed on default FAST_EXECUTOR
355354 future1 = future0 . then_on ( :fast ) { raise 'boo' } # executed on IO_EXECUTOR
@@ -490,22 +489,28 @@ def behaves_as_delay(delay, value)
490489 end
491490
492491 it 'can be risen when rejected' do
492+ strip_methods = -> backtrace do
493+ backtrace . map do |line |
494+ /^.*:\d +:in/ . match ( line ) [ 0 ] rescue line
495+ end
496+ end
497+
493498 future = rejected_future TypeError . new
494- backtrace = caller ; exception = raise future rescue $!
499+ backtrace = caller ; exception = ( raise future rescue $!)
495500 expect ( exception ) . to be_a TypeError
496- expect ( exception . backtrace [ 2 ..- 1 ] ) . to eq backtrace
501+ expect ( strip_methods [ backtrace ] - strip_methods [ exception . backtrace ] ) . to be_empty
497502
498503 exception = TypeError . new
499504 exception . set_backtrace ( first_backtrace = %W[ /a /b /c ] )
500505 future = rejected_future exception
501- backtrace = caller ; exception = raise future rescue $!
506+ backtrace = caller ; exception = ( raise future rescue $!)
502507 expect ( exception ) . to be_a TypeError
503- expect ( exception . backtrace - exception . backtrace [ 3 .. 4 ] ) . to eq ( first_backtrace + backtrace )
508+ expect ( strip_methods [ first_backtrace + backtrace ] - strip_methods [ exception . backtrace ] ) . to be_empty
504509
505510 future = rejected_future ( TypeError . new ) & rejected_future ( TypeError . new )
506- backtrace = caller ; exception = raise future rescue $!
511+ backtrace = caller ; exception = ( raise future rescue $!)
507512 expect ( exception ) . to be_a Concurrent ::MultipleErrors
508- expect ( exception . backtrace [ 2 ..- 1 ] ) . to eq backtrace
513+ expect ( strip_methods [ backtrace ] - strip_methods [ exception . backtrace ] ) . to be_empty
509514 end
510515 end
511516
0 commit comments