mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
clippy
This commit is contained in:
parent
eaa0824347
commit
e9e4e710e2
2 changed files with 8 additions and 10 deletions
|
@ -132,7 +132,7 @@ pub fn expect_success(input: &str, expected: &str) {
|
|||
// The state.rs tests do that!
|
||||
let mut iter = out.stdout.lines().rev();
|
||||
let line = iter.next().unwrap();
|
||||
let comment_index = line.rfind("#").unwrap_or_else(|| line.len());
|
||||
let comment_index = line.rfind('#').unwrap_or(line.len());
|
||||
let line_without_comment = line[0..comment_index].trim_end();
|
||||
|
||||
// Sometimes the "# val1" wraps around to its own line; if this happens,
|
||||
|
|
|
@ -112,22 +112,21 @@ fn complete(input: &str, state: &mut ReplState, expected_step_result: Result<(&s
|
|||
|
||||
match state.step(input) {
|
||||
Ok(string) => {
|
||||
let escaped = std::string::String::from_utf8(
|
||||
strip_ansi_escapes::strip(string.trim()).unwrap().into(),
|
||||
)
|
||||
.unwrap();
|
||||
let escaped =
|
||||
std::string::String::from_utf8(strip_ansi_escapes::strip(string.trim()).unwrap())
|
||||
.unwrap();
|
||||
|
||||
let comment_index = escaped.rfind('#').unwrap_or_else(|| escaped.len());
|
||||
let comment_index = escaped.rfind('#').unwrap_or(escaped.len());
|
||||
|
||||
assert_eq!(
|
||||
expected_step_result.map(|(starts_with, _)| starts_with),
|
||||
Ok(*&escaped[0..comment_index].trim())
|
||||
Ok(escaped[0..comment_index].trim())
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
expected_step_result.map(|(_, ends_with)| ends_with),
|
||||
// +1 because we want to skip over the '#' itself
|
||||
Ok(*&escaped[comment_index + 1..].trim())
|
||||
Ok(escaped[comment_index + 1..].trim())
|
||||
);
|
||||
}
|
||||
Err(err) => {
|
||||
|
@ -150,8 +149,7 @@ fn error(input: &str, state: &mut ReplState, expected_step_result: String) {
|
|||
assert!(!is_incomplete(input));
|
||||
|
||||
let escaped = state.step(input).map(|string| {
|
||||
std::string::String::from_utf8(strip_ansi_escapes::strip(string.trim()).unwrap().into())
|
||||
.unwrap()
|
||||
std::string::String::from_utf8(strip_ansi_escapes::strip(string.trim()).unwrap()).unwrap()
|
||||
});
|
||||
|
||||
assert_eq!(Ok(expected_step_result), escaped);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue