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:
nobu 2013-12-31 14:49:16 +00:00
parent 2cdee22370
commit 8a46d4027c
3 changed files with 67 additions and 11 deletions

View file

@ -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