summaryrefslogtreecommitdiff
path: root/test/ruby/test_regexp.rb
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-05 07:24:10 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-05 07:24:10 +0000
commitb3c40d5b9bc92a5afe55e2f14ef7e14434cd85a9 (patch)
tree85ee49b503ceb10c2ce5a311afccd8d82bd9df5a /test/ruby/test_regexp.rb
parenta62ee369a1cd9e141518c2d145a5e6dfc5362d9f (diff)
* test/ruby/test_regexp.rb
(TestRegexp#test_options_in_look_behind) (TestRegexp#assert_match_at): Parse regexps in run time rather than in compile time. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41793 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_regexp.rb')
-rw-r--r--test/ruby/test_regexp.rb21
1 files changed, 12 insertions, 9 deletions
diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb
index 2bfbd9dff9..11e86ec09d 100644
--- a/test/ruby/test_regexp.rb
+++ b/test/ruby/test_regexp.rb
@@ -946,19 +946,22 @@ class TestRegexp < Test::Unit::TestCase
def test_options_in_look_behind
assert_nothing_raised {
- assert_match_at(/(?<=(?i)ab)cd/, "ABcd", [[2,4]])
- assert_match_at(/(?<=(?i:ab))cd/, "ABcd", [[2,4]])
- assert_match_at(/(?<!(?i)ab)cd/, "aacd", [[2,4]])
- assert_match_at(/(?<!(?i:ab))cd/, "aacd", [[2,4]])
-
- assert_not_match(/(?<=(?i)ab)cd/, "ABCD")
- assert_not_match(/(?<=(?i:ab))cd/, "ABCD")
- assert_not_match(/(?<!(?i)ab)cd/, "ABcd")
- assert_not_match(/(?<!(?i:ab))cd/, "ABcd")
+ assert_match_at("(?<=(?i)ab)cd", "ABcd", [[2,4]])
+ assert_match_at("(?<=(?i:ab))cd", "ABcd", [[2,4]])
+ assert_match_at("(?<!(?i)ab)cd", "aacd", [[2,4]])
+ assert_match_at("(?<!(?i:ab))cd", "aacd", [[2,4]])
+
+ assert_not_match("(?<=(?i)ab)cd", "ABCD")
+ assert_not_match("(?<=(?i:ab))cd", "ABCD")
+ assert_not_match("(?<!(?i)ab)cd", "ABcd")
+ assert_not_match("(?<!(?i:ab))cd", "ABcd")
}
end
+ # This assertion is for porting x2() tests in testpy.py of Onigmo.
def assert_match_at(re, str, positions, msg = nil)
+ re = Regexp.new(re) unless re.is_a?(Regexp)
+
match = re.match(str)
assert_not_nil match, message(msg) {