aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-12-31 23:17:45 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-12-31 23:17:45 +0000
commit74ca4f53127a71b7f4ef37d1175ac275d9799b4d (patch)
tree14ec6ad32d26e208e85a5a8cc6b202f08f910a56
parent6fb4e54a49ac3d61626737bf6286a6e5bbed389c (diff)
downloadpaludis-74ca4f53127a71b7f4ef37d1175ac275d9799b4d.tar.gz
paludis-74ca4f53127a71b7f4ef37d1175ac275d9799b4d.tar.xz
Distinguish between 1.0 and 1.0.0 in versions. Fixes: Gentoo#152127
-rw-r--r--paludis/version_spec.cc11
-rw-r--r--paludis/version_spec_TEST.cc37
-rwxr-xr-xruby/environment_TEST_setup.sh4
3 files changed, 22 insertions, 30 deletions
diff --git a/paludis/version_spec.cc b/paludis/version_spec.cc
index ba4caa3..586d718 100644
--- a/paludis/version_spec.cc
+++ b/paludis/version_spec.cc
@@ -102,6 +102,9 @@ VersionSpec::VersionSpec(const std::string & text) :
{
Context c("When parsing version spec '" + text + "':");
+ if (text.empty())
+ throw BadVersionSpecError(text);
+
/* set us up with some sane defaults */
_imp->text = text;
@@ -140,14 +143,6 @@ VersionSpec::VersionSpec(const std::string & text) :
}
_imp->parts.push_back(Part(number, x));
- while (_imp->parts.size() > 1)
- {
- if (0 == _imp->parts[_imp->parts.size() - 1].value)
- _imp->parts.pop_back();
- else
- break;
- }
-
/* letter */
if (p < text.length())
if (text.at(p) >= 'a' && text.at(p) <= 'z')
diff --git a/paludis/version_spec_TEST.cc b/paludis/version_spec_TEST.cc
index d49c4ff..0ee9299 100644
--- a/paludis/version_spec_TEST.cc
+++ b/paludis/version_spec_TEST.cc
@@ -66,7 +66,7 @@ namespace test_cases
VersionSpec v20("1_rc1-r1");
VersionSpec v21("1_p1-r1");
VersionSpec v22("1_alpha_p");
-
+ VersionSpec v23("scm");
TEST_CHECK(true);
}
@@ -82,6 +82,7 @@ namespace test_cases
void run()
{
+ TEST_CHECK_THROWS(VersionSpec v1(""), BadVersionSpecError);
TEST_CHECK_THROWS(VersionSpec v1("b"), BadVersionSpecError);
TEST_CHECK_THROWS(VersionSpec v1("1-r1_pre"), BadVersionSpecError);
TEST_CHECK_THROWS(VersionSpec v1("1-pre"), BadVersionSpecError);
@@ -104,9 +105,9 @@ namespace test_cases
void run()
{
VersionSpec v("1.2.3");
- TEST_CHECK(v == VersionSpec("1.2.3.0"));
+ TEST_CHECK(v == VersionSpec("1.2.3"));
VersionSpec v1("1.2_pre2-r1");
- TEST_CHECK(v1 == VersionSpec("1.2.0_pre2-r1"));
+ TEST_CHECK(v1 == VersionSpec("1.2_pre2-r1"));
}
} test_version_spec_parse;
@@ -248,11 +249,11 @@ namespace test_cases
void run()
{
- TEST_CHECK(VersionSpec("0").hash_value() == VersionSpec("0.0").hash_value());
- TEST_CHECK(VersionSpec("1").hash_value() == VersionSpec("1.0").hash_value());
- TEST_CHECK(VersionSpec("1.0").hash_value() == VersionSpec("1").hash_value());
- TEST_CHECK(VersionSpec("1.0_alpha").hash_value() == VersionSpec("1_alpha").hash_value());
- TEST_CHECK(VersionSpec("1_alpha").hash_value() == VersionSpec("1.0_alpha").hash_value());
+ TEST_CHECK(VersionSpec("0").hash_value() != VersionSpec("0.0").hash_value());
+ TEST_CHECK(VersionSpec("1").hash_value() != VersionSpec("1.0").hash_value());
+ TEST_CHECK(VersionSpec("1.0").hash_value() != VersionSpec("1").hash_value());
+ TEST_CHECK(VersionSpec("1.0_alpha").hash_value() != VersionSpec("1_alpha").hash_value());
+ TEST_CHECK(VersionSpec("1_alpha").hash_value() != VersionSpec("1.0_alpha").hash_value());
}
} test_version_spec_hash_value;
@@ -271,18 +272,12 @@ namespace test_cases
void run()
{
- TEST_CHECK(VersionSpec("1.0") == VersionSpec("1"));
- TEST_CHECK(VersionSpec("1") == VersionSpec("1.0"));
- TEST_CHECK(! (VersionSpec("1") < VersionSpec("1.0")));
- TEST_CHECK(! (VersionSpec("1") > VersionSpec("1.0")));
- TEST_CHECK(! (VersionSpec("1.0") < VersionSpec("1")));
- TEST_CHECK(! (VersionSpec("1.0") > VersionSpec("1")));
- TEST_CHECK(VersionSpec("1.0_alpha") == VersionSpec("1_alpha"));
- TEST_CHECK(VersionSpec("1_alpha") == VersionSpec("1.0_alpha"));
- TEST_CHECK(! (VersionSpec("1_alpha") < VersionSpec("1.0_alpha")));
- TEST_CHECK(! (VersionSpec("1_alpha") > VersionSpec("1.0_alpha")));
- TEST_CHECK(! (VersionSpec("1.0_alpha") < VersionSpec("1_alpha")));
- TEST_CHECK(! (VersionSpec("1.0_alpha") > VersionSpec("1_alpha")));
+ TEST_CHECK(VersionSpec("1.0") > VersionSpec("1"));
+ TEST_CHECK(VersionSpec("1") < VersionSpec("1.0"));
+ TEST_CHECK(VersionSpec("1.0_alpha") > VersionSpec("1_alpha"));
+ TEST_CHECK(VersionSpec("1.0_alpha") > VersionSpec("1"));
+ TEST_CHECK(VersionSpec("1.0_alpha") < VersionSpec("1.0"));
+ TEST_CHECK(VersionSpec("1.2.0.0_alpha7-r4") > VersionSpec("1.2_alpha7-r4"));
std::vector<VersionSpec> v;
v.push_back(VersionSpec("1_alpha"));
@@ -314,6 +309,8 @@ namespace test_cases
v.push_back(VersionSpec("1_p1"));
v.push_back(VersionSpec("1-try2"));
v.push_back(VersionSpec("1p"));
+ v.push_back(VersionSpec("1.0"));
+ v.push_back(VersionSpec("1.0a"));
v.push_back(VersionSpec("1.1_alpha3"));
v.push_back(VersionSpec("1.1"));
v.push_back(VersionSpec("1.1-r1"));
diff --git a/ruby/environment_TEST_setup.sh b/ruby/environment_TEST_setup.sh
index c5403d1..e7ac099 100755
--- a/ruby/environment_TEST_setup.sh
+++ b/ruby/environment_TEST_setup.sh
@@ -16,12 +16,12 @@ END
cat <<END > home/.paludis/keywords.conf
* test
-~foo/bar-1 ~test
+~foo/bar-1.0 ~test
END
cat <<END > home/.paludis/use.conf
* enabled
-~foo/bar-1 sometimes_enabled
+~foo/bar-1.0 sometimes_enabled
END
cat <<END > home/.paludis/package_mask.conf