diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-02-28 04:41:38 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-02-28 04:41:38 +0000 |
commit | 4d9f5482aea747e614a8d78b5e8ec114b023a768 (patch) | |
tree | 3075620060c592076e2df80b21949e7e1e0ed8cd /test | |
parent | 74e5e61849e6062554adbc6887ce435826bcaef2 (diff) |
NoMethodError#private_call?
* error.c (nometh_err_initialize): add private_call? parameter.
* error.c (nometh_err_private_call_p): add private_call? method,
to tell if the exception raised in private form FCALL or VCALL.
[Feature #12043]
* vm_eval.c (make_no_method_exception): append private_call?
argument.
* vm_insnhelper.c (ci_missing_reason): copy FCALL flag.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53961 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_exception.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb index 7c0674857a..262d27f080 100644 --- a/test/ruby/test_exception.rb +++ b/test/ruby/test_exception.rb @@ -762,6 +762,7 @@ end.join assert_equal(:foo, e.name) assert_equal([1, 2], e.args) assert_same(obj, e.receiver) + assert_not_predicate(e, :private_call?) e = assert_raise(NoMethodError) { obj.instance_eval {foo(1, 2)} @@ -769,6 +770,7 @@ end.join assert_equal(:foo, e.name) assert_equal([1, 2], e.args) assert_same(obj, e.receiver) + assert_predicate(e, :private_call?) end def test_name_error_info_local_variables @@ -787,6 +789,29 @@ end.join assert_equal(%i[a b c d e f g], e.local_variables.sort) end + def test_name_error_info_method_missing + obj = PrettyObject.new + def obj.method_missing(*) + super + end + + e = assert_raise(NoMethodError) { + obj.foo(1, 2) + } + assert_equal(:foo, e.name) + assert_equal([1, 2], e.args) + assert_same(obj, e.receiver) + assert_not_predicate(e, :private_call?) + + e = assert_raise(NoMethodError) { + obj.instance_eval {foo(1, 2)} + } + assert_equal(:foo, e.name) + assert_equal([1, 2], e.args) + assert_same(obj, e.receiver) + assert_predicate(e, :private_call?) + end + def test_name_error_info_parent_iseq_mark assert_separately(['-', File.join(__dir__, 'bug-11928.rb')], <<-'end;') -> {require ARGV[0]}.call |