aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_marshal.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-06-24 17:33:35 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-06-24 17:33:35 +0000
commit461af70f9335ccfd1531f2faffadbf4194b3f344 (patch)
tree31a525fa80261c59d03b4dee20de68b6aa8d0401 /test/ruby/test_marshal.rb
parent45a0085e38268063d9b80500014f2cd900a00c11 (diff)
downloadruby-461af70f9335ccfd1531f2faffadbf4194b3f344.tar.gz
No respond_to? as if the default definition
* 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/trunk@55500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_marshal.rb')
-rw-r--r--test/ruby/test_marshal.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/ruby/test_marshal.rb b/test/ruby/test_marshal.rb
index 8bfca5561f..d21ab66ffd 100644
--- a/test/ruby/test_marshal.rb
+++ b/test/ruby/test_marshal.rb
@@ -737,4 +737,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