summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--object.c4
-rw-r--r--test/minitest/test_minitest_unit.rb4
-rw-r--r--test/ruby/test_object.rb9
3 files changed, 14 insertions, 3 deletions
diff --git a/object.c b/object.c
index a60626b5a1..31caea714f 100644
--- a/object.c
+++ b/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;
}
diff --git a/test/minitest/test_minitest_unit.rb b/test/minitest/test_minitest_unit.rb
index 3d92b865c3..f59bc45c26 100644
--- a/test/minitest/test_minitest_unit.rb
+++ b/test/minitest/test_minitest_unit.rb
@@ -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
diff --git a/test/ruby/test_object.rb b/test/ruby/test_object.rb
index 28e07162d7..0d31eb3ff0 100644
--- a/test/ruby/test_object.rb
+++ b/test/ruby/test_object.rb
@@ -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