wasmer/lib/emscripten-tests/src/lib.rs

28 lines
989 B
Rust
Raw Normal View History

2019-07-09 20:41:40 +00:00
#[cfg(test)]
mod tests {
use std::sync::Arc;
use wabt::wat2wasm;
use wasmer_emscripten::is_emscripten_module;
2019-11-21 21:36:44 +00:00
use wasmer_runtime::compile;
2019-07-09 20:41:40 +00:00
#[test]
fn should_detect_emscripten_files() {
const WAST_BYTES: &[u8] = include_bytes!("tests/is_emscripten_true.wast");
let wasm_binary = wat2wasm(WAST_BYTES.to_vec()).expect("Can't convert to wasm");
let module =
2019-11-21 21:36:44 +00:00
compile(&wasm_binary[..]).expect("WASM can't be compiled");
2019-07-09 20:41:40 +00:00
let module = Arc::new(module);
assert!(is_emscripten_module(&module));
}
#[test]
fn should_detect_non_emscripten_files() {
const WAST_BYTES: &[u8] = include_bytes!("tests/is_emscripten_false.wast");
let wasm_binary = wat2wasm(WAST_BYTES.to_vec()).expect("Can't convert to wasm");
let module =
2019-11-21 21:36:44 +00:00
compile(&wasm_binary[..]).expect("WASM can't be compiled");
2019-07-09 20:41:40 +00:00
let module = Arc::new(module);
assert!(!is_emscripten_module(&module));
}
}