#![cfg(all(feature = "std", feature = "time", feature = "smol"))]
use agnostic_lite::{LocalRuntimeLite, RuntimeLite, smol::SmolRuntime};
mod generic_only {
use core::{
future::{Ready, ready},
marker::PhantomData,
time::Duration,
};
use agnostic_lite::RuntimeLite;
pub fn every_former_member_resolves<R: RuntimeLite>() {
let _: R = R::new();
let _: &'static str = R::name();
let _: &'static str = R::fqname();
let _ = PhantomData::<R::LocalSpawner>;
let _ = PhantomData::<R::BlockingSpawner>;
let _ = PhantomData::<R::Spawner>;
let _ = PhantomData::<R::AfterSpawner>;
let _: u32 = R::block_on(async { 7 });
let _handle = R::spawn_local(async { 7u32 });
R::spawn_local_detach(async {});
let _handle = R::spawn_blocking(|| 7u32);
R::spawn_blocking_detach(|| {});
let _now: R::Instant = R::now();
let _interval: R::LocalInterval = R::interval_local(Duration::from_secs(1));
let _interval: R::LocalInterval = R::interval_local_at(R::now(), Duration::from_secs(1));
let _sleep: R::LocalSleep = R::sleep_local(Duration::from_secs(1));
let _sleep: R::LocalSleep = R::sleep_local_until(R::now());
let _delay: R::LocalDelay<Ready<()>> = R::delay_local(Duration::from_secs(1), ready(()));
let _delay: R::LocalDelay<Ready<()>> = R::delay_local_at(R::now(), ready(()));
let _timeout: R::LocalTimeout<Ready<()>> = R::timeout_local(Duration::from_secs(1), ready(()));
let _timeout: R::LocalTimeout<Ready<()>> = R::timeout_local_at(R::now(), ready(()));
let _handle = R::spawn(async { 7u32 });
R::spawn_detach(async {});
let _yield = R::yield_now();
let _handle = R::spawn_after(Duration::from_secs(1), async { 7u32 });
let _handle = R::spawn_after_at(R::now(), async { 7u32 });
let _interval: R::Interval = R::interval(Duration::from_secs(1));
let _interval: R::Interval = R::interval_at(R::now(), Duration::from_secs(1));
let _sleep: R::Sleep = R::sleep(Duration::from_secs(1));
let _sleep: R::Sleep = R::sleep_until(R::now());
let _delay: R::Delay<Ready<()>> = R::delay(Duration::from_secs(1), ready(()));
let _delay: R::Delay<Ready<()>> = R::delay_at(R::now(), ready(()));
let _timeout: R::Timeout<Ready<()>> = R::timeout(Duration::from_secs(1), ready(()));
let _timeout: R::Timeout<Ready<()>> = R::timeout_at(R::now(), ready(()));
let _sleep: R::Sleep = <R as RuntimeLite>::sleep(Duration::from_secs(1));
}
pub fn block_on_reaches_the_moved_core<R: RuntimeLite>() -> u32 {
R::block_on(async { 7 })
}
}
fn ufcs_names_the_owning_trait<R: RuntimeLite>() -> &'static str {
<R as LocalRuntimeLite>::name()
}
#[test]
fn generic_scope_reaches_every_former_member() {
let _ = generic_only::every_former_member_resolves::<SmolRuntime> as fn();
assert_eq!(
generic_only::block_on_reaches_the_moved_core::<SmolRuntime>(),
7
);
}
#[test]
fn concrete_calls_resolve_with_the_core_trait_in_scope() {
assert_eq!(ufcs_names_the_owning_trait::<SmolRuntime>(), "smol");
assert_eq!(SmolRuntime::name(), "smol");
let out = SmolRuntime::block_on(async { 7u32 });
assert_eq!(out, 7);
}