1
0
mirror of https://github.com/actix/actix synced 2024-11-30 17:14:36 +01:00

fix tests (#495)

This commit is contained in:
fakeshadow 2021-05-18 02:52:13 +08:00 committed by GitHub
parent 69be546a0f
commit 25266356d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 20 deletions

View File

@ -53,8 +53,12 @@ impl Handler<TestMessageOne> for TestActorTwo {
#[test] #[test]
fn it_all_works() { fn it_all_works() {
System::new().block_on(async { let sys = System::new();
sys.block_on(async {
TestActorOne.start(); TestActorOne.start();
TestActorTwo.start(); TestActorTwo.start();
}) });
sys.run().unwrap();
} }

View File

@ -100,11 +100,15 @@ where
/// } /// }
/// # impl Actor for Actor2 { /// # impl Actor for Actor2 {
/// # type Context = Context<Self>; /// # type Context = Context<Self>;
/// #
/// # fn started(&mut self, _: &mut Self::Context) {
/// # System::current().stop();
/// # }
/// # } /// # }
/// ///
/// # fn main() { /// # fn main() {
/// # let mut sys = System::new(); /// # let sys = System::new();
/// # System::new().block_on(async { /// # sys.block_on(async {
/// let ctx1 = Context::<Actor1>::new(); /// let ctx1 = Context::<Actor1>::new();
/// let ctx2 = Context::<Actor2>::new(); /// let ctx2 = Context::<Actor2>::new();
/// ///
@ -114,6 +118,7 @@ where
/// ctx1.run(actor1); /// ctx1.run(actor1);
/// ctx2.run(actor2); /// ctx2.run(actor2);
/// # }); /// # });
/// # sys.run().unwrap();
/// # } /// # }
/// ``` /// ```
#[inline] #[inline]

View File

@ -148,9 +148,13 @@ impl Actor for WeakRecipientRunner {
#[test] #[test]
fn test_weak_recipient() { fn test_weak_recipient() {
System::new().block_on(async move { let sys = System::new();
sys.block_on(async move {
WeakRecipientRunner.start(); WeakRecipientRunner.start();
}); });
sys.run().unwrap();
} }
#[test] #[test]

View File

@ -3,13 +3,6 @@ use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc; use std::sync::Arc;
use tokio::sync::oneshot; use tokio::sync::oneshot;
#[derive(Debug)]
struct Panic();
impl Message for Panic {
type Result = ();
}
#[derive(Debug)] #[derive(Debug)]
struct Ping(usize); struct Ping(usize);
@ -33,14 +26,6 @@ impl Handler<Ping> for MyActor {
} }
} }
impl Handler<Panic> for MyActor {
type Result = ();
fn handle(&mut self, _: Panic, _: &mut actix::Context<MyActor>) {
panic!("Whoops!");
}
}
#[test] #[test]
fn test_start_actor_message() { fn test_start_actor_message() {
let count = Arc::new(AtomicUsize::new(0)); let count = Arc::new(AtomicUsize::new(0));