New test for Boost version style

1_39_0 becomes 1.39.0
This commit is contained in:
Max Howell 2009-05-25 11:57:12 +01:00
parent bdc02ad696
commit bff155932d
2 changed files with 9 additions and 2 deletions

View File

@ -44,8 +44,10 @@ class Formula
filename=File.basename url
i=filename.index /[-_]\d/
unless i.nil?
/^((\d+[.-])*\d+)/.match filename[i+1,1000] #1000 because rubysucks
@version = $1
/^((\d+[._])*(\d+-)?\d+)/.match filename[i+1,1000] #1000 because rubysucks
@version=$1
# if there are no dots replace underscores, boost do this, the bastards!
@version.gsub!('_', '.') unless @version.include? '.'
else
# no divisor or a '.' divisor, eg. dmd.1.11.zip
/^[a-zA-Z._-]*((\d+\.)*\d+)/.match filename

View File

@ -16,6 +16,11 @@ class BeerTasting < Test::Unit::TestCase
assert_equal '1.1', r.version
end
def test_version_underscores_all_the_way
r=Formula.new "http://example.com/boost_1_39_0.tar.bz2", 'nomd5'
assert_equal '1.39.0', r.version
end
def test_version_internal_dash
r=Formula.new "http://example.com/foo-arse-1.1-2.tar.gz", 'nomd5'
assert_equal '1.1-2', r.version