Skip to content

Commit fc06cb7

Browse files
committed
simplify async-fn tests
1 parent d5294a5 commit fc06cb7

File tree

1 file changed

+25
-28
lines changed

1 file changed

+25
-28
lines changed

tests/run-pass/async-fn.rs

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -40,38 +40,35 @@ async fn includes_never(crash: bool, x: u32) -> u32 {
4040
result
4141
}
4242

43-
fn raw_waker_clone(_this: *const ()) -> RawWaker {
44-
panic!("unimplemented");
45-
}
46-
fn raw_waker_wake(_this: *const ()) {
47-
panic!("unimplemented");
48-
}
49-
fn raw_waker_wake_by_ref(_this: *const ()) {
50-
panic!("unimplemented");
51-
}
52-
fn raw_waker_drop(_this: *const ()) {}
43+
fn run_fut(mut fut: impl Future<Output=u32>, output: u32) {
44+
fn raw_waker_clone(_this: *const ()) -> RawWaker {
45+
panic!("unimplemented");
46+
}
47+
fn raw_waker_wake(_this: *const ()) {
48+
panic!("unimplemented");
49+
}
50+
fn raw_waker_wake_by_ref(_this: *const ()) {
51+
panic!("unimplemented");
52+
}
53+
fn raw_waker_drop(_this: *const ()) {}
5354

54-
static RAW_WAKER: RawWakerVTable = RawWakerVTable::new(
55-
raw_waker_clone,
56-
raw_waker_wake,
57-
raw_waker_wake_by_ref,
58-
raw_waker_drop,
59-
);
55+
static RAW_WAKER: RawWakerVTable = RawWakerVTable::new(
56+
raw_waker_clone,
57+
raw_waker_wake,
58+
raw_waker_wake_by_ref,
59+
raw_waker_drop,
60+
);
6061

61-
fn main() {
62-
let x = 5;
63-
let mut fut = foo(&x, 7);
6462
let waker = unsafe { Waker::from_raw(RawWaker::new(ptr::null(), &RAW_WAKER)) };
6563
let mut context = Context::from_waker(&waker);
66-
assert_eq!(unsafe { Pin::new_unchecked(&mut fut) }.poll(&mut context), Poll::Ready(31));
64+
assert_eq!(unsafe { Pin::new_unchecked(&mut fut) }.poll(&mut context), Poll::Ready(output));
65+
}
6766

68-
let mut fut = build_aggregate(1, 2, 3, 4);
69-
let waker = unsafe { Waker::from_raw(RawWaker::new(ptr::null(), &RAW_WAKER)) };
70-
let mut context = Context::from_waker(&waker);
71-
assert_eq!(unsafe { Pin::new_unchecked(&mut fut) }.poll(&mut context), Poll::Ready(10));
67+
fn main() {
68+
let x = 5;
69+
run_fut(foo(&x, 7), 31);
7270

73-
let mut fut = includes_never(false, 4);
74-
let waker = unsafe { Waker::from_raw(RawWaker::new(ptr::null(), &RAW_WAKER)) };
75-
let mut context = Context::from_waker(&waker);
76-
assert_eq!(unsafe { Pin::new_unchecked(&mut fut) }.poll(&mut context), Poll::Ready(16));
71+
run_fut(build_aggregate(1, 2, 3, 4), 10);
72+
73+
run_fut(includes_never(false, 4), 16);
7774
}

0 commit comments

Comments
 (0)