diff options
| author | John Turner <jturner.usa@gmail.com> | 2025-10-25 01:17:53 -0400 |
|---|---|---|
| committer | John Turner <jturner.usa@gmail.com> | 2025-10-25 01:17:53 -0400 |
| commit | 66d6e52b21c57da9d1207c5203bdfa635539236a (patch) | |
| tree | a0cc00c5e33036629f4bc2a45ded955227ffab9b | |
| parent | ccf7aeb98d6dcc67ce2190b7343bb4543165aeb0 (diff) | |
| download | gentoo-utils-66d6e52b21c57da9d1207c5203bdfa635539236a.tar.gz | |
verify that atoms that have versions have a version operator (and reverse)
| -rw-r--r-- | src/atom/parsers.rs | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/src/atom/parsers.rs b/src/atom/parsers.rs index e1954c0..f6fdd6c 100644 --- a/src/atom/parsers.rs +++ b/src/atom/parsers.rs @@ -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()); } |
