diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-15 00:28:17 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-15 00:28:17 +0000 |
commit | f5074060307bd27c8d0c7efa1b431db9a5f44a3c (patch) | |
tree | 47de8455071f3332c881b623a48f9ed60d843e2d /test/ruby/test_rubyoptions.rb | |
parent | c52283934ed11c4e55bd93257f99c19bc201fb29 (diff) |
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
Diffstat (limited to 'test/ruby/test_rubyoptions.rb')
-rw-r--r-- | test/ruby/test_rubyoptions.rb | 14 |
1 files changed, 8 insertions, 6 deletions
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 |