coverage: Add a test for #[coverage(..)]
on closures
This commit is contained in:
parent
fe420dc46e
commit
8dd2b37462
3 changed files with 119 additions and 0 deletions
42
tests/coverage/coverage_attr_closure.rs
Normal file
42
tests/coverage/coverage_attr_closure.rs
Normal file
|
@ -0,0 +1,42 @@
|
|||
#![feature(coverage_attribute, stmt_expr_attributes)]
|
||||
#![allow(dead_code)]
|
||||
// edition: 2021
|
||||
|
||||
static GLOBAL_CLOSURE_ON: fn(&str) = #[coverage(on)]
|
||||
|input: &str| {
|
||||
println!("{input}");
|
||||
};
|
||||
static GLOBAL_CLOSURE_OFF: fn(&str) = #[coverage(off)]
|
||||
|input: &str| {
|
||||
println!("{input}");
|
||||
};
|
||||
|
||||
#[coverage(on)]
|
||||
fn contains_closures_on() {
|
||||
let _local_closure_on = #[coverage(on)]
|
||||
|input: &str| {
|
||||
println!("{input}");
|
||||
};
|
||||
let _local_closure_off = #[coverage(off)]
|
||||
|input: &str| {
|
||||
println!("{input}");
|
||||
};
|
||||
}
|
||||
|
||||
#[coverage(off)]
|
||||
fn contains_closures_off() {
|
||||
let _local_closure_on = #[coverage(on)]
|
||||
|input: &str| {
|
||||
println!("{input}");
|
||||
};
|
||||
let _local_closure_off = #[coverage(off)]
|
||||
|input: &str| {
|
||||
println!("{input}");
|
||||
};
|
||||
}
|
||||
|
||||
#[coverage(off)]
|
||||
fn main() {
|
||||
contains_closures_on();
|
||||
contains_closures_off();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue