summaryrefslogtreecommitdiffstats
path: root/vendor/semver/tests
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/semver/tests')
-rw-r--r--vendor/semver/tests/node/mod.rs43
-rw-r--r--vendor/semver/tests/test_autotrait.rs12
-rw-r--r--vendor/semver/tests/test_identifier.rs45
-rw-r--r--vendor/semver/tests/test_version.rs241
-rw-r--r--vendor/semver/tests/test_version_req.rs443
-rw-r--r--vendor/semver/tests/util/mod.rs39
6 files changed, 823 insertions, 0 deletions
diff --git a/vendor/semver/tests/node/mod.rs b/vendor/semver/tests/node/mod.rs
new file mode 100644
index 000000000..eb50673d5
--- /dev/null
+++ b/vendor/semver/tests/node/mod.rs
@@ -0,0 +1,43 @@
+#![cfg(test_node_semver)]
+
+use semver::Version;
+use std::fmt::{self, Display};
+use std::process::Command;
+
+#[derive(Default, Eq, PartialEq, Hash, Debug)]
+pub(super) struct VersionReq(semver::VersionReq);
+
+impl VersionReq {
+ pub(super) const STAR: Self = VersionReq(semver::VersionReq::STAR);
+
+ pub(super) fn matches(&self, version: &Version) -> bool {
+ let out = Command::new("node")
+ .arg("-e")
+ .arg(format!(
+ "console.log(require('semver').satisfies('{}', '{}'))",
+ version,
+ self.to_string().replace(',', ""),
+ ))
+ .output()
+ .unwrap();
+ if out.stdout == b"true\n" {
+ true
+ } else if out.stdout == b"false\n" {
+ false
+ } else {
+ let s = String::from_utf8_lossy(&out.stdout) + String::from_utf8_lossy(&out.stderr);
+ panic!("unexpected output: {}", s);
+ }
+ }
+}
+
+impl Display for VersionReq {
+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+ Display::fmt(&self.0, formatter)
+ }
+}
+
+#[cfg_attr(not(no_track_caller), track_caller)]
+pub(super) fn req(text: &str) -> VersionReq {
+ VersionReq(crate::util::req(text))
+}
diff --git a/vendor/semver/tests/test_autotrait.rs b/vendor/semver/tests/test_autotrait.rs
new file mode 100644
index 000000000..af8534bd7
--- /dev/null
+++ b/vendor/semver/tests/test_autotrait.rs
@@ -0,0 +1,12 @@
+fn assert_send_sync<T: Send + Sync>() {}
+
+#[test]
+fn test() {
+ assert_send_sync::<semver::BuildMetadata>();
+ assert_send_sync::<semver::Comparator>();
+ assert_send_sync::<semver::Error>();
+ assert_send_sync::<semver::Prerelease>();
+ assert_send_sync::<semver::Version>();
+ assert_send_sync::<semver::VersionReq>();
+ assert_send_sync::<semver::Op>();
+}
diff --git a/vendor/semver/tests/test_identifier.rs b/vendor/semver/tests/test_identifier.rs
new file mode 100644
index 000000000..dc888c9c1
--- /dev/null
+++ b/vendor/semver/tests/test_identifier.rs
@@ -0,0 +1,45 @@
+#![allow(
+ clippy::eq_op,
+ clippy::needless_pass_by_value,
+ clippy::toplevel_ref_arg,
+ clippy::wildcard_imports
+)]
+
+mod util;
+
+use crate::util::*;
+use semver::Prerelease;
+
+#[test]
+fn test_new() {
+ fn test(identifier: Prerelease, expected: &str) {
+ assert_eq!(identifier.is_empty(), expected.is_empty());
+ assert_eq!(identifier.len(), expected.len());
+ assert_eq!(identifier.as_str(), expected);
+ assert_eq!(identifier, identifier);
+ assert_eq!(identifier, identifier.clone());
+ }
+
+ let ref mut string = String::new();
+ let limit = if cfg!(miri) { 40 } else { 280 }; // miri is slow
+ for _ in 0..limit {
+ test(prerelease(string), string);
+ string.push('1');
+ }
+
+ if !cfg!(miri) {
+ let ref string = string.repeat(20000);
+ test(prerelease(string), string);
+ }
+}
+
+#[test]
+fn test_eq() {
+ assert_eq!(prerelease("-"), prerelease("-"));
+ assert_ne!(prerelease("a"), prerelease("aa"));
+ assert_ne!(prerelease("aa"), prerelease("a"));
+ assert_ne!(prerelease("aaaaaaaaa"), prerelease("a"));
+ assert_ne!(prerelease("a"), prerelease("aaaaaaaaa"));
+ assert_ne!(prerelease("aaaaaaaaa"), prerelease("bbbbbbbbb"));
+ assert_ne!(build_metadata("1"), build_metadata("001"));
+}
diff --git a/vendor/semver/tests/test_version.rs b/vendor/semver/tests/test_version.rs
new file mode 100644
index 000000000..93a528c19
--- /dev/null
+++ b/vendor/semver/tests/test_version.rs
@@ -0,0 +1,241 @@
+#![allow(
+ clippy::nonminimal_bool,
+ clippy::too_many_lines,
+ clippy::wildcard_imports
+)]
+
+mod util;
+
+use crate::util::*;
+use semver::{BuildMetadata, Prerelease, Version};
+
+#[test]
+fn test_parse() {
+ let err = version_err("");
+ assert_to_string(
+ err,
+ "unexpected end of input while parsing major version number",
+ );
+
+ let err = version_err(" ");
+ assert_to_string(
+ err,
+ "unexpected character ' ' while parsing major version number",
+ );
+
+ let err = version_err("1");
+ assert_to_string(
+ err,
+ "unexpected end of input while parsing major version number",
+ );
+
+ let err = version_err("1.2");
+ assert_to_string(
+ err,
+ "unexpected end of input while parsing minor version number",
+ );
+
+ let err = version_err("1.2.3-");
+ assert_to_string(err, "empty identifier segment in pre-release identifier");
+
+ let err = version_err("a.b.c");
+ assert_to_string(
+ err,
+ "unexpected character 'a' while parsing major version number",
+ );
+
+ let err = version_err("1.2.3 abc");
+ assert_to_string(err, "unexpected character ' ' after patch version number");
+
+ let err = version_err("1.2.3-01");
+ assert_to_string(err, "invalid leading zero in pre-release identifier");
+
+ let parsed = version("1.2.3");
+ let expected = Version::new(1, 2, 3);
+ assert_eq!(parsed, expected);
+ let expected = Version {
+ major: 1,
+ minor: 2,
+ patch: 3,
+ pre: Prerelease::EMPTY,
+ build: BuildMetadata::EMPTY,
+ };
+ assert_eq!(parsed, expected);
+
+ let parsed = version("1.2.3-alpha1");
+ let expected = Version {
+ major: 1,
+ minor: 2,
+ patch: 3,
+ pre: prerelease("alpha1"),
+ build: BuildMetadata::EMPTY,
+ };
+ assert_eq!(parsed, expected);
+
+ let parsed = version("1.2.3+build5");
+ let expected = Version {
+ major: 1,
+ minor: 2,
+ patch: 3,
+ pre: Prerelease::EMPTY,
+ build: build_metadata("build5"),
+ };
+ assert_eq!(parsed, expected);
+
+ let parsed = version("1.2.3+5build");
+ let expected = Version {
+ major: 1,
+ minor: 2,
+ patch: 3,
+ pre: Prerelease::EMPTY,
+ build: build_metadata("5build"),
+ };
+ assert_eq!(parsed, expected);
+
+ let parsed = version("1.2.3-alpha1+build5");
+ let expected = Version {
+ major: 1,
+ minor: 2,
+ patch: 3,
+ pre: prerelease("alpha1"),
+ build: build_metadata("build5"),
+ };
+ assert_eq!(parsed, expected);
+
+ let parsed = version("1.2.3-1.alpha1.9+build5.7.3aedf");
+ let expected = Version {
+ major: 1,
+ minor: 2,
+ patch: 3,
+ pre: prerelease("1.alpha1.9"),
+ build: build_metadata("build5.7.3aedf"),
+ };
+ assert_eq!(parsed, expected);
+
+ let parsed = version("1.2.3-0a.alpha1.9+05build.7.3aedf");
+ let expected = Version {
+ major: 1,
+ minor: 2,
+ patch: 3,
+ pre: prerelease("0a.alpha1.9"),
+ build: build_metadata("05build.7.3aedf"),
+ };
+ assert_eq!(parsed, expected);
+
+ let parsed = version("0.4.0-beta.1+0851523");
+ let expected = Version {
+ major: 0,
+ minor: 4,
+ patch: 0,
+ pre: prerelease("beta.1"),
+ build: build_metadata("0851523"),
+ };
+ assert_eq!(parsed, expected);
+
+ // for https://nodejs.org/dist/index.json, where some older npm versions are "1.1.0-beta-10"
+ let parsed = version("1.1.0-beta-10");
+ let expected = Version {
+ major: 1,
+ minor: 1,
+ patch: 0,
+ pre: prerelease("beta-10"),
+ build: BuildMetadata::EMPTY,
+ };
+ assert_eq!(parsed, expected);
+}
+
+#[test]
+fn test_eq() {
+ assert_eq!(version("1.2.3"), version("1.2.3"));
+ assert_eq!(version("1.2.3-alpha1"), version("1.2.3-alpha1"));
+ assert_eq!(version("1.2.3+build.42"), version("1.2.3+build.42"));
+ assert_eq!(version("1.2.3-alpha1+42"), version("1.2.3-alpha1+42"));
+}
+
+#[test]
+fn test_ne() {
+ assert_ne!(version("0.0.0"), version("0.0.1"));
+ assert_ne!(version("0.0.0"), version("0.1.0"));
+ assert_ne!(version("0.0.0"), version("1.0.0"));
+ assert_ne!(version("1.2.3-alpha"), version("1.2.3-beta"));
+ assert_ne!(version("1.2.3+23"), version("1.2.3+42"));
+}
+
+#[test]
+fn test_display() {
+ assert_to_string(version("1.2.3"), "1.2.3");
+ assert_to_string(version("1.2.3-alpha1"), "1.2.3-alpha1");
+ assert_to_string(version("1.2.3+build.42"), "1.2.3+build.42");
+ assert_to_string(version("1.2.3-alpha1+42"), "1.2.3-alpha1+42");
+}
+
+#[test]
+fn test_lt() {
+ assert!(version("0.0.0") < version("1.2.3-alpha2"));
+ assert!(version("1.0.0") < version("1.2.3-alpha2"));
+ assert!(version("1.2.0") < version("1.2.3-alpha2"));
+ assert!(version("1.2.3-alpha1") < version("1.2.3"));
+ assert!(version("1.2.3-alpha1") < version("1.2.3-alpha2"));
+ assert!(!(version("1.2.3-alpha2") < version("1.2.3-alpha2")));
+ assert!(version("1.2.3+23") < version("1.2.3+42"));
+}
+
+#[test]
+fn test_le() {
+ assert!(version("0.0.0") <= version("1.2.3-alpha2"));
+ assert!(version("1.0.0") <= version("1.2.3-alpha2"));
+ assert!(version("1.2.0") <= version("1.2.3-alpha2"));
+ assert!(version("1.2.3-alpha1") <= version("1.2.3-alpha2"));
+ assert!(version("1.2.3-alpha2") <= version("1.2.3-alpha2"));
+ assert!(version("1.2.3+23") <= version("1.2.3+42"));
+}
+
+#[test]
+fn test_gt() {
+ assert!(version("1.2.3-alpha2") > version("0.0.0"));
+ assert!(version("1.2.3-alpha2") > version("1.0.0"));
+ assert!(version("1.2.3-alpha2") > version("1.2.0"));
+ assert!(version("1.2.3-alpha2") > version("1.2.3-alpha1"));
+ assert!(version("1.2.3") > version("1.2.3-alpha2"));
+ assert!(!(version("1.2.3-alpha2") > version("1.2.3-alpha2")));
+ assert!(!(version("1.2.3+23") > version("1.2.3+42")));
+}
+
+#[test]
+fn test_ge() {
+ assert!(version("1.2.3-alpha2") >= version("0.0.0"));
+ assert!(version("1.2.3-alpha2") >= version("1.0.0"));
+ assert!(version("1.2.3-alpha2") >= version("1.2.0"));
+ assert!(version("1.2.3-alpha2") >= version("1.2.3-alpha1"));
+ assert!(version("1.2.3-alpha2") >= version("1.2.3-alpha2"));
+ assert!(!(version("1.2.3+23") >= version("1.2.3+42")));
+}
+
+#[test]
+fn test_spec_order() {
+ let vs = [
+ "1.0.0-alpha",
+ "1.0.0-alpha.1",
+ "1.0.0-alpha.beta",
+ "1.0.0-beta",
+ "1.0.0-beta.2",
+ "1.0.0-beta.11",
+ "1.0.0-rc.1",
+ "1.0.0",
+ ];
+ let mut i = 1;
+ while i < vs.len() {
+ let a = version(vs[i - 1]);
+ let b = version(vs[i]);
+ assert!(a < b, "nope {:?} < {:?}", a, b);
+ i += 1;
+ }
+}
+
+#[test]
+fn test_align() {
+ let version = version("1.2.3-rc1");
+ assert_eq!("1.2.3-rc1 ", format!("{:20}", version));
+ assert_eq!("*****1.2.3-rc1******", format!("{:*^20}", version));
+ assert_eq!(" 1.2.3-rc1", format!("{:>20}", version));
+}
diff --git a/vendor/semver/tests/test_version_req.rs b/vendor/semver/tests/test_version_req.rs
new file mode 100644
index 000000000..98a03ac89
--- /dev/null
+++ b/vendor/semver/tests/test_version_req.rs
@@ -0,0 +1,443 @@
+#![allow(
+ clippy::missing_panics_doc,
+ clippy::shadow_unrelated,
+ clippy::toplevel_ref_arg,
+ clippy::wildcard_imports
+)]
+
+mod node;
+mod util;
+
+use crate::util::*;
+use std::collections::hash_map::DefaultHasher;
+use std::hash::{Hash, Hasher};
+
+#[cfg(test_node_semver)]
+use node::{req, VersionReq};
+#[cfg(not(test_node_semver))]
+use semver::VersionReq;
+
+#[cfg_attr(not(no_track_caller), track_caller)]
+fn assert_match_all(req: &VersionReq, versions: &[&str]) {
+ for string in versions {
+ let parsed = version(string);
+ assert!(req.matches(&parsed), "did not match {}", string);
+ }
+}
+
+#[cfg_attr(not(no_track_caller), track_caller)]
+fn assert_match_none(req: &VersionReq, versions: &[&str]) {
+ for string in versions {
+ let parsed = version(string);
+ assert!(!req.matches(&parsed), "matched {}", string);
+ }
+}
+
+#[test]
+fn test_basic() {
+ let ref r = req("1.0.0");
+ assert_to_string(r, "^1.0.0");
+ assert_match_all(r, &["1.0.0", "1.1.0", "1.0.1"]);
+ assert_match_none(r, &["0.9.9", "0.10.0", "0.1.0", "1.0.0-pre", "1.0.1-pre"]);
+}
+
+#[test]
+#[cfg(not(no_const_vec_new))]
+fn test_default() {
+ let ref r = VersionReq::default();
+ assert_eq!(r, &VersionReq::STAR);
+}
+
+#[test]
+fn test_exact() {
+ let ref r = req("=1.0.0");
+ assert_to_string(r, "=1.0.0");
+ assert_match_all(r, &["1.0.0"]);
+ assert_match_none(r, &["1.0.1", "0.9.9", "0.10.0", "0.1.0", "1.0.0-pre"]);
+
+ let ref r = req("=0.9.0");
+ assert_to_string(r, "=0.9.0");
+ assert_match_all(r, &["0.9.0"]);
+ assert_match_none(r, &["0.9.1", "1.9.0", "0.0.9", "0.9.0-pre"]);
+
+ let ref r = req("=0.0.2");
+ assert_to_string(r, "=0.0.2");
+ assert_match_all(r, &["0.0.2"]);
+ assert_match_none(r, &["0.0.1", "0.0.3", "0.0.2-pre"]);
+
+ let ref r = req("=0.1.0-beta2.a");
+ assert_to_string(r, "=0.1.0-beta2.a");
+ assert_match_all(r, &["0.1.0-beta2.a"]);
+ assert_match_none(r, &["0.9.1", "0.1.0", "0.1.1-beta2.a", "0.1.0-beta2"]);
+
+ let ref r = req("=0.1.0+meta");
+ assert_to_string(r, "=0.1.0");
+ assert_match_all(r, &["0.1.0", "0.1.0+meta", "0.1.0+any"]);
+}
+
+#[test]
+pub fn test_greater_than() {
+ let ref r = req(">= 1.0.0");
+ assert_to_string(r, ">=1.0.0");
+ assert_match_all(r, &["1.0.0", "2.0.0"]);
+ assert_match_none(r, &["0.1.0", "0.0.1", "1.0.0-pre", "2.0.0-pre"]);
+
+ let ref r = req(">= 2.1.0-alpha2");
+ assert_to_string(r, ">=2.1.0-alpha2");
+ assert_match_all(r, &["2.1.0-alpha2", "2.1.0-alpha3", "2.1.0", "3.0.0"]);
+ assert_match_none(
+ r,
+ &["2.0.0", "2.1.0-alpha1", "2.0.0-alpha2", "3.0.0-alpha2"],
+ );
+}
+
+#[test]
+pub fn test_less_than() {
+ let ref r = req("< 1.0.0");
+ assert_to_string(r, "<1.0.0");
+ assert_match_all(r, &["0.1.0", "0.0.1"]);
+ assert_match_none(r, &["1.0.0", "1.0.0-beta", "1.0.1", "0.9.9-alpha"]);
+
+ let ref r = req("<= 2.1.0-alpha2");
+ assert_match_all(r, &["2.1.0-alpha2", "2.1.0-alpha1", "2.0.0", "1.0.0"]);
+ assert_match_none(
+ r,
+ &["2.1.0", "2.2.0-alpha1", "2.0.0-alpha2", "1.0.0-alpha2"],
+ );
+
+ let ref r = req(">1.0.0-alpha, <1.0.0");
+ assert_match_all(r, &["1.0.0-beta"]);
+
+ let ref r = req(">1.0.0-alpha, <1.0");
+ assert_match_none(r, &["1.0.0-beta"]);
+
+ let ref r = req(">1.0.0-alpha, <1");
+ assert_match_none(r, &["1.0.0-beta"]);
+}
+
+#[test]
+pub fn test_multiple() {
+ let ref r = req("> 0.0.9, <= 2.5.3");
+ assert_to_string(r, ">0.0.9, <=2.5.3");
+ assert_match_all(r, &["0.0.10", "1.0.0", "2.5.3"]);
+ assert_match_none(r, &["0.0.8", "2.5.4"]);
+
+ let ref r = req("0.3.0, 0.4.0");
+ assert_to_string(r, "^0.3.0, ^0.4.0");
+ assert_match_none(r, &["0.0.8", "0.3.0", "0.4.0"]);
+
+ let ref r = req("<= 0.2.0, >= 0.5.0");
+ assert_to_string(r, "<=0.2.0, >=0.5.0");
+ assert_match_none(r, &["0.0.8", "0.3.0", "0.5.1"]);
+
+ let ref r = req("0.1.0, 0.1.4, 0.1.6");
+ assert_to_string(r, "^0.1.0, ^0.1.4, ^0.1.6");
+ assert_match_all(r, &["0.1.6", "0.1.9"]);
+ assert_match_none(r, &["0.1.0", "0.1.4", "0.2.0"]);
+
+ let err = req_err("> 0.1.0,");
+ assert_to_string(
+ err,
+ "unexpected end of input while parsing major version number",
+ );
+
+ let err = req_err("> 0.3.0, ,");
+ assert_to_string(
+ err,
+ "unexpected character ',' while parsing major version number",
+ );
+
+ let ref r = req(">=0.5.1-alpha3, <0.6");
+ assert_to_string(r, ">=0.5.1-alpha3, <0.6");
+ assert_match_all(
+ r,
+ &[
+ "0.5.1-alpha3",
+ "0.5.1-alpha4",
+ "0.5.1-beta",
+ "0.5.1",
+ "0.5.5",
+ ],
+ );
+ assert_match_none(
+ r,
+ &["0.5.1-alpha1", "0.5.2-alpha3", "0.5.5-pre", "0.5.0-pre"],
+ );
+ assert_match_none(r, &["0.6.0", "0.6.0-pre"]);
+
+ // https://github.com/steveklabnik/semver/issues/56
+ let err = req_err("1.2.3 - 2.3.4");
+ assert_to_string(err, "expected comma after patch version number, found '-'");
+}
+
+#[test]
+pub fn test_whitespace_delimited_comparator_sets() {
+ // https://github.com/steveklabnik/semver/issues/55
+ let err = req_err("> 0.0.9 <= 2.5.3");
+ assert_to_string(err, "expected comma after patch version number, found '<'");
+}
+
+#[test]
+pub fn test_tilde() {
+ let ref r = req("~1");
+ assert_match_all(r, &["1.0.0", "1.0.1", "1.1.1"]);
+ assert_match_none(r, &["0.9.1", "2.9.0", "0.0.9"]);
+
+ let ref r = req("~1.2");
+ assert_match_all(r, &["1.2.0", "1.2.1"]);
+ assert_match_none(r, &["1.1.1", "1.3.0", "0.0.9"]);
+
+ let ref r = req("~1.2.2");
+ assert_match_all(r, &["1.2.2", "1.2.4"]);
+ assert_match_none(r, &["1.2.1", "1.9.0", "1.0.9", "2.0.1", "0.1.3"]);
+
+ let ref r = req("~1.2.3-beta.2");
+ assert_match_all(r, &["1.2.3", "1.2.4", "1.2.3-beta.2", "1.2.3-beta.4"]);
+ assert_match_none(r, &["1.3.3", "1.1.4", "1.2.3-beta.1", "1.2.4-beta.2"]);
+}
+
+#[test]
+pub fn test_caret() {
+ let ref r = req("^1");
+ assert_match_all(r, &["1.1.2", "1.1.0", "1.2.1", "1.0.1"]);
+ assert_match_none(r, &["0.9.1", "2.9.0", "0.1.4"]);
+ assert_match_none(r, &["1.0.0-beta1", "0.1.0-alpha", "1.0.1-pre"]);
+
+ let ref r = req("^1.1");
+ assert_match_all(r, &["1.1.2", "1.1.0", "1.2.1"]);
+ assert_match_none(r, &["0.9.1", "2.9.0", "1.0.1", "0.1.4"]);
+
+ let ref r = req("^1.1.2");
+ assert_match_all(r, &["1.1.2", "1.1.4", "1.2.1"]);
+ assert_match_none(r, &["0.9.1", "2.9.0", "1.1.1", "0.0.1"]);
+ assert_match_none(r, &["1.1.2-alpha1", "1.1.3-alpha1", "2.9.0-alpha1"]);
+
+ let ref r = req("^0.1.2");
+ assert_match_all(r, &["0.1.2", "0.1.4"]);
+ assert_match_none(r, &["0.9.1", "2.9.0", "1.1.1", "0.0.1"]);
+ assert_match_none(r, &["0.1.2-beta", "0.1.3-alpha", "0.2.0-pre"]);
+
+ let ref r = req("^0.5.1-alpha3");
+ assert_match_all(
+ r,
+ &[
+ "0.5.1-alpha3",
+ "0.5.1-alpha4",
+ "0.5.1-beta",
+ "0.5.1",
+ "0.5.5",
+ ],
+ );
+ assert_match_none(
+ r,
+ &[
+ "0.5.1-alpha1",
+ "0.5.2-alpha3",
+ "0.5.5-pre",
+ "0.5.0-pre",
+ "0.6.0",
+ ],
+ );
+
+ let ref r = req("^0.0.2");
+ assert_match_all(r, &["0.0.2"]);
+ assert_match_none(r, &["0.9.1", "2.9.0", "1.1.1", "0.0.1", "0.1.4"]);
+
+ let ref r = req("^0.0");
+ assert_match_all(r, &["0.0.2", "0.0.0"]);
+ assert_match_none(r, &["0.9.1", "2.9.0", "1.1.1", "0.1.4"]);
+
+ let ref r = req("^0");
+ assert_match_all(r, &["0.9.1", "0.0.2", "0.0.0"]);
+ assert_match_none(r, &["2.9.0", "1.1.1"]);
+
+ let ref r = req("^1.4.2-beta.5");
+ assert_match_all(
+ r,
+ &["1.4.2", "1.4.3", "1.4.2-beta.5", "1.4.2-beta.6", "1.4.2-c"],
+ );
+ assert_match_none(
+ r,
+ &[
+ "0.9.9",
+ "2.0.0",
+ "1.4.2-alpha",
+ "1.4.2-beta.4",
+ "1.4.3-beta.5",
+ ],
+ );
+}
+
+#[test]
+pub fn test_wildcard() {
+ let err = req_err("");
+ assert_to_string(
+ err,
+ "unexpected end of input while parsing major version number",
+ );
+
+ let ref r = req("*");
+ assert_match_all(r, &["0.9.1", "2.9.0", "0.0.9", "1.0.1", "1.1.1"]);
+ assert_match_none(r, &["1.0.0-pre"]);
+
+ for s in &["x", "X"] {
+ assert_eq!(*r, req(s));
+ }
+
+ let ref r = req("1.*");
+ assert_match_all(r, &["1.2.0", "1.2.1", "1.1.1", "1.3.0"]);
+ assert_match_none(r, &["0.0.9", "1.2.0-pre"]);
+
+ for s in &["1.x", "1.X", "1.*.*"] {
+ assert_eq!(*r, req(s));
+ }
+
+ let ref r = req("1.2.*");
+ assert_match_all(r, &["1.2.0", "1.2.2", "1.2.4"]);
+ assert_match_none(r, &["1.9.0", "1.0.9", "2.0.1", "0.1.3", "1.2.2-pre"]);
+
+ for s in &["1.2.x", "1.2.X"] {
+ assert_eq!(*r, req(s));
+ }
+}
+
+#[test]
+pub fn test_logical_or() {
+ // https://github.com/steveklabnik/semver/issues/57
+ let err = req_err("=1.2.3 || =2.3.4");
+ assert_to_string(err, "expected comma after patch version number, found '|'");
+
+ let err = req_err("1.1 || =1.2.3");
+ assert_to_string(err, "expected comma after minor version number, found '|'");
+
+ let err = req_err("6.* || 8.* || >= 10.*");
+ assert_to_string(err, "expected comma after minor version number, found '|'");
+}
+
+#[test]
+pub fn test_any() {
+ #[cfg(not(no_const_vec_new))]
+ let ref r = VersionReq::STAR;
+ #[cfg(no_const_vec_new)]
+ let ref r = VersionReq {
+ comparators: Vec::new(),
+ };
+ assert_match_all(r, &["0.0.1", "0.1.0", "1.0.0"]);
+}
+
+#[test]
+pub fn test_pre() {
+ let ref r = req("=2.1.1-really.0");
+ assert_match_all(r, &["2.1.1-really.0"]);
+}
+
+#[test]
+pub fn test_parse_errors() {
+ let err = req_err("\0");
+ assert_to_string(
+ err,
+ "unexpected character '\\0' while parsing major version number",
+ );
+
+ let err = req_err(">= >= 0.0.2");
+ assert_to_string(
+ err,
+ "unexpected character '>' while parsing major version number",
+ );
+
+ let err = req_err(">== 0.0.2");
+ assert_to_string(
+ err,
+ "unexpected character '=' while parsing major version number",
+ );
+
+ let err = req_err("a.0.0");
+ assert_to_string(
+ err,
+ "unexpected character 'a' while parsing major version number",
+ );
+
+ let err = req_err("1.0.0-");
+ assert_to_string(err, "empty identifier segment in pre-release identifier");
+
+ let err = req_err(">=");
+ assert_to_string(
+ err,
+ "unexpected end of input while parsing major version number",
+ );
+}
+
+#[test]
+fn test_cargo3202() {
+ let ref r = req("0.*.*");
+ assert_to_string(r, "0.*");
+ assert_match_all(r, &["0.5.0"]);
+
+ let ref r = req("0.0.*");
+ assert_to_string(r, "0.0.*");
+}
+
+#[test]
+fn test_digit_after_wildcard() {
+ let err = req_err("*.1");
+ assert_to_string(err, "unexpected character after wildcard in version req");
+
+ let err = req_err("1.*.1");
+ assert_to_string(err, "unexpected character after wildcard in version req");
+
+ let err = req_err(">=1.*.1");
+ assert_to_string(err, "unexpected character after wildcard in version req");
+}
+
+#[test]
+fn test_eq_hash() {
+ fn calculate_hash(value: impl Hash) -> u64 {
+ let mut hasher = DefaultHasher::new();
+ value.hash(&mut hasher);
+ hasher.finish()
+ }
+
+ assert!(req("^1") == req("^1"));
+ assert!(calculate_hash(req("^1")) == calculate_hash(req("^1")));
+ assert!(req("^1") != req("^2"));
+}
+
+#[test]
+fn test_leading_digit_in_pre_and_build() {
+ for op in &["=", ">", ">=", "<", "<=", "~", "^"] {
+ // digit then alpha
+ req(&format!("{} 1.2.3-1a", op));
+ req(&format!("{} 1.2.3+1a", op));
+
+ // digit then alpha (leading zero)
+ req(&format!("{} 1.2.3-01a", op));
+ req(&format!("{} 1.2.3+01", op));
+
+ // multiple
+ req(&format!("{} 1.2.3-1+1", op));
+ req(&format!("{} 1.2.3-1-1+1-1-1", op));
+ req(&format!("{} 1.2.3-1a+1a", op));
+ req(&format!("{} 1.2.3-1a-1a+1a-1a-1a", op));
+ }
+}
+
+#[test]
+fn test_wildcard_and_another() {
+ let err = req_err("*, 0.20.0-any");
+ assert_to_string(
+ err,
+ "wildcard req (*) must be the only comparator in the version req",
+ );
+
+ let err = req_err("0.20.0-any, *");
+ assert_to_string(
+ err,
+ "wildcard req (*) must be the only comparator in the version req",
+ );
+
+ let err = req_err("0.20.0-any, *, 1.0");
+ assert_to_string(
+ err,
+ "wildcard req (*) must be the only comparator in the version req",
+ );
+}
diff --git a/vendor/semver/tests/util/mod.rs b/vendor/semver/tests/util/mod.rs
new file mode 100644
index 000000000..5cc142c48
--- /dev/null
+++ b/vendor/semver/tests/util/mod.rs
@@ -0,0 +1,39 @@
+#![allow(dead_code)]
+
+use semver::{BuildMetadata, Error, Prerelease, Version, VersionReq};
+use std::fmt::Display;
+
+#[cfg_attr(not(no_track_caller), track_caller)]
+pub(super) fn version(text: &str) -> Version {
+ Version::parse(text).unwrap()
+}
+
+#[cfg_attr(not(no_track_caller), track_caller)]
+pub(super) fn version_err(text: &str) -> Error {
+ Version::parse(text).unwrap_err()
+}
+
+#[cfg_attr(not(no_track_caller), track_caller)]
+pub(super) fn req(text: &str) -> VersionReq {
+ VersionReq::parse(text).unwrap()
+}
+
+#[cfg_attr(not(no_track_caller), track_caller)]
+pub(super) fn req_err(text: &str) -> Error {
+ VersionReq::parse(text).unwrap_err()
+}
+
+#[cfg_attr(not(no_track_caller), track_caller)]
+pub(super) fn prerelease(text: &str) -> Prerelease {
+ Prerelease::new(text).unwrap()
+}
+
+#[cfg_attr(not(no_track_caller), track_caller)]
+pub(super) fn build_metadata(text: &str) -> BuildMetadata {
+ BuildMetadata::new(text).unwrap()
+}
+
+#[cfg_attr(not(no_track_caller), track_caller)]
+pub(super) fn assert_to_string(value: impl Display, expected: &str) {
+ assert_eq!(value.to_string(), expected);
+}