forked from gentoo-utils/gentoo-utils
verify that atoms that have versions have a version operator (and reverse)
This commit is contained in:
@@ -216,6 +216,11 @@ pub fn atom<'a>() -> impl Parser<&'a str, Output = Atom> {
|
||||
usedeps: usedeps.unwrap_or(Vec::new()),
|
||||
},
|
||||
)
|
||||
.verify_output(|atom| match (&atom.version_operator, &atom.version) {
|
||||
(Some(_), Some(_)) => true,
|
||||
(None, None) => true,
|
||||
_ => false,
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -264,35 +269,49 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn test_atom_with_star_in_non_empty_slot() {
|
||||
let it = InputIter::new("foo/bar-1.0.0:*/subslot");
|
||||
let it = InputIter::new("foo/bar:*/subslot");
|
||||
|
||||
assert!(atom().check_finished(it).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_invalid_usedep() {
|
||||
let it = InputIter::new("foo-bar-1.0.0:slot/sub=[!use]");
|
||||
let it = InputIter::new("foo-bar:slot/sub=[!use]");
|
||||
|
||||
assert!(atom().check_finished(it).is_err())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_empty_slot() {
|
||||
let it = InputIter::new("foo/bar-1.0.0:=");
|
||||
let it = InputIter::new("foo/bar:=");
|
||||
|
||||
atom().check_finished(it).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_usedep_with_underscore() {
|
||||
let it = InputIter::new("foo/bar-1.0.0[use_dep]");
|
||||
let it = InputIter::new("foo/bar[use_dep]");
|
||||
|
||||
atom().check_finished(it).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_version_with_uppercase_letter() {
|
||||
let it = InputIter::new("foo/bar-1.0.0V");
|
||||
let it = InputIter::new("=foo/bar-1.0.0V");
|
||||
|
||||
assert!(atom().check_finished(it).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_version_with_version_operator_without_version() {
|
||||
let it = InputIter::new("=foo/bar");
|
||||
|
||||
assert!(atom().check_finished(it).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_version_with_version_without_version_operator() {
|
||||
let it = InputIter::new("foo/bar-1.0.0");
|
||||
|
||||
assert!(atom().check_finished(it).is_err());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user