Files
wasmtime/crates/lightbeam/tests/wrongs.rs
Dan Gohman e691bf36f3 Reorganize tests (#523)
* Refactor Lightbeam's tests.

This refactors Lightbeam's tests.rs file into several pieces, separating
quickcheck tests into their own file, and moving tests which can be run as
wast tests into `tests/misc_testsuite`, and creating a tests directory
for the rest.

* Remove the old filetests tests.

These are all covered by misc_testsuite and spec_testsuite tests.

* rustfmt

* Remove the "bench" feature.
2019-11-08 16:16:12 -06:00

46 lines
901 B
Rust

use lightbeam::{translate, ExecutableModule, ExecutionError};
fn translate_wat(wat: &str) -> ExecutableModule {
let wasm = wat::parse_str(wat).unwrap();
let compiled = translate(&wasm).unwrap();
compiled
}
#[test]
fn wrong_type() {
let code = r#"
(module
(func (param i32) (param i64) (result i32)
(i32.const 228)
)
)
"#;
let translated = translate_wat(code);
assert_eq!(
translated
.execute_func::<_, ()>(0, (0u32, 0u32))
.unwrap_err(),
ExecutionError::TypeMismatch
);
}
#[test]
fn wrong_index() {
let code = r#"
(module
(func (param i32) (param i64) (result i32)
(i32.const 228)
)
)
"#;
let translated = translate_wat(code);
assert_eq!(
translated
.execute_func::<_, ()>(10, (0u32, 0u32))
.unwrap_err(),
ExecutionError::FuncIndexOutOfBounds
);
}