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

ruby-changes:64253

From: Koichi <ko1@a...>
Date: Fri, 18 Dec 2020 09:14:33 +0900 (JST)
Subject: [ruby-changes:64253] 51c2725dc6 (master): use eval to create different Regexp objects

https://git.ruby-lang.org/ruby.git/commit/?id=51c2725dc6

From 51c2725dc646030283d01ce23a32c06f0f1c8bf6 Mon Sep 17 00:00:00 2001
From: Koichi Sasada <ko1@a...>
Date: Fri, 18 Dec 2020 09:12:26 +0900
Subject: use eval to create different Regexp objects

Only one warning is shown for the same Regexp object, so create
different objects to support repeating tests.

http://ci.rvm.jp/results/trunk-repeat20@phosphorus-docker/3290658

diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb
index a237460..6daae50 100644
--- a/test/ruby/test_regexp.rb
+++ b/test/ruby/test_regexp.rb
@@ -561,7 +561,10 @@ class TestRegexp < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_regexp.rb#L561
     assert_equal("bc", /../.match('abc', -2)[0])
     assert_nil(/../.match("abc", -4))
     assert_nil(/../.match("abc", 4))
-    assert_equal('\x', assert_warning(/binary regexp/) {/../n.match("\u3042" + '\x', 1)}[0])
+
+    # use eval because only one warning is shown for the same regexp literal
+    pat = eval('/../n')
+    assert_equal('\x', assert_warning(/binary regexp/) {pat.match("\u3042" + '\x', 1)}[0])
 
     r = nil
     /.../.match("abc") {|m| r = m[0] }
@@ -726,7 +729,9 @@ class TestRegexp < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_regexp.rb#L729
   end
 
   def test_rindex_regexp
-    assert_equal(3, assert_warning(/binary regexp/) {"foobarbaz\u3042".rindex(/b../n, 5)})
+    # use eval because only one warning is shown for the same regexp literal
+    pat = eval('/b../n')
+    assert_equal(3, assert_warning(/binary regexp/) {"foobarbaz\u3042".rindex(pat, 5)})
   end
 
   def assert_regexp(re, ss, fs = [], msg = nil)
-- 
cgit v0.10.2


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

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