diff options
author | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-02-17 12:36:41 +0000 |
---|---|---|
committer | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-02-17 12:36:41 +0000 |
commit | 457c2c4a55b5896b30510ff8b39256b61b46cdf4 (patch) | |
tree | 2029f3eae8accb28962f50e2e5602f21d32a9512 /test/ruby/test_regexp.rb | |
parent | 24421c835d85bdff2a8878cab1befc3255685b67 (diff) | |
download | ruby-457c2c4a55b5896b30510ff8b39256b61b46cdf4.tar.gz |
* regcomp.c (setup_tree, onig_compile): optimize .* at last by
converting into (?>.*), which does not backtrack. [ruby-core:27791]
* test/ruby/test_regexp.rb: add a test for above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26701 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_regexp.rb')
-rw-r--r-- | test/ruby/test_regexp.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb index 4cd35d5248..06c6d1c633 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -800,4 +800,11 @@ class TestRegexp < Test::Unit::TestCase assert_nothing_raised { eval("a = 1; /\#{ a }/; a") } assert_nothing_raised { eval("a = 1; /\#{ a }/o; a") } end + + def test_optimize_last_anycharstar + s = "1" + " " * 5000000 + assert_nothing_raised { s.match(/(\d) (.*)/) } + assert_equal("1", $1) + assert_equal(" " * 4999999, $2) + end end |