mirror of
https://github.com/ruby/ruby.git
synced 2025-08-28 15:36:16 +02:00
insns.def (opt_regexpmatch2): respect redefined match op
* insns.def (opt_regexpmatch2): respect redefined match op Thanks to Sam Rawlins for the fix. * test/ruby/test_string.rb: test based on Tsuyoshi Sawada's report [Bug #9581] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45318 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c1f1b93171
commit
4101a5690e
3 changed files with 21 additions and 1 deletions
|
@ -2219,6 +2219,19 @@ class TestString < Test::Unit::TestCase
|
|||
assert_equal("foo", "" =~ //)
|
||||
RUBY
|
||||
end
|
||||
|
||||
class Bug9581 < String
|
||||
def =~ re; :foo end
|
||||
end
|
||||
|
||||
def test_regexp_match_subclass
|
||||
s = Bug9581.new("abc")
|
||||
r = /abc/
|
||||
assert_equal(:foo, s =~ r)
|
||||
assert_equal(:foo, s.send(:=~, r))
|
||||
assert_equal(:foo, s.send(:=~, /abc/))
|
||||
assert_equal(:foo, s =~ /abc/, "should not use optimized instruction")
|
||||
end
|
||||
end
|
||||
|
||||
class TestString2 < TestString
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue