Add a script to dump an AST using docker.
This commit is contained in:
@@ -2,7 +2,7 @@ use std::borrow::Cow;
|
||||
|
||||
/// Removes all whitespace from a string if any line breaks are present.
|
||||
///
|
||||
/// Example: "foo bar" => "foo bar" but "foo \n bar" => "foobar".
|
||||
/// Example: "foo bar" => "foo bar" but "foo \n bar" => "foobar".
|
||||
pub(crate) fn remove_whitespace_if_line_break(input: &str) -> Cow<'_, str> {
|
||||
let mut state = RemoveWhitespaceIfLineBreakState::Normal;
|
||||
for (offset, c) in input.char_indices() {
|
||||
@@ -78,7 +78,7 @@ enum RemoveLineBreakState {
|
||||
|
||||
/// Removes all whitespace from a string if any line breaks are present.
|
||||
///
|
||||
/// Example: "foo bar" => "foo bar" but "foo \n bar" => "foobar".
|
||||
/// Example: "foo bar" => "foo bar" but "foo \n bar" => "foo bar".
|
||||
pub(crate) fn coalesce_whitespace_if_line_break(input: &str) -> Cow<'_, str> {
|
||||
let mut state = CoalesceWhitespaceIfLineBreakState::Normal;
|
||||
for (offset, c) in input.char_indices() {
|
||||
@@ -515,4 +515,25 @@ mod tests {
|
||||
assert!(matches!(output, Cow::Borrowed(_)));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_coalesce_whitespace_if_line_break() -> Result<(), Box<dyn std::error::Error>> {
|
||||
assert_eq!(coalesce_whitespace_if_line_break("foo bar"), "foo bar");
|
||||
assert_eq!(coalesce_whitespace_if_line_break("foo \n bar"), "foo bar");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_remove_whitespace_if_line_break() -> Result<(), Box<dyn std::error::Error>> {
|
||||
assert_eq!(remove_whitespace_if_line_break("foo bar"), "foo bar");
|
||||
assert_eq!(remove_whitespace_if_line_break("foo \n bar"), "foobar");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_remove_line_break() -> Result<(), Box<dyn std::error::Error>> {
|
||||
assert_eq!(remove_line_break("foo bar"), "foo bar");
|
||||
assert_eq!(remove_line_break("foo \n bar"), "foo bar");
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user