also assert_invalid fixture type

This commit is contained in:
NikVolf
2017-06-05 18:13:17 +03:00
parent b6eea87552
commit dfd6152cda
2 changed files with 23 additions and 0 deletions

View File

@ -24,6 +24,12 @@ fn setup_program(base_dir: &str, test_module_path: &str) -> (ProgramInstance, Ar
(program, module_instance)
}
fn try_load(base_dir: &str, module_path: &str) -> Result<parity_wasm::elements::Module, parity_wasm::elements::Error> {
let mut wasm_path = PathBuf::from(base_dir.clone());
wasm_path.push(module_path);
parity_wasm::deserialize_file(&wasm_path)
}
fn runtime_value(test_val: &test::RuntimeValue) -> parity_wasm::RuntimeValue {
match test_val.value_type.as_ref() {
"i32" => {
@ -130,6 +136,17 @@ pub fn spec(name: &str) {
println!("assert_trap at line {} - success ({:?})", line, e);
}
}
},
&test::Command::AssertInvalid { line, ref filename, .. } => {
let module_load = try_load(&outdir, filename);
match module_load {
Ok(result) => {
panic!("Expected invalid module definition, got some module!")
},
Err(e) => {
println!("assert_invalid at line {} - success ({:?})", line, e)
}
}
}
}
}

View File

@ -31,6 +31,12 @@ pub enum Command {
action: Action,
text: String,
},
#[serde(rename = "assert_invalid")]
AssertInvalid {
line: u64,
filename: String,
text: String,
}
}
#[derive(Deserialize, Debug)]