Add Waker::will_wake tests
Currently fails: ---- task::test_waker_will_wake_clone stdout ---- thread 'task::test_waker_will_wake_clone' panicked at library/alloc/tests/task.rs:17:5: assertion failed: waker.will_wake(&clone)
This commit is contained in:
parent
0250ef2571
commit
793b45f53a
@ -41,6 +41,7 @@
|
|||||||
#![feature(thin_box)]
|
#![feature(thin_box)]
|
||||||
#![feature(strict_provenance)]
|
#![feature(strict_provenance)]
|
||||||
#![feature(drain_keep_rest)]
|
#![feature(drain_keep_rest)]
|
||||||
|
#![feature(local_waker)]
|
||||||
#![allow(internal_features)]
|
#![allow(internal_features)]
|
||||||
#![deny(fuzzy_provenance_casts)]
|
#![deny(fuzzy_provenance_casts)]
|
||||||
#![deny(unsafe_op_in_unsafe_fn)]
|
#![deny(unsafe_op_in_unsafe_fn)]
|
||||||
@ -62,6 +63,7 @@
|
|||||||
mod slice;
|
mod slice;
|
||||||
mod str;
|
mod str;
|
||||||
mod string;
|
mod string;
|
||||||
|
mod task;
|
||||||
mod thin_box;
|
mod thin_box;
|
||||||
mod vec;
|
mod vec;
|
||||||
mod vec_deque;
|
mod vec_deque;
|
||||||
|
34
library/alloc/tests/task.rs
Normal file
34
library/alloc/tests/task.rs
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
use alloc::rc::Rc;
|
||||||
|
use alloc::sync::Arc;
|
||||||
|
use alloc::task::{LocalWake, Wake};
|
||||||
|
use core::task::{LocalWaker, Waker};
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_waker_will_wake_clone() {
|
||||||
|
struct NoopWaker;
|
||||||
|
|
||||||
|
impl Wake for NoopWaker {
|
||||||
|
fn wake(self: Arc<Self>) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
let waker = Waker::from(Arc::new(NoopWaker));
|
||||||
|
let clone = waker.clone();
|
||||||
|
|
||||||
|
assert!(waker.will_wake(&clone));
|
||||||
|
assert!(clone.will_wake(&waker));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_local_waker_will_wake_clone() {
|
||||||
|
struct NoopWaker;
|
||||||
|
|
||||||
|
impl LocalWake for NoopWaker {
|
||||||
|
fn wake(self: Rc<Self>) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
let waker = LocalWaker::from(Rc::new(NoopWaker));
|
||||||
|
let clone = waker.clone();
|
||||||
|
|
||||||
|
assert!(waker.will_wake(&clone));
|
||||||
|
assert!(clone.will_wake(&waker));
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user