Skip to content

Commit

Permalink
Fix up tests and benchmark to use new get
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark McCaskey committed Jun 8, 2020
1 parent 8530e5e commit e70828e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions benches/static_and_dynamic_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ wasmer_compilers! {
},
};
let instance = Instance::new(&module, &import_object).unwrap();
let dyn_f: &Function = instance.exports.get("add").unwrap();
let f: NativeFunc<(i32, i32), i32> = dyn_f.clone().native().unwrap();
let dyn_f: Function = instance.exports.get("add").unwrap();
let f: NativeFunc<(i32, i32), i32> = dyn_f.native().unwrap();

c.bench_function(&format!("basic static func {}", COMPILER_NAME), |b| {
b.iter(|| {
Expand All @@ -47,7 +47,7 @@ wasmer_compilers! {
};
let instance = Instance::new(&module, &import_object).unwrap();

let dyn_f: &Function = instance.exports.get("add").unwrap();
let dyn_f: Function = instance.exports.get("add").unwrap();
c.bench_function(&format!("basic dynfunc {}", COMPILER_NAME), |b| {
b.iter(|| {
let dyn_result = black_box(dyn_f.call(&[Val::I32(4), Val::I32(6)]).unwrap());
Expand Down
8 changes: 4 additions & 4 deletions lib/api/tests/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,20 +181,20 @@ fn native_function_works_for_wasm() -> Result<()> {

// TODO:
//let f: NativeFunc<(i32, i32), i32> = instance.exports.get("add").unwrap();
let dyn_f: &Function = instance.exports.get("add").unwrap();
let dyn_f: Function = instance.exports.get("add").unwrap();
let dyn_result = dyn_f.call(&[Val::I32(4), Val::I32(6)]).unwrap();
assert_eq!(dyn_result[0], Val::I32(10));

let f: NativeFunc<(i32, i32), i32> = dyn_f.clone().native().unwrap();
let f: NativeFunc<(i32, i32), i32> = dyn_f.native().unwrap();

let result = f.call(4, 6).unwrap();
assert_eq!(result, 10);

let dyn_f: &Function = instance.exports.get("double_then_add").unwrap();
let dyn_f: Function = instance.exports.get("double_then_add").unwrap();
let dyn_result = dyn_f.call(&[Val::I32(4), Val::I32(6)]).unwrap();
assert_eq!(dyn_result[0], Val::I32(20));

let f: NativeFunc<(i32, i32), i32> = dyn_f.clone().native().unwrap();
let f: NativeFunc<(i32, i32), i32> = dyn_f.native().unwrap();

let result = f.call(4, 6).unwrap();
assert_eq!(result, 20);
Expand Down

0 comments on commit e70828e

Please sign in to comment.