From 6954ff1dcb538ee6c042872088b64464a1ef6089 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Mon, 29 Jul 2019 16:22:00 -0700 Subject: Make Range#=== operate like cover? instead of include? for string ranges Previously, Range#=== treated string ranges that were not endless or beginless the same as include?, instead of the same as cover?. I think this was an oversight in 989e07c0f2fa664a54e52a475c2fcc145f06539d, as the commit message did not indicate this behavior was desired. This also makes some previously dead code no longer dead. Previously, the conditionals were doing this: if (RB_TYPE_P(beg, T_STRING) if (NIL_P(beg)) # can never be true This restructures it so at the NIL_P(beg) check, beg could possibly be nil (beginless ranges). Fixes [Bug #15449] --- test/ruby/test_range.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_range.rb b/test/ruby/test_range.rb index 699e4459be..546b1ad8ca 100644 --- a/test/ruby/test_range.rb +++ b/test/ruby/test_range.rb @@ -528,6 +528,14 @@ class TestRange < Test::Unit::TestCase assert_not_operator(5..nil, :===, 0) end + def test_eqq_string + assert_operator('A'..'Z', :===, 'ANA') + assert_not_operator('A'..'Z', :===, 'ana') + assert_operator('A'.., :===, 'ANA') + assert_operator(..'Z', :===, 'ANA') + assert_operator(nil..nil, :===, 'ANA') + end + def test_eqq_time bug11113 = '[ruby-core:69052] [Bug #11113]' t = Time.now -- cgit v1.2.3