From c4b4e77c72b42f0a69c6a825954ec768d1b2375b Mon Sep 17 00:00:00 2001 From: sorah Date: Thu, 26 Sep 2013 07:58:28 +0000 Subject: * insns.def (opt_regexpmatch2): Check String#=~ hasn't overridden before calling rb_reg_match(). * test/ruby/test_string.rb: Test for above. * vm.c (vm_init_redefined_flag): Add BOP flag for String#=~ [ruby-core:57385] [Bug #8953] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43052 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_string.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test') diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index 4520464105..694d122372 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -2256,6 +2256,18 @@ class TestString < Test::Unit::TestCase assert_equal Encoding::UTF_8, a.encoding assert_equal Encoding::US_ASCII, b.encoding end + + def test_eq_tilde_can_be_overridden + assert_in_out_err([], <<-RUBY, ["foo"], []) + class String + def =~(str) + "foo" + end + end + + puts "" =~ // + RUBY + end end class TestString2 < TestString -- cgit v1.2.3