Skip to content

Commit

Permalink
fix test code for exception
Browse files Browse the repository at this point in the history
  • Loading branch information
m11o committed Feb 9, 2021
1 parent 396306c commit 083beb9
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions test/stdlib/Timeout_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ def test_timeout
Timeout, :timeout, BigDecimal("1.123456789123456789"), &proc

hard_process = Proc.new { _calc_pi }
refute_send_type "(::Numeric sec): [T] { (::Numeric sec) -> T } -> T",
Timeout, :timeout, 0.001, &hard_process
refute_send_type "(::Numeric sec, singleton(Exception) klass): [T] { (::Numeric sec) -> T } -> T",
Timeout, :timeout, 0.001, TimeoutTestException, &hard_process
refute_send_type "(::Numeric sec, singleton(Exception) klass, String message): [T] { (::Numeric sec) -> T } -> T",
Timeout, :timeout, 0.001, TimeoutTestException, "timeout test error", &hard_process
exception = assert_raises(Timeout::Error) { Timeout.timeout 0.001, &hard_process }
assert_equal "execution expired", exception.message

exception = assert_raises(TimeoutTestException) { Timeout.timeout 0.001, TimeoutTestException, &hard_process }
assert_equal "execution expired", exception.message

exception = assert_raises(TimeoutTestException) { Timeout.timeout 0.001, TimeoutTestException, "timeout test error", &hard_process }
assert_equal "timeout test error", exception.message
end

def _calc_pi
Expand Down

0 comments on commit 083beb9

Please sign in to comment.