rust/tests/coverage/async2.rs
Zalathar e96b4e479a coverage: Extract executor::block_on from several async coverage tests
By moving `block_on` to an auxiliary crate, we avoid having to keep a separate
copy of it in every async test.

(This also incorporates some small tweaks to the headers in `await_ready.rs`.)
2024-09-10 16:08:36 +10:00

36 lines
691 B
Rust

#![feature(coverage_attribute)]
#![feature(noop_waker)]
//@ edition: 2018
//@ aux-build: executor.rs
extern crate executor;
fn non_async_func() {
println!("non_async_func was covered");
let b = true;
if b {
println!("non_async_func println in block");
}
}
async fn async_func() {
println!("async_func was covered");
let b = true;
if b {
println!("async_func println in block");
}
}
async fn async_func_just_println() {
println!("async_func_just_println was covered");
}
fn main() {
println!("codecovsample::main");
non_async_func();
executor::block_on(async_func());
executor::block_on(async_func_just_println());
}