Skip to content

Commit

Permalink
expr: Remove useless arg in enum variant
Browse files Browse the repository at this point in the history
  • Loading branch information
RenjiSann committed Feb 25, 2025
1 parent a172060 commit 481a155
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 29 deletions.
4 changes: 2 additions & 2 deletions src/uu/expr/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ pub enum ExprError {
UnmatchedOpeningBrace,
#[error("Unmatched ) or \\}}")]
UnmatchedClosingBrace,
#[error("Invalid content of {0}")]
InvalidContent(String),
#[error("Invalid content of \\{{\\}}")]
InvalidContent,
}

impl UError for ExprError {
Expand Down
34 changes: 8 additions & 26 deletions src/uu/expr/src/syntax_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ fn check_posix_regex_errors(pattern: &str) -> ExprResult<()> {
(true, true, false) => Ok(()),
(_, false, _) => Err(ExprError::UnmatchedOpeningBrace),
(false, _, _) => Err(ExprError::UnmatchedOpeningParenthesis),
(true, true, true) => Err(ExprError::InvalidContent(r"\{\}".to_string())),
(true, true, true) => Err(ExprError::InvalidContent),
}
}

Expand Down Expand Up @@ -793,38 +793,20 @@ mod test {

#[test]
fn check_regex_empty_repeating_pattern() {
assert_eq!(
check_posix_regex_errors("ab\\{\\}"),
Err(InvalidContent(r"\{\}".to_string()))
)
assert_eq!(check_posix_regex_errors("ab\\{\\}"), Err(InvalidContent))
}

#[test]
fn check_regex_intervals_two_numbers() {
assert_eq!(
// out of order
check_posix_regex_errors("ab\\{1,0\\}"),
Err(InvalidContent(r"\{\}".to_string()))
);
assert_eq!(
check_posix_regex_errors("ab\\{1,a\\}"),
Err(InvalidContent(r"\{\}".to_string()))
);
assert_eq!(
check_posix_regex_errors("ab\\{a,3\\}"),
Err(InvalidContent(r"\{\}".to_string()))
);
assert_eq!(
check_posix_regex_errors("ab\\{a,b\\}"),
Err(InvalidContent(r"\{\}".to_string()))
);
assert_eq!(
check_posix_regex_errors("ab\\{a,\\}"),
Err(InvalidContent(r"\{\}".to_string()))
);
assert_eq!(
check_posix_regex_errors("ab\\{,b\\}"),
Err(InvalidContent(r"\{\}".to_string()))
Err(InvalidContent)
);
assert_eq!(check_posix_regex_errors("ab\\{1,a\\}"), Err(InvalidContent));
assert_eq!(check_posix_regex_errors("ab\\{a,3\\}"), Err(InvalidContent));
assert_eq!(check_posix_regex_errors("ab\\{a,b\\}"), Err(InvalidContent));
assert_eq!(check_posix_regex_errors("ab\\{a,\\}"), Err(InvalidContent));
assert_eq!(check_posix_regex_errors("ab\\{,b\\}"), Err(InvalidContent));
}
}
2 changes: 1 addition & 1 deletion tests/by-util/test_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ mod gnu_expr {
.stdout_only("\n");
}

#[ignore]
#[ignore = "rust-onig bug, see https://github.com/rust-onig/rust-onig/issues/188"]
#[test]
fn test_bre10() {
new_ucmd!()
Expand Down

0 comments on commit 481a155

Please sign in to comment.