From b9eea5f325845973c483f24115ac078b539078de Mon Sep 17 00:00:00 2001 From: Ben-PH Date: Wed, 22 Jan 2025 14:45:43 +0100 Subject: [PATCH] auto-fix `clipp::bool_assert_comparison` --- nexosim/src/channel/queue.rs | 4 +- nexosim/src/executor/task/tests/general.rs | 76 +++++++++++----------- 2 files changed, 40 insertions(+), 40 deletions(-) diff --git a/nexosim/src/channel/queue.rs b/nexosim/src/channel/queue.rs index 832a9ab..6c15c58 100644 --- a/nexosim/src/channel/queue.rs +++ b/nexosim/src/channel/queue.rs @@ -493,12 +493,12 @@ mod tests { fn queue_closed_by_consumer() { let (p, mut c) = queue(3); - assert_eq!(p.is_closed(), false); + assert!(!p.is_closed()); assert!(p.push(|b| RecycleBox::recycle(b, 42)).is_ok()); c.close(); - assert_eq!(p.is_closed(), true); + assert!(p.is_closed()); assert!(matches!( p.push(|b| RecycleBox::recycle(b, 13)), Err(PushError::Closed) diff --git a/nexosim/src/executor/task/tests/general.rs b/nexosim/src/executor/task/tests/general.rs index c5d3421..0937ac9 100644 --- a/nexosim/src/executor/task/tests/general.rs +++ b/nexosim/src/executor/task/tests/general.rs @@ -164,13 +164,13 @@ fn task_schedule() { let (future, future_is_alive, output_is_alive) = MonitoredFuture::new(async move { 42 }); let (promise, runnable, _cancel_token) = spawn(future, schedule_runnable, ()); - assert_eq!(future_is_alive.get(), true); - assert_eq!(output_is_alive.get(), false); + assert!(future_is_alive.get()); + assert!(!output_is_alive.get()); // The task should complete immediately when ran. runnable.run(); - assert_eq!(future_is_alive.get(), false); - assert_eq!(output_is_alive.get(), true); + assert!(!future_is_alive.get()); + assert!(output_is_alive.get()); assert_eq!(promise.poll().map(|v| *v), Stage::Ready(42)); } @@ -200,13 +200,13 @@ fn task_schedule_and_forget() { let (future, future_is_alive, output_is_alive) = MonitoredFuture::new(async {}); let (runnable, _cancel_token) = spawn_and_forget(future, schedule_runnable, ()); - assert_eq!(future_is_alive.get(), true); - assert_eq!(output_is_alive.get(), false); + assert!(future_is_alive.get()); + assert!(!output_is_alive.get()); // The task should complete immediately when ran. runnable.run(); - assert_eq!(future_is_alive.get(), false); - assert_eq!(output_is_alive.get(), true); + assert!(!future_is_alive.get()); + assert!(output_is_alive.get()); } #[test] @@ -222,16 +222,16 @@ fn task_wake() { runnable.run(); // The future should have been polled but should not have completed. - assert_eq!(output_is_alive.get(), false); + assert!(!output_is_alive.get()); assert!(promise.poll().is_pending()); // Wake the task. sender.send(42).unwrap(); // The task should have been scheduled by the channel sender. - assert_eq!(run_scheduled_runnable(), true); - assert_eq!(future_is_alive.get(), false); - assert_eq!(output_is_alive.get(), true); + assert!(run_scheduled_runnable()); + assert!(!future_is_alive.get()); + assert!(output_is_alive.get()); assert_eq!(promise.poll().map(|v| *v), Stage::Ready(42)); } @@ -279,15 +279,15 @@ fn task_wake_and_forget() { runnable.run(); // The future should have been polled but should not have completed. - assert_eq!(output_is_alive.get(), false); + assert!(!output_is_alive.get()); // Wake the task. sender.send(42).unwrap(); // The task should have been scheduled by the channel sender. - assert_eq!(run_scheduled_runnable(), true); - assert_eq!(future_is_alive.get(), false); - assert_eq!(output_is_alive.get(), true); + assert!(run_scheduled_runnable()); + assert!(!future_is_alive.get()); + assert!(output_is_alive.get()); } #[test] @@ -316,7 +316,7 @@ fn task_multiple_wake() { sender.try_send(3).unwrap(); // The task should have been scheduled by the channel sender. - assert_eq!(run_scheduled_runnable(), true); + assert!(run_scheduled_runnable()); assert!(promise.poll().is_pending()); // The channel should be empty. Wake the task 2 more times. @@ -324,11 +324,11 @@ fn task_multiple_wake() { sender.try_send(5).unwrap(); // The task should have been scheduled by the channel sender. - assert_eq!(run_scheduled_runnable(), true); + assert!(run_scheduled_runnable()); // The task should have completed. - assert_eq!(future_is_alive.get(), false); - assert_eq!(output_is_alive.get(), true); + assert!(!future_is_alive.get()); + assert!(output_is_alive.get()); assert_eq!(promise.poll().map(|v| *v), Stage::Ready(15)); } @@ -396,13 +396,13 @@ fn task_cancel_scheduled() { // The future should not be dropped while the `Runnable` exists, even if the // task is cancelled, but the task should be seen as cancelled. - assert_eq!(future_is_alive.get(), true); + assert!(future_is_alive.get()); assert!(promise.poll().is_cancelled()); // An attempt to run the task should now drop the future without polling it. runnable.run(); - assert_eq!(future_is_alive.get(), false); - assert_eq!(output_is_alive.get(), false); + assert!(!future_is_alive.get()); + assert!(!output_is_alive.get()); } #[test] @@ -417,8 +417,8 @@ fn task_cancel_unscheduled() { let (promise, runnable, cancel_token) = spawn(future, schedule_runnable, ()); runnable.run(); - assert_eq!(future_is_alive.get(), true); - assert_eq!(output_is_alive.get(), false); + assert!(future_is_alive.get()); + assert!(!output_is_alive.get()); // Cancel the task while no `Runnable` exists (the task is not scheduled as // it needs to be woken by the channel sender first). @@ -428,8 +428,8 @@ fn task_cancel_unscheduled() { // The future should be dropped immediately upon cancellation without // completing. - assert_eq!(future_is_alive.get(), false); - assert_eq!(output_is_alive.get(), false); + assert!(!future_is_alive.get()); + assert!(!output_is_alive.get()); } #[test] @@ -440,12 +440,12 @@ fn task_cancel_completed() { let (promise, runnable, cancel_token) = spawn(future, schedule_runnable, ()); runnable.run(); - assert_eq!(future_is_alive.get(), false); - assert_eq!(output_is_alive.get(), true); + assert!(!future_is_alive.get()); + assert!(output_is_alive.get()); // Cancel the already completed task. cancel_token.cancel(); - assert_eq!(output_is_alive.get(), true); + assert!(output_is_alive.get()); assert_eq!(promise.poll().map(|v| *v), Stage::Ready(42)); } @@ -474,8 +474,8 @@ fn task_drop_promise_scheduled() { // The task should complete immediately when ran. runnable.run(); - assert_eq!(future_is_alive.get(), false); - assert_eq!(output_is_alive.get(), true); + assert!(!future_is_alive.get()); + assert!(output_is_alive.get()); } #[test] @@ -499,9 +499,9 @@ fn task_drop_promise_unscheduled() { assert!(sender.send(()).is_ok()); // The task should have been scheduled by the channel sender. - assert_eq!(run_scheduled_runnable(), true); - assert_eq!(future_is_alive.get(), false); - assert_eq!(output_is_alive.get(), true); + assert!(run_scheduled_runnable()); + assert!(!future_is_alive.get()); + assert!(output_is_alive.get()); } #[test] @@ -533,9 +533,9 @@ fn task_drop_runnable() { assert!(sender.send(()).is_ok()); // Drop the task scheduled by the channel sender. - assert_eq!(drop_runnable(), true); - assert_eq!(future_is_alive.get(), false); - assert_eq!(output_is_alive.get(), false); + assert!(drop_runnable()); + assert!(!future_is_alive.get()); + assert!(!output_is_alive.get()); assert!(promise.poll().is_cancelled()); }