also add an async fn test
This commit is contained in:
parent
8d6472a76c
commit
7fe24a2b86
1 changed files with 35 additions and 0 deletions
35
tests/run-pass-fullmir/async-fn.rs
Normal file
35
tests/run-pass-fullmir/async-fn.rs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
#![feature(
|
||||
async_await,
|
||||
await_macro,
|
||||
futures_api,
|
||||
pin,
|
||||
)]
|
||||
|
||||
use std::{future::Future, pin::Pin, task::Poll};
|
||||
|
||||
// See if we can run a basic `async fn`
|
||||
pub async fn foo(x: &u32, y: u32) -> u32 {
|
||||
let y = &y;
|
||||
let z = 9;
|
||||
let z = &z;
|
||||
let y = await!(async { *y + *z });
|
||||
let a = 10;
|
||||
let a = &a;
|
||||
*x + y + *a
|
||||
}
|
||||
|
||||
fn main() {
|
||||
use std::{sync::Arc, task::{Wake, local_waker}};
|
||||
|
||||
struct NoWake;
|
||||
impl Wake for NoWake {
|
||||
fn wake(_arc_self: &Arc<Self>) {
|
||||
panic!();
|
||||
}
|
||||
}
|
||||
|
||||
let lw = unsafe { local_waker(Arc::new(NoWake)) };
|
||||
let x = 5;
|
||||
let mut fut = foo(&x, 7);
|
||||
assert_eq!(unsafe { Pin::new_unchecked(&mut fut) }.poll(&lw), Poll::Ready(31));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue