summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-08-11 18:58:11 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-08-11 18:58:11 +0000
commit8dc8bba42d63b5ada216f94b85f8dceb72e266a8 (patch)
treeedd024d3b69f60b11e3bcdf0e1aea32846e022c0 /test
parent717f31e0756ac0f7c1e0c47c7a91356d0cbccc71 (diff)
merge revision(s) 54142,55500: [Backport #12353]
assertions.rb: fix result of assert_nothing_raised * test/lib/test/unit/assertions.rb (assert_nothing_raised): do not discard the result of the given block. * vm_method.c (vm_respond_to): try method_missing if respond_to? is undefined, as if it is the default definition. [ruby-core:75377] [Bug #12353] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@55869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/lib/test/unit/assertions.rb1
-rw-r--r--test/ruby/test_marshal.rb20
2 files changed, 20 insertions, 1 deletions
diff --git a/test/lib/test/unit/assertions.rb b/test/lib/test/unit/assertions.rb
index 4396503447..9a1cacd5a9 100644
--- a/test/lib/test/unit/assertions.rb
+++ b/test/lib/test/unit/assertions.rb
@@ -186,7 +186,6 @@ module Test
raise
end
end
- nil
end
# :call-seq:
diff --git a/test/ruby/test_marshal.rb b/test/ruby/test_marshal.rb
index e2e321bb41..38e03ac57b 100644
--- a/test/ruby/test_marshal.rb
+++ b/test/ruby/test_marshal.rb
@@ -736,4 +736,24 @@ class TestMarshal < Test::Unit::TestCase
end
RUBY
end
+
+ MethodMissingWithoutRespondTo = Struct.new(:wrapped_object) do
+ undef respond_to?
+ def method_missing(*args, &block)
+ wrapped_object.public_send(*args, &block)
+ end
+ def respond_to_missing?(name, private = false)
+ wrapped_object.respond_to?(name, false)
+ end
+ end
+
+ def test_method_missing_without_respond_to
+ bug12353 = "[ruby-core:75377] [Bug #12353]: try method_missing if" \
+ " respond_to? is undefined"
+ obj = MethodMissingWithoutRespondTo.new("foo")
+ dump = assert_nothing_raised(NoMethodError, bug12353) do
+ Marshal.dump(obj)
+ end
+ assert_equal(obj, Marshal.load(dump))
+ end
end