[前][次][番号順一覧][スレッド一覧]

ruby-changes:41799

From: nobu <ko1@a...>
Date: Fri, 19 Feb 2016 16:57:41 +0900 (JST)
Subject: [ruby-changes:41799] nobu:r53873 (trunk): test/ruby: suppress runtime warnings

nobu	2016-02-19 16:58:09 +0900 (Fri, 19 Feb 2016)

  New Revision: 53873

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53873

  Log:
    test/ruby: suppress runtime warnings

  Modified files:
    trunk/test/ruby/test_autoload.rb
    trunk/test/ruby/test_const.rb
    trunk/test/ruby/test_file_exhaustive.rb
    trunk/test/ruby/test_iseq.rb
    trunk/test/ruby/test_m17n.rb
    trunk/test/ruby/test_math.rb
    trunk/test/ruby/test_rational.rb
    trunk/test/ruby/test_refinement.rb
    trunk/test/ruby/test_syntax.rb
    trunk/test/ruby/test_variable.rb
Index: test/ruby/test_iseq.rb
===================================================================
--- test/ruby/test_iseq.rb	(revision 53872)
+++ test/ruby/test_iseq.rb	(revision 53873)
@@ -9,7 +9,9 @@ class TestISeq < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_iseq.rb#L9
   end
 
   def compile(src, line = nil, opt = nil)
-    RubyVM::InstructionSequence.new(src, __FILE__, __FILE__, line, opt)
+    EnvUtil.suppress_warning do
+      RubyVM::InstructionSequence.new(src, __FILE__, __FILE__, line, opt)
+    end
   end
 
   def lines src
Index: test/ruby/test_autoload.rb
===================================================================
--- test/ruby/test_autoload.rb	(revision 53872)
+++ test/ruby/test_autoload.rb	(revision 53873)
@@ -189,7 +189,9 @@ p Foo::Bar https://github.com/ruby/ruby/blob/trunk/test/ruby/test_autoload.rb#L189
   end
 
   def ruby_impl_require
-    Kernel.module_eval do; alias :old_require :require; end
+    Kernel.module_eval do
+      alias old_require require
+    end
     called_with = []
     Kernel.send :define_method, :require do |path|
       called_with << path
@@ -197,7 +199,11 @@ p Foo::Bar https://github.com/ruby/ruby/blob/trunk/test/ruby/test_autoload.rb#L199
     end
     yield called_with
   ensure
-    Kernel.module_eval do; alias :require :old_require; undef :old_require; end
+    Kernel.module_eval do
+      undef require
+      alias require old_require
+      undef old_require
+    end
   end
 
   def test_require_implemented_in_ruby_is_called
Index: test/ruby/test_rational.rb
===================================================================
--- test/ruby/test_rational.rb	(revision 53872)
+++ test/ruby/test_rational.rb	(revision 53873)
@@ -904,7 +904,8 @@ class Rational_Test < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rational.rb#L904
 
   def test_fixed_bug
     n = Float::MAX.to_i * 2
-    assert_equal(1.0, Rational(n + 2, n + 1).to_f, '[ruby-dev:33852]')
+    x = EnvUtil.suppress_warning {Rational(n + 2, n + 1).to_f}
+    assert_equal(1.0, x, '[ruby-dev:33852]')
   end
 
   def test_power_of_1_and_minus_1
Index: test/ruby/test_m17n.rb
===================================================================
--- test/ruby/test_m17n.rb	(revision 53872)
+++ test/ruby/test_m17n.rb	(revision 53873)
@@ -1673,13 +1673,9 @@ class TestM17N < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_m17n.rb#L1673
   def test_inspect_with_default_internal
     bug11787 = '[ruby-dev:49415] [Bug #11787]'
 
-    orig_int = Encoding.default_internal
-    Encoding.default_internal = ::Encoding::EUC_JP
-    s = begin
-          [e("\xB4\xC1\xBB\xFA")].inspect
-        ensure
-          Encoding.default_internal = orig_int
-        end
+    s = EnvUtil.with_default_internal(::Encoding::EUC_JP) do
+      [e("\xB4\xC1\xBB\xFA")].inspect
+    end
     assert_equal(e("[\"\xB4\xC1\xBB\xFA\"]"), s, bug11787)
   end
 end
Index: test/ruby/test_refinement.rb
===================================================================
--- test/ruby/test_refinement.rb	(revision 53872)
+++ test/ruby/test_refinement.rb	(revision 53873)
@@ -503,8 +503,10 @@ class TestRefinement < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/ruby/test_refinement.rb#L503
     end
 
     class C
-      def foo
-        "redefined"
+      EnvUtil.suppress_warning do
+        def foo
+          "redefined"
+        end
       end
     end
   end
Index: test/ruby/test_syntax.rb
===================================================================
--- test/ruby/test_syntax.rb	(revision 53872)
+++ test/ruby/test_syntax.rb	(revision 53873)
@@ -369,22 +369,22 @@ WARN https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L369
 
   def test_duplicated_arg
     assert_syntax_error("def foo(a, a) end", /duplicated argument name/)
-    assert_nothing_raised { def foo(_, _) end }
+    assert_valid_syntax("def foo(_, _) end")
   end
 
   def test_duplicated_rest
     assert_syntax_error("def foo(a, *a) end", /duplicated argument name/)
-    assert_nothing_raised { def foo(_, *_) end }
+    assert_valid_syntax("def foo(_, *_) end")
   end
 
   def test_duplicated_opt
     assert_syntax_error("def foo(a, a=1) end", /duplicated argument name/)
-    assert_nothing_raised { def foo(_, _=1) end }
+    assert_valid_syntax("def foo(_, _=1) end")
   end
 
   def test_duplicated_opt_rest
     assert_syntax_error("def foo(a=1, *a) end", /duplicated argument name/)
-    assert_nothing_raised { def foo(_=1, *_) end }
+    assert_valid_syntax("def foo(_=1, *_) end")
   end
 
   def test_duplicated_rest_opt
@@ -397,12 +397,12 @@ WARN https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L397
 
   def test_duplicated_opt_post
     assert_syntax_error("def foo(a=1, a) end", /duplicated argument name/)
-    assert_nothing_raised { def foo(_=1, _) end }
+    assert_valid_syntax("def foo(_=1, _) end")
   end
 
   def test_duplicated_kw
     assert_syntax_error("def foo(a, a: 1) end", /duplicated argument name/)
-    assert_nothing_raised { def foo(_, _: 1) end }
+    assert_valid_syntax("def foo(_, _: 1) end")
   end
 
   def test_duplicated_rest_kw
@@ -412,22 +412,22 @@ WARN https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L412
 
   def test_duplicated_opt_kw
     assert_syntax_error("def foo(a=1, a: 1) end", /duplicated argument name/)
-    assert_nothing_raised { def foo(_=1, _: 1) end }
+    assert_valid_syntax("def foo(_=1, _: 1) end")
   end
 
   def test_duplicated_kw_kwrest
     assert_syntax_error("def foo(a: 1, **a) end", /duplicated argument name/)
-    assert_nothing_raised { def foo(_: 1, **_) end }
+    assert_valid_syntax("def foo(_: 1, **_) end")
   end
 
   def test_duplicated_rest_kwrest
     assert_syntax_error("def foo(*a, **a) end", /duplicated argument name/)
-    assert_nothing_raised { def foo(*_, **_) end }
+    assert_valid_syntax("def foo(*_, **_) end")
   end
 
   def test_duplicated_opt_kwrest
     assert_syntax_error("def foo(a=1, **a) end", /duplicated argument name/)
-    assert_nothing_raised { def foo(_=1, **_) end }
+    assert_valid_syntax("def foo(_=1, **_) end")
   end
 
   def test_duplicated_when
Index: test/ruby/test_const.rb
===================================================================
--- test/ruby/test_const.rb	(revision 53872)
+++ test/ruby/test_const.rb	(revision 53873)
@@ -37,7 +37,7 @@ class TestConst < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_const.rb#L37
     self.class.class_eval {
       include Const2
     }
-    STDERR.print "intentionally redefines TEST3, TEST4\n" if $VERBOSE
+    # STDERR.print "intentionally redefines TEST3, TEST4\n" if $VERBOSE
     assert defined?(TEST1)
     assert_equal 1, TEST1
     assert defined?(TEST2)
Index: test/ruby/test_math.rb
===================================================================
--- test/ruby/test_math.rb	(revision 53872)
+++ test/ruby/test_math.rb	(revision 53873)
@@ -289,7 +289,7 @@ class TestMath < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_math.rb#L289
     check(Math.exp((0 + 1)._to_f), Math.exp(0))
     check(Math.log((0 + 1)._to_f), Math.log(0))
 
-    Fixnum.class_eval { alias to_f _to_f }
+    Fixnum.class_eval { undef to_f; alias to_f _to_f; undef _to_f }
   end
 
   def test_bignum_to_f
@@ -307,7 +307,7 @@ class TestMath < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_math.rb#L307
     check(Math.cos((1 << 62 << 1)._to_f),  Math.cos(1 << 62))
     check(Math.log((1 << 62 << 1)._to_f),  Math.log(1 << 62))
 
-    Bignum.class_eval { alias to_f _to_f }
+    Bignum.class_eval { undef to_f; alias to_f _to_f; undef _to_f }
   end
 
   def test_rational_to_f
@@ -326,6 +326,6 @@ class TestMath < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_math.rb#L326
     check(Math.exp((0r + 1)._to_f), Math.exp(0r))
     check(Math.log((0r + 1)._to_f), Math.log(0r))
 
-    Rational.class_eval { alias to_f _to_f }
+    Rational.class_eval { undef to_f; alias to_f _to_f; undef _to_f }
   end
 end
Index: test/ruby/test_file_exhaustive.rb
===================================================================
--- test/ruby/test_file_exhaustive.rb	(revision 53872)
+++ test/ruby/test_file_exhaustive.rb	(revision 53873)
@@ -107,7 +107,7 @@ class TestFileExhaustive < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/test/ruby/test_file_exhaustive.rb#L107
   end
 
   def symlinkfile
-    return @symlinkfile if @symlinkfile
+    return @symlinkfile if defined? @symlinkfile
     @symlinkfile = make_tmp_filename("symlinkfile")
     begin
       File.symlink(regular_file, @symlinkfile)
Index: test/ruby/test_variable.rb
===================================================================
--- test/ruby/test_variable.rb	(revision 53872)
+++ test/ruby/test_variable.rb	(revision 53873)
@@ -141,7 +141,7 @@ class TestVariable < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/test/ruby/test_variable.rb#L141
         v.instance_variable_set(:@foo, :bar)
       end
 
-      assert_nil v.instance_variable_get(:@foo)
+      assert_nil EnvUtil.suppress_warning {v.instance_variable_get(:@foo)}
       assert_not_send([v, :instance_variable_defined?, :@foo])
 
       assert_raise_with_message(RuntimeError, msg) do

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]