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

ruby-changes:27953

From: marcandre <ko1@a...>
Date: Sat, 30 Mar 2013 13:33:38 +0900 (JST)
Subject: [ruby-changes:27953] marcandRe: r40005 (trunk): * test/ruby/test_class.rb: Simplify warning checks

marcandre	2013-03-30 13:33:28 +0900 (Sat, 30 Mar 2013)

  New Revision: 40005

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=40005

  Log:
    * test/ruby/test_class.rb: Simplify warning checks
    
    * test/ruby/test_io.rb: ditto
    
    * test/ruby/test_module.rb: ditto
    
    * test/ruby/test_regexp.rb: ditto

  Modified files:
    trunk/test/ruby/test_class.rb
    trunk/test/ruby/test_io.rb
    trunk/test/ruby/test_module.rb
    trunk/test/ruby/test_regexp.rb

Index: test/ruby/test_module.rb
===================================================================
--- test/ruby/test_module.rb	(revision 40004)
+++ test/ruby/test_module.rb	(revision 40005)
@@ -1067,23 +1067,21 @@ class TestModule < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_module.rb#L1067
     assert_match(/:#{line}: warning: method redefined; discarding old foo/, stderr)
     assert_match(/:#{line-1}: warning: previous definition of foo/, stderr, feature2155)
 
-    stderr = EnvUtil.verbose_warning do
+    assert_warning '' do
       Module.new do
         def foo; end
         alias bar foo
         def foo; end
       end
     end
-    assert_equal("", stderr)
 
-    stderr = EnvUtil.verbose_warning do
+    assert_warning '' do
       Module.new do
         def foo; end
         alias bar foo
         alias bar foo
       end
     end
-    assert_equal("", stderr)
 
     line = __LINE__+4
     stderr = EnvUtil.verbose_warning do
@@ -1095,31 +1093,28 @@ class TestModule < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_module.rb#L1093
     assert_match(/:#{line}: warning: method redefined; discarding old foo/, stderr)
     assert_match(/:#{line-1}: warning: previous definition of foo/, stderr, feature2155)
 
-    stderr = EnvUtil.verbose_warning do
+    assert_warning '' do
       Module.new do
         define_method(:foo) do end
         alias bar foo
         alias bar foo
       end
     end
-    assert_equal("", stderr)
 
-    stderr = EnvUtil.verbose_warning do
+    assert_warning('', '[ruby-dev:39397]') do
       Module.new do
         module_function
         def foo; end
         module_function :foo
       end
     end
-    assert_equal("", stderr, '[ruby-dev:39397]')
 
-    stderr = EnvUtil.verbose_warning do
+    assert_warning '' do
       Module.new do
         def foo; end
         undef foo
       end
     end
-    assert_equal("", stderr)
   end
 
   def test_protected_singleton_method
@@ -1592,55 +1587,47 @@ class TestModule < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_module.rb#L1587
 
   def test_uninitialized_instance_variable
     a = AttrTest.new
-    stderr = EnvUtil.verbose_warning do
+    assert_warning /instance variable @ivar not initialized/ do
       assert_nil(a.ivar)
     end
-    assert_match(/instance variable @ivar not initialized/, stderr)
     a.instance_variable_set(:@ivar, 42)
-    stderr = EnvUtil.verbose_warning do
+    assert_warning '' do
       assert_equal(42, a.ivar)
     end
-    assert_equal("", stderr)
   end
 
   def test_uninitialized_attr
     a = AttrTest.new
-    stderr = EnvUtil.verbose_warning do
+    assert_warning '' do
       assert_nil(a.iattr)
     end
-    assert_equal("", stderr)
     a.iattr = 42
-    stderr = EnvUtil.verbose_warning do
+    assert_warning '' do
       assert_equal(42, a.iattr)
     end
-    assert_equal("", stderr)
   end
 
   def test_uninitialized_attr_class
-    stderr = EnvUtil.verbose_warning do
+    assert_warning '' do
       assert_nil(AttrTest.cattr)
     end
-    assert_equal("", stderr)
     AttrTest.cattr = 42
-    stderr = EnvUtil.verbose_warning do
+    assert_warning '' do
       assert_equal(42, AttrTest.cattr)
     end
-    assert_equal("", stderr)
   end
 
   def test_uninitialized_attr_non_object
     a = Class.new(Array) do
       attr_accessor :iattr
     end.new
-    stderr = EnvUtil.verbose_warning do
+    assert_warning '' do
       assert_nil(a.iattr)
     end
-    assert_equal("", stderr)
     a.iattr = 42
-    stderr = EnvUtil.verbose_warning do
+    assert_warning '' do
       assert_equal(42, a.iattr)
     end
-    assert_equal("", stderr)
   end
 
   def test_remove_const
Index: test/ruby/test_regexp.rb
===================================================================
--- test/ruby/test_regexp.rb	(revision 40004)
+++ test/ruby/test_regexp.rb	(revision 40005)
@@ -914,9 +914,7 @@ class TestRegexp < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_regexp.rb#L914
     assert_warning(/duplicated/) { Regexp.new('[\u3042\u3044\u3046\u3041-\u3047]') }
 
     bug7471 = '[ruby-core:50344]'
-    EnvUtil.verbose_warning do
-      assert_warning(/\A\z/, bug7471) { Regexp.new('[\D]') =~ "\u3042" }
-    end
+    assert_warning('', bug7471) { Regexp.new('[\D]') =~ "\u3042" }
   end
 
   def test_property_warn
Index: test/ruby/test_io.rb
===================================================================
--- test/ruby/test_io.rb	(revision 40004)
+++ test/ruby/test_io.rb	(revision 40005)
@@ -2396,20 +2396,17 @@ End https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L2396
   end
 
   def test_warn
-    stderr = EnvUtil.verbose_warning do
+    assert_warning "warning\n" do
       warn "warning"
     end
-    assert_equal("warning\n", stderr)
 
-    stderr = EnvUtil.verbose_warning do
+    assert_warning '' do
       warn
     end
-    assert_equal("", stderr)
 
-    stderr = EnvUtil.verbose_warning do
+    assert_warning "[Feature #5029]\n[ruby-core:38070]\n" do
       warn "[Feature #5029]", "[ruby-core:38070]"
     end
-    assert_equal("[Feature #5029]\n[ruby-core:38070]\n", stderr)
   end
 
   def test_cloexec
Index: test/ruby/test_class.rb
===================================================================
--- test/ruby/test_class.rb	(revision 40004)
+++ test/ruby/test_class.rb	(revision 40005)
@@ -118,23 +118,21 @@ class TestClass < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_class.rb#L118
     assert_match(/:#{line}: warning: method redefined; discarding old foo/, stderr)
     assert_match(/:#{line-1}: warning: previous definition of foo/, stderr, feature2155)
 
-    stderr = EnvUtil.verbose_warning do
+    assert_warning '' do
       Class.new do
         def foo; end
         alias bar foo
         def foo; end
       end
     end
-    assert_equal("", stderr)
 
-    stderr = EnvUtil.verbose_warning do
+    assert_warning '' do
       Class.new do
         def foo; end
         alias bar foo
         alias bar foo
       end
     end
-    assert_equal("", stderr)
 
     line = __LINE__+4
     stderr = EnvUtil.verbose_warning do
@@ -146,22 +144,20 @@ class TestClass < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_class.rb#L144
     assert_match(/:#{line}: warning: method redefined; discarding old foo/, stderr)
     assert_match(/:#{line-1}: warning: previous definition of foo/, stderr, feature2155)
 
-    stderr = EnvUtil.verbose_warning do
+    assert_warning '' do
       Class.new do
         define_method(:foo) do end
         alias bar foo
         alias bar foo
       end
     end
-    assert_equal("", stderr)
 
-    stderr = EnvUtil.verbose_warning do
+    assert_warning '' do
       Class.new do
         def foo; end
         undef foo
       end
     end
-    assert_equal("", stderr)
   end
 
   def test_check_inheritable

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

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