-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
116c83e
commit 6b0c0bd
Showing
3 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
mod multiply; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/// A simple function to multiply by 2 a i32 value and return the result | ||
#[test_log::test] | ||
pub fn multiply() { | ||
use wasm::{validate, RuntimeInstance}; | ||
|
||
let wat = r#" | ||
(module | ||
(func (export "multiply") (param $x i32) (result i32) | ||
local.get $x | ||
i32.const 2 | ||
i32.mul) | ||
) | ||
"#; | ||
|
||
let wasm_bytes = wat::parse_str(wat).unwrap(); | ||
|
||
let validation_info = validate(&wasm_bytes).expect("validation failed"); | ||
|
||
let mut instance = RuntimeInstance::new(&validation_info).expect("instantiation failed"); | ||
|
||
assert_eq!(22, instance.invoke_func(0, 11)); | ||
assert_eq!(0, instance.invoke_func(0, 0)); | ||
assert_eq!(-20, instance.invoke_func(0, -10)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
mod arithmetic; |