Rebrand to Galaxy, major improvements to Bedrock support, still needs some TLC though

This commit is contained in:
Ryan Ward
2026-05-07 11:29:34 -05:00
parent f4e2475c60
commit a41cbd8cc7
2433 changed files with 14208 additions and 9409 deletions
+32
View File
@@ -0,0 +1,32 @@
use crate::on_cancel::OnCancelFutureExt;
use futures_util::future::{AbortHandle, Abortable, Aborted};
use std::sync::atomic::{AtomicBool, Ordering};
#[test]
fn test_ready_future_doesnt_call_callback() {
let callback_called = AtomicBool::new(false);
let future = async {}.on_cancel(|| callback_called.store(true, Ordering::SeqCst));
galaxyui::r#async::block_on(future);
assert!(!callback_called.load(Ordering::Relaxed));
}
#[test]
fn test_aborted_future_calls_callback() {
let callback_called = AtomicBool::new(false);
let (handle, registration) = AbortHandle::new_pair();
let future = Abortable::new(
async {}.on_cancel(|| callback_called.store(true, Ordering::SeqCst)),
registration,
);
// Abort the future before it is ever polled.
handle.abort();
let future_result = galaxyui::r#async::block_on(future);
// The future should be aborted and the callback should have been called.
assert_eq!(future_result, Err(Aborted));
assert!(callback_called.load(Ordering::Relaxed));
}