1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
nobu 2016-03-15 00:28:17 +00:00
parent c52283934e
commit f507406030

View file

@ -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