mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 16:44:33 +00:00
Fix wasm REPL tests
This commit is contained in:
parent
e37d0c45c6
commit
a99f9fee14
2 changed files with 21 additions and 7 deletions
|
@ -140,19 +140,33 @@ fn run(src: &'static str) -> String {
|
||||||
};
|
};
|
||||||
|
|
||||||
let len = Value::I32(src.len() as i32);
|
let len = Value::I32(src.len() as i32);
|
||||||
assert!(instance
|
instance.call_export("entrypoint_from_test", [len]).unwrap();
|
||||||
.call_export("entrypoint_from_test", [len])
|
|
||||||
.unwrap()
|
|
||||||
.is_none());
|
|
||||||
instance.import_dispatcher.answer.to_owned()
|
instance.import_dispatcher.answer.to_owned()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn expect_success(input: &'static str, expected: &str) {
|
pub fn expect_success(input: &'static str, expected: &str) {
|
||||||
assert_eq!(run(input), expected.to_string());
|
expect(input, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn expect_failure(input: &'static str, expected: &str) {
|
pub fn expect_failure(input: &'static str, expected: &str) {
|
||||||
assert_eq!(run(input), expected.to_string());
|
expect(input, expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub fn expect(input: &'static str, expected: &str) {
|
||||||
|
let raw_output = run(input);
|
||||||
|
|
||||||
|
// We need to get rid of HTML tags, and we can be quite specific about it!
|
||||||
|
// If we ever write more complex test cases, we might need regex here.
|
||||||
|
let without_html = raw_output
|
||||||
|
.replace("<span class='color-magenta'> : </span>", " : ")
|
||||||
|
.replace("<span class='color-green'> # val1</span>", "");
|
||||||
|
|
||||||
|
// Whitespace that was originally in front of the `# val1` is now at the end,
|
||||||
|
// and there's other whitespace at both ends too. Trim it all.
|
||||||
|
let clean_output = without_html.trim();
|
||||||
|
|
||||||
|
assert_eq!(clean_output, expected);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,4 +12,4 @@ set -euxo pipefail
|
||||||
RUSTFLAGS="" cargo build --locked --profile release-with-lto --target wasm32-wasi -p roc_repl_wasm --no-default-features --features wasi_test
|
RUSTFLAGS="" cargo build --locked --profile release-with-lto --target wasm32-wasi -p roc_repl_wasm --no-default-features --features wasi_test
|
||||||
|
|
||||||
# Build & run the test code on *native* target, not WebAssembly
|
# Build & run the test code on *native* target, not WebAssembly
|
||||||
cargo test --locked --release -p repl_test --features wasm
|
cargo test --locked --release -p repl_test --features wasm $@
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue