summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2024-02-15 14:23:01 +0900
committerYusuke Endoh <mame@ruby-lang.org>2024-02-15 19:11:58 +0900
commit9d1b000bd1bb747bcc49e2d7677fb7c2b31c5a94 (patch)
treece3568e37e47e6106567c6ac7e0a981bc59627a9 /test/ruby
parent61819c87b29f3267d6a2499d9018f09cd5bcf2c4 (diff)
Show the method owner in backtraces
``` test.rb:1:in 'Object#toplevel_meth': unhandled exception from test.rb:4:in 'Foo.class_meth' from test.rb:6:in 'Foo#instance_meth' from test.rb:11:in 'singleton_meth' from test.rb:13:in '<main>' ``` [Feature #19117]
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_backtrace.rb20
1 files changed, 10 insertions, 10 deletions
diff --git a/test/ruby/test_backtrace.rb b/test/ruby/test_backtrace.rb
index c4b9d50c8b..50d37faa1d 100644
--- a/test/ruby/test_backtrace.rb
+++ b/test/ruby/test_backtrace.rb
@@ -216,7 +216,7 @@ class TestBacktrace < Test::Unit::TestCase
end
@line = __LINE__ + 1
[1].map.map { [1].map.map { foo } }
- assert_equal("[\"#{__FILE__}:#{@line}:in 'map'\"]", @res)
+ assert_equal("[\"#{__FILE__}:#{@line}:in 'Array#map'\"]", @res)
end
def test_caller_location_path_cfunc_iseq_no_pc
@@ -292,13 +292,13 @@ class TestBacktrace < Test::Unit::TestCase
end
def test_caller_locations_label
- assert_equal("#{__method__}", caller_locations(0, 1)[0].label)
+ assert_equal("TestBacktrace##{__method__}", caller_locations(0, 1)[0].label)
loc, = tap {break caller_locations(0, 1)}
- assert_equal("block in #{__method__}", loc.label)
+ assert_equal("block in TestBacktrace##{__method__}", loc.label)
begin
raise
rescue
- assert_equal("rescue in #{__method__}", caller_locations(0, 1)[0].label)
+ assert_equal("TestBacktrace##{__method__}", caller_locations(0, 1)[0].label)
end
end
@@ -387,7 +387,7 @@ class TestBacktrace < Test::Unit::TestCase
err = ["-:1:in '<main>': unhandled exception"]
assert_in_out_err([], "raise", [], err)
- err = ["-:2:in 'foo': foo! (RuntimeError)",
+ err = ["-:2:in 'Object#foo': foo! (RuntimeError)",
"\tfrom -:4:in '<main>'"]
assert_in_out_err([], <<-"end;", [], err)
def foo
@@ -396,11 +396,11 @@ class TestBacktrace < Test::Unit::TestCase
foo
end;
- err = ["-:7:in 'rescue in bar': bar! (RuntimeError)",
- "\tfrom -:4:in 'bar'",
+ err = ["-:7:in 'Object#bar': bar! (RuntimeError)",
+ "\tfrom -:4:in 'Object#bar'",
"\tfrom -:9:in '<main>'",
- "-:2:in 'foo': foo! (RuntimeError)",
- "\tfrom -:5:in 'bar'",
+ "-:2:in 'Object#foo': foo! (RuntimeError)",
+ "\tfrom -:5:in 'Object#bar'",
"\tfrom -:9:in '<main>'"]
assert_in_out_err([], <<-"end;", [], err)
def foo
@@ -416,7 +416,7 @@ class TestBacktrace < Test::Unit::TestCase
end
def test_caller_to_enum
- err = ["-:3:in 'foo': unhandled exception", "\tfrom -:in 'each'"]
+ err = ["-:3:in 'Object#foo': unhandled exception", "\tfrom -:in 'Enumerator#each'"]
assert_in_out_err([], <<-"end;", [], err, "[ruby-core:91911]")
def foo
return to_enum(__method__) unless block_given?