From f5074060307bd27c8d0c7efa1b431db9a5f44a3c Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 15 Mar 2016 00:28:17 +0000 Subject: test_rubyoptions.rb: VERSION_PATTERN * test/ruby/test_rubyoptions.rb (VERSION_PATTERN): make the pattern at loading, and escape regexp meta characters. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54107 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_rubyoptions.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'test/ruby') diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb index ba23604bb6..1705839bd7 100644 --- a/test/ruby/test_rubyoptions.rb +++ b/test/ruby/test_rubyoptions.rb @@ -84,18 +84,20 @@ class TestRubyOptions < Test::Unit::TestCase "", %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::TestCase 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 -- cgit v1.2.3