From 8a46d4027c5d797eb07afe24d43c37aaa5e33c5d Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 31 Dec 2013 14:49:16 +0000 Subject: 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 --- test/ruby/test_exception.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test') 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 -- cgit v1.2.3