23 lines
806 B
Rust
23 lines
806 B
Rust
// file: crates/ksp-logging-lib/unit_tests/span.rs
|
|
// version: 1
|
|
|
|
#[test]
|
|
fn synchronous_scope_returns_operation_value() {
|
|
let span = crate::Span::__from_tracing(tracing::info_span!("unit_test_span"));
|
|
let value = span.in_scope(|| -> u32 {
|
|
return 42;
|
|
});
|
|
assert_eq!(value, 42);
|
|
}
|
|
|
|
#[test]
|
|
fn async_instrumentation_returns_future_output() {
|
|
let span = crate::Span::__from_tracing(tracing::info_span!("unit_test_async_span"));
|
|
let future = crate::instrument(span, std::future::ready(42_u32));
|
|
let mut future = std::boxed::Box::pin(future);
|
|
let waker = std::task::Waker::noop();
|
|
let mut context = std::task::Context::from_waker(waker);
|
|
let poll = std::future::Future::poll(future.as_mut(), &mut context);
|
|
assert_eq!(poll, std::task::Poll::Ready(42_u32));
|
|
}
|