From dfd6152cda9d6673956f4355fd4376db96094eb6 Mon Sep 17 00:00:00 2001 From: NikVolf Date: Mon, 5 Jun 2017 18:13:17 +0300 Subject: [PATCH] also assert_invalid fixture type --- spec/src/run.rs | 17 +++++++++++++++++ spec/src/test.rs | 6 ++++++ 2 files changed, 23 insertions(+) diff --git a/spec/src/run.rs b/spec/src/run.rs index 92d7d7d..b943580 100644 --- a/spec/src/run.rs +++ b/spec/src/run.rs @@ -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 { + 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) + } + } } } } diff --git a/spec/src/test.rs b/spec/src/test.rs index 614ecca..baa21c9 100644 --- a/spec/src/test.rs +++ b/spec/src/test.rs @@ -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)]