diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-12-17 20:06:18 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-17 20:06:18 +0900 |
commit | 9908177857a28633d6279c43a1ad4dfedcb98596 (patch) | |
tree | 400f3c07584b9d87129ec24c42ccb436095f2803 /test/ruby/test_marshal.rb | |
parent | d597d7a8b6e753cfe40b8470c770f744adde5d4f (diff) |
test/ruby: Check warning messages at a finer granularity
Instead of suppressing all warnings wholly in each test scripts by
setting `$VERBOSE` to `nil` in `setup` methods.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3925
Merged-By: nobu <nobu@ruby-lang.org>
Diffstat (limited to 'test/ruby/test_marshal.rb')
-rw-r--r-- | test/ruby/test_marshal.rb | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/test/ruby/test_marshal.rb b/test/ruby/test_marshal.rb index fd62ea774b..ef8b261321 100644 --- a/test/ruby/test_marshal.rb +++ b/test/ruby/test_marshal.rb @@ -8,7 +8,6 @@ class TestMarshal < Test::Unit::TestCase def setup @verbose = $VERBOSE - $VERBOSE = nil end def teardown @@ -157,20 +156,29 @@ class TestMarshal < Test::Unit::TestCase end def test_change_class_name + self.class.__send__(:remove_const, :C3) if self.class.const_defined?(:C3) eval("class C3; def _dump(s); 'foo'; end; end") m = Marshal.dump(C3.new) assert_raise(TypeError) { Marshal.load(m) } + self.class.__send__(:remove_const, :C3) eval("C3 = nil") assert_raise(TypeError) { Marshal.load(m) } + ensure + self.class.__send__(:remove_const, :C3) if self.class.const_defined?(:C3) end def test_change_struct + self.class.__send__(:remove_const, :C3) if self.class.const_defined?(:C3) eval("C3 = Struct.new(:foo, :bar)") m = Marshal.dump(C3.new("FOO", "BAR")) + self.class.__send__(:remove_const, :C3) eval("C3 = Struct.new(:foo)") assert_raise(TypeError) { Marshal.load(m) } + self.class.__send__(:remove_const, :C3) eval("C3 = Struct.new(:foo, :baz)") assert_raise(TypeError) { Marshal.load(m) } + ensure + self.class.__send__(:remove_const, :C3) if self.class.const_defined?(:C3) end class C4 @@ -542,7 +550,7 @@ class TestMarshal < Test::Unit::TestCase end class TestForRespondToFalse - def respond_to?(a) + def respond_to?(a, priv = false) false end end @@ -570,7 +578,7 @@ class TestMarshal < Test::Unit::TestCase end def test_continuation - require "continuation" + EnvUtil.suppress_warning {require "continuation"} c = Bug9523.new assert_raise_with_message(RuntimeError, /Marshal\.dump reentered at marshal_dump/) do Marshal.dump(c) |