Fix repl multiline string test

This commit is contained in:
Richard Feldman 2022-10-31 07:05:18 -04:00
parent 212090769f
commit 664526a167
No known key found for this signature in database
GPG Key ID: F1F21AA5B1D9E43B
2 changed files with 24 additions and 13 deletions

View File

@ -9,10 +9,10 @@ use roc_test_utils::assert_multiline_str_eq;
const ERROR_MESSAGE_START: char = '─';
#[derive(Debug)]
struct Out {
stdout: String,
stderr: String,
status: ExitStatus,
pub struct Out {
pub stdout: String,
pub stderr: String,
pub status: ExitStatus,
}
fn path_to_roc_binary() -> PathBuf {
@ -39,7 +39,7 @@ fn path_to_roc_binary() -> PathBuf {
path
}
fn repl_eval(input: &str) -> Out {
pub fn repl_eval(input: &str) -> Out {
let mut cmd = Command::new(path_to_roc_binary());
cmd.arg("repl");

View File

@ -1,6 +1,8 @@
#[allow(unused_imports)]
use indoc::indoc;
use roc_test_utils::assert_multiline_str_eq;
use crate::cli::repl_eval;
#[cfg(not(feature = "wasm"))]
use crate::cli::{expect_failure, expect_success};
@ -562,19 +564,28 @@ fn four_element_record() {
#[test]
fn multiline_string() {
// If a string contains newlines, format it as a multiline string in the output
expect_success(
r#""\n\nhi!\n\n""#,
indoc!(
r#""""
// If a string contains newlines, format it as a multiline string in the output.
// We can't use expect_success to test this, because it only looks at the last
// line of output, and in this case we care about every line of output!
let out = repl_eval(r#""\n\nhi!\n\n""#);
let expected = indoc!(
r#""""
hi!
""" : Str"#
),
);
assert_multiline_str_eq!("", out.stderr.as_str());
// Don't consider the auto variable name ("# val1") at the end.
// The state.rs tests do that!
assert_multiline_str_eq!(expected, out.stdout.replace("# val1", "").trim());
assert!(out.status.success());
}
#[test]