]> git.lizzy.rs Git - rust.git/blob - library/core/tests/task.rs
Rollup merge of #103554 - notriddle:notriddle/summary-focus-visible, r=jsha
[rust.git] / library / core / tests / task.rs
1 use core::task::{Context, Poll, RawWaker, RawWakerVTable, Waker};
2
3 #[test]
4 fn poll_const() {
5     // test that the methods of `Poll` are usable in a const context
6
7     const POLL: Poll<usize> = Poll::Pending;
8
9     const IS_READY: bool = POLL.is_ready();
10     assert!(!IS_READY);
11
12     const IS_PENDING: bool = POLL.is_pending();
13     assert!(IS_PENDING);
14 }
15
16 #[test]
17 fn waker_const() {
18     const VOID_TABLE: RawWakerVTable = RawWakerVTable::new(|_| VOID_WAKER, |_| {}, |_| {}, |_| {});
19
20     const VOID_WAKER: RawWaker = RawWaker::new(&(), &VOID_TABLE);
21
22     static WAKER: Waker = unsafe { Waker::from_raw(VOID_WAKER) };
23
24     static CONTEXT: Context<'static> = Context::from_waker(&WAKER);
25
26     static WAKER_REF: &'static Waker = CONTEXT.waker();
27
28     WAKER_REF.wake_by_ref();
29 }