summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-25 18:28:21 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-25 18:28:21 +0000
commitca050a8d57a771d24de2cdf3e3d56e5ff6bc278c (patch)
tree622e3cffb084e4574e83d35aeb64afc6d319ace2 /test
parent5fd508805288d9f9f5f3a8025e76200698420c89 (diff)
merge revision(s) 44411: [Backport #9295]
* vm_insnhelper.c (argument_error): insert dummy frame to make a backtrace object intead of modify backtrace string array. [Bug #9295] * test/ruby/test_backtrace.rb: add a test for this patch. fix test to compare a result of Exception#backtrace with a result of Exception#backtrace_locations. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_backtrace.rb38
1 files changed, 30 insertions, 8 deletions
diff --git a/test/ruby/test_backtrace.rb b/test/ruby/test_backtrace.rb
index aded544dcf..6ec13e4cc5 100644
--- a/test/ruby/test_backtrace.rb
+++ b/test/ruby/test_backtrace.rb
@@ -19,17 +19,16 @@ class TestBacktrace < Test::Unit::TestCase
end
def test_exception_backtrace_locations
- bt = Fiber.new{
+ backtrace, backtrace_locations = Fiber.new{
begin
raise
rescue => e
- e.backtrace_locations
+ [e.backtrace, e.backtrace_locations]
end
}.resume
- assert_equal(1, bt.size)
- assert_match(/.+:\d+:.+/, bt[0].to_s)
+ assert_equal(backtrace, backtrace_locations.map{|e| e.to_s})
- bt = Fiber.new{
+ backtrace, backtrace_locations = Fiber.new{
begin
begin
helper_test_exception_backtrace_locations
@@ -37,11 +36,34 @@ class TestBacktrace < Test::Unit::TestCase
raise
end
rescue => e
- e.backtrace_locations
+ [e.backtrace, e.backtrace_locations]
+ end
+ }.resume
+ assert_equal(backtrace, backtrace_locations.map{|e| e.to_s})
+ end
+
+ def call_helper_test_exception_backtrace_locations
+ helper_test_exception_backtrace_locations(:bad_argument)
+ end
+
+ def test_argument_error_backtrace_locations
+ backtrace, backtrace_locations = Fiber.new{
+ begin
+ helper_test_exception_backtrace_locations(1)
+ rescue ArgumentError => e
+ [e.backtrace, e.backtrace_locations]
+ end
+ }.resume
+ assert_equal(backtrace, backtrace_locations.map{|e| e.to_s})
+
+ backtrace, backtrace_locations = Fiber.new{
+ begin
+ call_helper_test_exception_backtrace_locations
+ rescue ArgumentError => e
+ [e.backtrace, e.backtrace_locations]
end
}.resume
- assert_equal(2, bt.size)
- assert_match(/helper_test_exception_backtrace_locations/, bt[0].to_s)
+ assert_equal(backtrace, backtrace_locations.map{|e| e.to_s})
end
def test_caller_lev