[前][次][番号順一覧][スレッド一覧]

ruby-changes:29741

From: knu <ko1@a...>
Date: Fri, 5 Jul 2013 16:24:23 +0900 (JST)
Subject: [ruby-changes:29741] knu:r41793 (trunk): * test/ruby/test_regexp.rb

knu	2013-07-05 16:24:10 +0900 (Fri, 05 Jul 2013)

  New Revision: 41793

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41793

  Log:
    * 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.

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_regexp.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 41792)
+++ ChangeLog	(revision 41793)
@@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
-Fri Jul  5 16:01:21 2013  Akinori MUSHA  <knu@i...>
+Fri Jul  5 16:21:56 2013  Akinori MUSHA  <knu@i...>
 
 	* test/ruby/test_regexp.rb
 	  (TestRegexp#test_options_in_look_behind)
@@ -8,6 +8,11 @@ Fri Jul  5 16:01:21 2013  Akinori MUSHA https://github.com/ruby/ruby/blob/trunk/ChangeLog#L8
 	  interpolate a regexp into another in the middle of a look-behind
 	  pattern.  cf. https://github.com/k-takata/Onigmo/pull/17
 
+	* 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.
+
 Fri Jul  5 12:14:40 2013  NAKAMURA Usaku  <usa@r...>
 
 	* test/ruby/test_rubyoptions.rb (TestRubyOptions#test_notfound): after
Index: test/ruby/test_regexp.rb
===================================================================
--- test/ruby/test_regexp.rb	(revision 41792)
+++ test/ruby/test_regexp.rb	(revision 41793)
@@ -946,19 +946,22 @@ class TestRegexp < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_regexp.rb#L946
 
   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_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_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) {

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]