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

ruby-changes:42033

From: nobu <ko1@a...>
Date: Tue, 15 Mar 2016 09:28:21 +0900 (JST)
Subject: [ruby-changes:42033] nobu:r54107 (trunk): test_rubyoptions.rb: VERSION_PATTERN

nobu	2016-03-15 09:28:17 +0900 (Tue, 15 Mar 2016)

  New Revision: 54107

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54107

  Log:
    test_rubyoptions.rb: VERSION_PATTERN
    
    * test/ruby/test_rubyoptions.rb (VERSION_PATTERN): make the
      pattern at loading, and escape regexp meta characters.

  Modified files:
    trunk/test/ruby/test_rubyoptions.rb
Index: test/ruby/test_rubyoptions.rb
===================================================================
--- test/ruby/test_rubyoptions.rb	(revision 54106)
+++ test/ruby/test_rubyoptions.rb	(revision 54107)
@@ -84,18 +84,20 @@ class TestRubyOptions < Test::Unit::Test https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rubyoptions.rb#L84
                       "", %w(true), [])
   end
 
-  private def version_match
+  q = Regexp.method(:quote)
+  VERSION_PATTERN =
     case RUBY_ENGINE
     when 'jruby'
-      /^jruby #{RUBY_ENGINE_VERSION} \(#{RUBY_VERSION}\).*? \[#{RbConfig::CONFIG["host_os"]}-#{RbConfig::CONFIG["host_cpu"]}\]$/
+      /^jruby #{q[RUBY_ENGINE_VERSION]} \(#{q[RUBY_VERSION]}\).*? \[#{
+        q[RbConfig::CONFIG["host_os"]]}-#{q[RbConfig::CONFIG["host_cpu"]]}\]$/
     else
-      /^ruby #{RUBY_VERSION}(?:[p ]|dev|rc).*? \[#{RUBY_PLATFORM}\]$/
+      /^ruby #{q[RUBY_VERSION]}(?:[p ]|dev|rc).*? \[#{q[RUBY_PLATFORM]}\]$/
     end
-  end
+  private_constant :VERSION_PATTERN
 
   def test_verbose
     assert_in_out_err(["-vve", ""]) do |r, e|
-      assert_match(version_match, r[0])
+      assert_match(VERSION_PATTERN, r[0])
       assert_equal(RUBY_DESCRIPTION, r[0])
       assert_equal([], e)
     end
@@ -151,7 +153,7 @@ class TestRubyOptions < Test::Unit::Test https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rubyoptions.rb#L153
 
   def test_version
     assert_in_out_err(%w(--version)) do |r, e|
-      assert_match(version_match, r[0])
+      assert_match(VERSION_PATTERN, r[0])
       assert_equal(RUBY_DESCRIPTION, r[0])
       assert_equal([], e)
     end

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

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