diff options
Diffstat (limited to 'tests/run-make/coverage/if_else.rs')
-rw-r--r-- | tests/run-make/coverage/if_else.rs | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/run-make/coverage/if_else.rs b/tests/run-make/coverage/if_else.rs new file mode 100644 index 000000000..3244e1e3a --- /dev/null +++ b/tests/run-make/coverage/if_else.rs @@ -0,0 +1,40 @@ +#![allow(unused_assignments, unused_variables)] + +fn main() { + // Initialize test constants in a way that cannot be determined at compile time, to ensure + // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from + // dependent conditions. + let is_true = std::env::args().len() == 1; + + let mut countdown = 0; + if + is_true + { + countdown + = + 10 + ; + } + else // Note coverage region difference without semicolon + { + countdown + = + 100 + } + + if + is_true + { + countdown + = + 10 + ; + } + else + { + countdown + = + 100 + ; + } +} |