From a9574d48b020e2b6f3195a17b212de45e65e6b51 Mon Sep 17 00:00:00 2001 From: Baptiste Fontaine Date: Wed, 10 Feb 2016 15:03:40 +0100 Subject: [PATCH] tests: Add missing version tests --- Library/Homebrew/test/test_versions.rb | 31 ++++++++++++++++++++++++++ Library/Homebrew/test/testing_env.rb | 4 ++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/test/test_versions.rb b/Library/Homebrew/test/test_versions.rb index d0b57a5313e5..d88d89b6c174 100644 --- a/Library/Homebrew/test/test_versions.rb +++ b/Library/Homebrew/test/test_versions.rb @@ -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.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.new.inspect + end + + def test_comparing_null + assert_operator Version::NullToken.new, :==, Version::NullToken.new + end end class VersionComparisonTests < Homebrew::TestCase @@ -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 diff --git a/Library/Homebrew/test/testing_env.rb b/Library/Homebrew/test/testing_env.rb index 2aaf20c3f021..d0c1d500dc99 100644 --- a/Library/Homebrew/test/testing_env.rb +++ b/Library/Homebrew/test/testing_env.rb @@ -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)