summaryrefslogtreecommitdiffstats
path: root/tests/run-make/coverage/simple_loop.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/run-make/coverage/simple_loop.rs')
-rw-r--r--tests/run-make/coverage/simple_loop.rs35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/run-make/coverage/simple_loop.rs b/tests/run-make/coverage/simple_loop.rs
new file mode 100644
index 000000000..6f7f23475
--- /dev/null
+++ b/tests/run-make/coverage/simple_loop.rs
@@ -0,0 +1,35 @@
+#![allow(unused_assignments)]
+
+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
+ ;
+ }
+
+ loop
+ {
+ if
+ countdown
+ ==
+ 0
+ {
+ break
+ ;
+ }
+ countdown
+ -=
+ 1
+ ;
+ }
+}