Unverified Commit aee67eaf authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto Committed by GitHub

Merge pull request #4240 from shuujii/refactor-sleep-test

Use `assert_raise` and `assert_nothing_raised` in `mruby-sleep` tests
parents fc5dc527 3707ef3d
def run_with_catching_error &b
e = nil
begin
b.call
rescue => _e
e = _e
end
return e
end
assert("sleep works") do
e = run_with_catching_error { sleep 1 }
assert_nil e
assert_nothing_raised { sleep(1) }
end
assert("sleep would not accept negative value") do
e = run_with_catching_error{ sleep(-1) }
assert_not_equal e, nil
assert_equal e.class, ArgumentError
assert_raise(ArgumentError) { sleep(-1) }
end
assert("usleep works") do
e = run_with_catching_error { usleep 100 }
assert_nil e
assert_nothing_raised { usleep(100) }
end
assert("usleep would not accept negative value") do
e = run_with_catching_error{ usleep(-100) }
assert_not_equal e, nil
assert_equal e.class, ArgumentError
assert_raise(ArgumentError) { usleep(-100) }
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment