mirror of
https://github.com/roc-lang/roc.git
synced 2024-09-21 15:59:20 +03:00
Fix repl multiline string test
This commit is contained in:
parent
212090769f
commit
664526a167
@ -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");
|
||||
|
@ -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]
|
||||
|
Loading…
Reference in New Issue
Block a user