mirror of
https://github.com/ruby/ruby.git
synced 2025-08-28 07:26:00 +02:00
Regexp#match{?} with nil raises TypeError as String, Symbol (#1506)
* {String|Symbol}#match{?} with nil returns falsy To improve consistency with Regexp#match{?} * String#match(nil) returns `nil` instead of TypeError * String#match?(nil) returns `false` instead of TypeError * Symbol#match(nil) returns `nil` instead of TypeError * Symbol#match?(nil) returns `false` instead of TypeError * Prefer exception * Follow empty ENV * Drop outdated specs * Write ruby/spec for above https://github.com/ruby/ruby/pull/1506/files#r183242981 * Fix merge miss
This commit is contained in:
parent
41457dcbe0
commit
2a22a6b2d8
5 changed files with 41 additions and 15 deletions
|
@ -2512,6 +2512,7 @@ CODE
|
|||
|
||||
def test_match_method
|
||||
assert_equal("bar", "foobarbaz".match(/bar/).to_s)
|
||||
assert_raise(TypeError) { "".match(nil) }
|
||||
|
||||
o = Regexp.new('foo')
|
||||
def o.match(x, y, z); x + y + z; end
|
||||
|
@ -2567,6 +2568,10 @@ CODE
|
|||
assert_equal('backref', $&)
|
||||
end
|
||||
|
||||
def test_match_p_nil
|
||||
assert_raise(TypeError) { ''.match?(nil) }
|
||||
end
|
||||
|
||||
def test_clear
|
||||
s = "foo" * 100
|
||||
s.clear
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue