Add functions with multiple arguments to import macro, add test cases
This commit is contained in:
parent
28f071e50d
commit
f110945fd6
3 changed files with 100 additions and 69 deletions
|
@ -35,10 +35,29 @@ pub fn print(string: String) {
|
|||
eprintln!("to stderr: {}", string);
|
||||
}
|
||||
|
||||
// #[import]
|
||||
// fn mystery_number(input: u32) -> u32;
|
||||
#[import]
|
||||
fn mystery_number(input: u32) -> u32;
|
||||
|
||||
// #[export]
|
||||
// pub fn and_back(secret: u32) -> u32 {
|
||||
// mystery_number(secret)
|
||||
// }
|
||||
#[export]
|
||||
pub fn and_back(secret: u32) -> u32 {
|
||||
mystery_number(secret)
|
||||
}
|
||||
|
||||
#[import]
|
||||
fn import_noop() -> ();
|
||||
|
||||
#[import]
|
||||
fn import_identity(i: u32) -> u32;
|
||||
|
||||
#[import]
|
||||
fn import_swap(a: u32, b: u32) -> (u32, u32);
|
||||
|
||||
#[export]
|
||||
pub fn imports(x: u32) -> u32 {
|
||||
let a = import_identity(7);
|
||||
import_noop();
|
||||
let (b, c) = import_swap(a, x);
|
||||
assert_eq!(a, c);
|
||||
assert_eq!(x, b);
|
||||
a + b // should be 7 + x
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue