summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-18 15:04:49 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-18 15:04:49 +0000
commitbec19f4962ab3ef773f016761e1761ddf516e0b9 (patch)
tree5ba1510550709315cd9e0fd59d3ede6dccf885c0 /test
parent57647b8a97c112a98bb235a345da5a90d09c80a4 (diff)
merge revision(s) 55372: [Backport #14179]
* lib/forwardable.rb (_delegator_method): leave the backtrace untouched during accessor. forwardable.rb does not appear in the backtrace during delegated method because of tail-call optimization. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@62820 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/test_forwardable.rb13
1 files changed, 8 insertions, 5 deletions
diff --git a/test/test_forwardable.rb b/test/test_forwardable.rb
index f678ca4fc7..9d159de826 100644
--- a/test/test_forwardable.rb
+++ b/test/test_forwardable.rb
@@ -225,18 +225,21 @@ class TestForwardable < Test::Unit::TestCase
class Foo
extend Forwardable
+ attr_accessor :bar
def_delegator :bar, :baz
def_delegator :caller, :itself, :c
-
- class Exception
- end
end
def test_backtrace_adjustment
+ obj = Foo.new
+ def (obj.bar = Object.new).baz
+ foo
+ end
e = assert_raise(NameError) {
- Foo.new.baz
+ obj.baz
}
- assert_not_match(/\/forwardable\.rb/, e.backtrace[0])
+ assert_not_match(/\/forwardable\.rb/, e.backtrace[0],
+ proc {RubyVM::InstructionSequence.of(obj.method(:baz)).disassemble})
assert_equal(caller(0, 1)[0], Foo.new.c[0])
end