about summary refs log tree commit diff
path: root/tests/coverage/inner_items.coverage
diff options
context:
space:
mode:
authorZalathar <Zalathar@users.noreply.github.com>2023-11-01 21:26:53 +1100
committerZalathar <Zalathar@users.noreply.github.com>2023-11-07 11:15:19 +1100
commite9d04c5e2444526ffde83662f2d57fa35c772891 (patch)
tree6dbc04c3253992f8968d5914d7b1c631db528892 /tests/coverage/inner_items.coverage
parentaea7c27eae5e34b11c64ec6d11c75627ef24f8b1 (diff)
downloadrust-e9d04c5e2444526ffde83662f2d57fa35c772891.tar.gz
rust-e9d04c5e2444526ffde83662f2d57fa35c772891.zip
coverage: Migrate `tests/run-coverage` into `tests/coverage`
Diffstat (limited to 'tests/coverage/inner_items.coverage')
-rw-r--r--tests/coverage/inner_items.coverage60
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/coverage/inner_items.coverage b/tests/coverage/inner_items.coverage
new file mode 100644
index 00000000000..65493bcd9db
--- /dev/null
+++ b/tests/coverage/inner_items.coverage
@@ -0,0 +1,60 @@
+   LL|       |#![allow(unused_assignments, unused_variables, dead_code)]
+   LL|       |
+   LL|      1|fn main() {
+   LL|      1|    // Initialize test constants in a way that cannot be determined at compile time, to ensure
+   LL|      1|    // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
+   LL|      1|    // dependent conditions.
+   LL|      1|    let is_true = std::env::args().len() == 1;
+   LL|      1|
+   LL|      1|    let mut countdown = 0;
+   LL|      1|    if is_true {
+   LL|      1|        countdown = 10;
+   LL|      1|    }
+                   ^0
+   LL|       |
+   LL|       |    mod in_mod {
+   LL|       |        const IN_MOD_CONST: u32 = 1000;
+   LL|       |    }
+   LL|       |
+   LL|      3|    fn in_func(a: u32) {
+   LL|      3|        let b = 1;
+   LL|      3|        let c = a + b;
+   LL|      3|        println!("c = {}", c)
+   LL|      3|    }
+   LL|       |
+   LL|       |    struct InStruct {
+   LL|       |        in_struct_field: u32,
+   LL|       |    }
+   LL|       |
+   LL|       |    const IN_CONST: u32 = 1234;
+   LL|       |
+   LL|       |    trait InTrait {
+   LL|       |        fn trait_func(&mut self, incr: u32);
+   LL|       |
+   LL|      1|        fn default_trait_func(&mut self) {
+   LL|      1|            in_func(IN_CONST);
+   LL|      1|            self.trait_func(IN_CONST);
+   LL|      1|        }
+   LL|       |    }
+   LL|       |
+   LL|       |    impl InTrait for InStruct {
+   LL|      1|        fn trait_func(&mut self, incr: u32) {
+   LL|      1|            self.in_struct_field += incr;
+   LL|      1|            in_func(self.in_struct_field);
+   LL|      1|        }
+   LL|       |    }
+   LL|       |
+   LL|       |    type InType = String;
+   LL|       |
+   LL|      1|    if is_true {
+   LL|      1|        in_func(countdown);
+   LL|      1|    }
+                   ^0
+   LL|       |
+   LL|      1|    let mut val = InStruct {
+   LL|      1|        in_struct_field: 101,
+   LL|      1|    };
+   LL|      1|
+   LL|      1|    val.default_trait_func();
+   LL|      1|}
+