mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 16:44:01 +02:00
eval.c: raise with cause
* eval.c (rb_f_raise): add cause: optional keyword argument. [ruby-core:58610] [Feature #8257] [EXPERIMENTAL] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2cdee22370
commit
8a46d4027c
3 changed files with 67 additions and 11 deletions
|
@ -517,4 +517,18 @@ end.join
|
|||
}
|
||||
assert_not_same(e, e.cause, "#{msg}: should not be recursive")
|
||||
end
|
||||
|
||||
def test_raise_with_cause
|
||||
msg = "[Feature #8257]"
|
||||
cause = ArgumentError.new("foobar")
|
||||
e = assert_raise(RuntimeError) {raise msg, cause: cause}
|
||||
assert_same(cause, e.cause)
|
||||
end
|
||||
|
||||
def test_cause_with_no_arguments
|
||||
cause = ArgumentError.new("foobar")
|
||||
assert_raise_with_message(ArgumentError, /with no arguments/) do
|
||||
raise cause: cause
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue