Use assert_matches!

This commit is contained in:
Sergey Pepyakin 2018-05-24 12:33:43 +03:00
parent a82f03eace
commit 166af4306d
2 changed files with 8 additions and 8 deletions

View File

@ -5,3 +5,4 @@ authors = ["Sergey Pepyakin <s.pepyakin@gmail.com>"]
[dependencies] [dependencies]
wasmi = { path = ".." } wasmi = { path = ".." }
assert_matches = "1.2"

View File

@ -2,6 +2,8 @@
extern crate test; extern crate test;
extern crate wasmi; extern crate wasmi;
#[macro_use]
extern crate assert_matches;
use std::error; use std::error;
use std::fs::File; use std::fs::File;
@ -28,17 +30,14 @@ fn bench_tiny_keccak(b: &mut Bencher) {
.expect("failed to instantiate wasm module") .expect("failed to instantiate wasm module")
.assert_no_start(); .assert_no_start();
let test_data = match instance let test_data_ptr = assert_matches!(
.invoke_export("prepare_tiny_keccak", &[], &mut NopExternals) instance.invoke_export("prepare_tiny_keccak", &[], &mut NopExternals),
.unwrap() Ok(Some(v @ RuntimeValue::I32(_))) => v
{ );
Some(v @ RuntimeValue::I32(_)) => v,
_ => panic!(),
};
b.iter(|| { b.iter(|| {
instance instance
.invoke_export("bench_tiny_keccak", &[test_data], &mut NopExternals) .invoke_export("bench_tiny_keccak", &[test_data_ptr], &mut NopExternals)
.unwrap(); .unwrap();
}); });
} }