Merge pull request #4508 from roc-lang/windows-final-cli-tests

Windows final cli tests
This commit is contained in:
Folkert de Vries 2022-11-16 18:21:49 +01:00 committed by GitHub
commit 0920fb4227
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 243 additions and 128 deletions

View file

@ -13,6 +13,11 @@ pub mod spaces;
use bumpalo::{collections::String, Bump};
use roc_parse::ast::Module;
#[cfg(windows)]
const NEWLINE: &str = "\r\n";
#[cfg(not(windows))]
const NEWLINE: &str = "\n";
#[derive(Debug)]
pub struct Ast<'a> {
pub module: Module<'a>,
@ -99,7 +104,9 @@ impl<'a> Buf<'a> {
pub fn newline(&mut self) {
self.spaces_to_flush = 0;
self.text.push('\n');
self.text.push_str(NEWLINE);
self.beginning_of_line = true;
}
@ -183,14 +190,14 @@ fn fmt_text_eof(text: &mut bumpalo::collections::String<'_>) {
// There's some whitespace at the end of this file, but the first
// whitespace char after the last non-whitespace char isn't a newline.
// So replace that whitespace char (and everything after it) with a newline.
text.replace_range(last_whitespace_index.., "\n");
text.replace_range(last_whitespace_index.., NEWLINE);
}
None => {
debug_assert!(last_whitespace_index == text.len());
debug_assert!(!text.ends_with(char::is_whitespace));
// This doesn't end in whitespace at all, so add a newline.
text.push('\n');
text.push_str(NEWLINE);
}
}
}