diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-06-17 03:37:47 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-06-17 03:37:47 +0000 |
commit | d689dca633e979bb888a6a287a07e0084a0f5187 (patch) | |
tree | 09f909688088f714b26e2c9bbf246eb2d6a78a8e /test | |
parent | b905ac81a07bd6547f353ea30c163b47ac60b27d (diff) | |
download | ruby-d689dca633e979bb888a6a287a07e0084a0f5187.tar.gz |
eval.c: pass unknown options
* eval.c (extract_raise_opts): pass unknown options to the
exception, so that exception class can receive a hash argument.
[ruby-core:63203] [Feature #8257]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46456 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_exception.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb index 33d10b31d1..b80cf00cac 100644 --- a/test/ruby/test_exception.rb +++ b/test/ruby/test_exception.rb @@ -596,4 +596,25 @@ end.join raise cause: cause end end + + def test_unknown_option + bug = '[ruby-core:63203] [Feature #8257] should pass unknown options' + + exc = Class.new(RuntimeError) do + attr_reader :arg + def initialize(msg = nil) + @arg = msg + super(msg) + end + end + + e = assert_raise(exc, bug) {raise exc, "foo" => "bar", foo: "bar"} + assert_equal({"foo" => "bar", foo: "bar"}, e.arg, bug) + + e = assert_raise(exc, bug) {raise exc, "foo" => "bar", foo: "bar", cause: "zzz"} + assert_equal({"foo" => "bar", foo: "bar"}, e.arg, bug) + + e = assert_raise(exc, bug) {raise exc, {}} + assert_equal({}, e.arg, bug) + end end |