about summary refs log tree commit diff
path: root/tests/coverage/coverage_attr_closure.coverage
diff options
context:
space:
mode:
Diffstat (limited to 'tests/coverage/coverage_attr_closure.coverage')
-rw-r--r--tests/coverage/coverage_attr_closure.coverage43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/coverage/coverage_attr_closure.coverage b/tests/coverage/coverage_attr_closure.coverage
new file mode 100644
index 00000000000..32c75b40d83
--- /dev/null
+++ b/tests/coverage/coverage_attr_closure.coverage
@@ -0,0 +1,43 @@
+   LL|       |#![feature(coverage_attribute, stmt_expr_attributes)]
+   LL|       |#![allow(dead_code)]
+   LL|       |// edition: 2021
+   LL|       |
+   LL|       |static GLOBAL_CLOSURE_ON: fn(&str) = #[coverage(on)]
+   LL|      0||input: &str| {
+   LL|      0|    println!("{input}");
+   LL|      0|};
+   LL|       |static GLOBAL_CLOSURE_OFF: fn(&str) = #[coverage(off)]
+   LL|       ||input: &str| {
+   LL|       |    println!("{input}");
+   LL|       |};
+   LL|       |
+   LL|       |#[coverage(on)]
+   LL|      1|fn contains_closures_on() {
+   LL|      1|    let _local_closure_on = #[coverage(on)]
+   LL|      1|    |input: &str| {
+   LL|      0|        println!("{input}");
+   LL|      1|    };
+   LL|      1|    let _local_closure_off = #[coverage(off)]
+   LL|      1|    |input: &str| {
+   LL|       |        println!("{input}");
+   LL|      1|    };
+   LL|      1|}
+   LL|       |
+   LL|       |#[coverage(off)]
+   LL|       |fn contains_closures_off() {
+   LL|       |    let _local_closure_on = #[coverage(on)]
+   LL|      0|    |input: &str| {
+   LL|      0|        println!("{input}");
+   LL|      0|    };
+   LL|       |    let _local_closure_off = #[coverage(off)]
+   LL|       |    |input: &str| {
+   LL|       |        println!("{input}");
+   LL|       |    };
+   LL|       |}
+   LL|       |
+   LL|       |#[coverage(off)]
+   LL|       |fn main() {
+   LL|       |    contains_closures_on();
+   LL|       |    contains_closures_off();
+   LL|       |}
+