Skip to content
This repository has been archived by the owner on Jan 16, 2025. It is now read-only.

Commit

Permalink
tests: Add missing version tests
Browse files Browse the repository at this point in the history
Closes #49031.

Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
  • Loading branch information
bfontaine committed Feb 10, 2016
1 parent 87d699c commit 81e4357
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
31 changes: 31 additions & 0 deletions Library/Homebrew/test/test_versions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,32 @@ def test_raises_for_non_string_objects
assert_raises(TypeError) { Version.new(1) }
assert_raises(TypeError) { Version.new(:symbol) }
end

def test_detected_from_url?
refute Version.new("1.0").detected_from_url?
assert Version::FromURL.new("1.0").detected_from_url?
end
end

class VersionTokenTests < Homebrew::TestCase
def test_inspect
assert_equal '#<Version::Token "foo">',
Version::Token.new("foo").inspect
end

def test_to_s
assert_equal "foo", Version::Token.new("foo").to_s
end
end

class VersionNullTokenTests < Homebrew::TestCase
def test_inspect
assert_equal "#<Version::NullToken>", Version::NullToken.new.inspect
end

def test_comparing_null
assert_operator Version::NullToken.new, :==, Version::NullToken.new
end
end

class VersionComparisonTests < Homebrew::TestCase
Expand Down Expand Up @@ -404,4 +430,9 @@ def test_waf_version
def test_dash_separated_version
assert_version_detected "6-20151227", "ftp://gcc.gnu.org/pub/gcc/snapshots/6-20151227/gcc-6-20151227.tar.bz2"
end

def test_from_url
assert_version_detected "1.2.3",
"http://github.com/foo/bar.git", {:tag => "v1.2.3"}
end
end
4 changes: 2 additions & 2 deletions Library/Homebrew/test/testing_env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def assert_version_equal(expected, actual)
assert_equal Version.new(expected), actual
end

def assert_version_detected(expected, url)
assert_equal expected, Version.parse(url).to_s
def assert_version_detected(expected, url, specs={})
assert_equal expected, Version.detect(url, specs).to_s
end

def assert_version_nil(url)
Expand Down

0 comments on commit 81e4357

Please sign in to comment.