use qubit_clock::{
TokioMonotonicClock,
TokioRuntimeError,
};
use std::error::Error;
#[test]
fn test_tokio_runtime_error_retains_runtime_lookup_source() {
let error = TokioMonotonicClock::try_current()
.expect_err("construction outside a runtime should fail");
assert!(
error
.to_string()
.starts_with("no Tokio runtime is entered:"),
"error should identify the missing ambient runtime"
);
let source = error
.source()
.and_then(|source| {
source.downcast_ref::<tokio::runtime::TryCurrentError>()
})
.expect("Tokio lookup error should remain in the source chain");
assert!(source.is_missing_context());
}
#[test]
fn test_tokio_runtime_error_implements_std_error() {
fn assert_error<T: Error>() {}
assert_error::<TokioRuntimeError>();
}