mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	object.c (rb_obj_match): use rb_warn for deprecation warning
Now the warning is printed even without -w option. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									2b21744efa
								
							
						
					
					
						commit
						e030e9f0b8
					
				
					 3 changed files with 14 additions and 3 deletions
				
			
		
							
								
								
									
										4
									
								
								object.c
									
										
									
									
									
								
							
							
						
						
									
										4
									
								
								object.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1687,8 +1687,8 @@ rb_false(VALUE obj)
 | 
			
		|||
static VALUE
 | 
			
		||||
rb_obj_match(VALUE obj1, VALUE obj2)
 | 
			
		||||
{
 | 
			
		||||
    rb_warning("deprecated Object#=~ is called on %"PRIsVALUE
 | 
			
		||||
               "; it always returns nil", rb_obj_class(obj1));
 | 
			
		||||
    rb_warn("deprecated Object#=~ is called on %"PRIsVALUE
 | 
			
		||||
            "; it always returns nil", rb_obj_class(obj1));
 | 
			
		||||
    return Qnil;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1529,7 +1529,9 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
 | 
			
		|||
  def test_refute_match_matcher_object
 | 
			
		||||
    @assertion_count = 2
 | 
			
		||||
    non_verbose do
 | 
			
		||||
      @tc.refute_match Object.new, 5 # default #=~ returns false
 | 
			
		||||
      obj = Object.new
 | 
			
		||||
      def obj.=~(other); false; end
 | 
			
		||||
      @tc.refute_match obj, 5
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -946,4 +946,13 @@ class TestObject < Test::Unit::TestCase
 | 
			
		|||
      end
 | 
			
		||||
    EOS
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_matcher
 | 
			
		||||
    assert_warning(/deprecated Object#=~ is called on Object/) do
 | 
			
		||||
      assert_equal(Object.new =~ 42, nil)
 | 
			
		||||
    end
 | 
			
		||||
    assert_warning(/deprecated Object#=~ is called on Array/) do
 | 
			
		||||
      assert_equal([] =~ 42, nil)
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue