verify that slot exprs have either a primary slot name or operator

This commit is contained in:
John Turner
2025-11-17 19:01:39 +00:00
parent 803f727082
commit 0cc3ac8e84

View File

@@ -185,6 +185,12 @@ impl<'a> Parseable<'a, &'a str> for Slot {
sub,
operator,
})
.verify_output(|slot| {
matches!(
(&slot.primary(), &slot.operator()),
(Some(_) | None, Some(_)) | (Some(_), None)
)
})
}
}
@@ -420,9 +426,9 @@ mod test {
#[test]
fn test_empty_slot() {
let it = InputIter::new("foo/bar:=");
let it = InputIter::new("=dev-ml/uucp-17*:");
Atom::parser().check_finished(it).unwrap();
assert!(Atom::parser().check_finished(it).is_err());
}
#[test]
@@ -494,4 +500,11 @@ mod test {
assert!(Cpv::parser().parse_finished(it).is_err());
}
#[test]
fn test_empty_slot_with_operator() {
let it = InputIter::new("foo/bar:=");
Atom::parser().check_finished(it).unwrap();
}
}