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.
This commit is contained in:
committed by
Alex Crichton
parent
0f4f9d7832
commit
e691bf36f3
45
crates/lightbeam/tests/wrongs.rs
Normal file
45
crates/lightbeam/tests/wrongs.rs
Normal file
@@ -0,0 +1,45 @@
|
||||
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
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user