mirror of
https://github.com/ruby/ruby.git
synced 2025-09-16 00:54:01 +02:00
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
This commit is contained in:
parent
b905ac81a0
commit
d689dca633
3 changed files with 30 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue