diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-12-31 14:49:16 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-12-31 14:49:16 +0000 |
commit | 8a46d4027c5d797eb07afe24d43c37aaa5e33c5d (patch) | |
tree | fa3dbaa5d7fb097e82daf4de58e5d5f2a299b2eb /test/ruby | |
parent | 2cdee22370ef9f7ed887c4cf5167576f94db9899 (diff) | |
download | ruby-8a46d4027c5d797eb07afe24d43c37aaa5e33c5d.tar.gz |
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
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_exception.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb index dfa428912e..f15b37f8b9 100644 --- a/test/ruby/test_exception.rb +++ b/test/ruby/test_exception.rb @@ -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 |