From 6ecdc04788334420db05d9894e18d1d7a605ab4f Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 25 Mar 2011 16:28:16 +0100 Subject: Add support for break and cont to rustc Testing proper cleanup is hampered by https://github.com/graydon/rust/issues/293 --- src/test/run-pass/break.rs | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/test/run-pass/break.rs (limited to 'src/test') diff --git a/src/test/run-pass/break.rs b/src/test/run-pass/break.rs new file mode 100644 index 00000000..48c3b091 --- /dev/null +++ b/src/test/run-pass/break.rs @@ -0,0 +1,40 @@ +// xfail-boot + +fn main() { + auto i = 0; + while (i < 20) { + i += 1; + if (i == 10) { break; } + } + check(i == 10); + + do { + i += 1; + if (i == 20) { break; } + } while (i < 30); + check(i == 20); + + for (int x in vec(1, 2, 3, 4, 5, 6)) { + if (x == 3) { break; } + check(x <= 3); + } + + i = 0; + while (i < 10) { + i += 1; + if (i % 2 == 0) { cont; } + check(i % 2 != 0); + } + + i = 0; + do { + i += 1; + if (i % 2 == 0) { cont; } + check(i % 2 != 0); + } while (i < 10); + + for (int x in vec(1, 2, 3, 4, 5, 6)) { + if (x % 2 == 0) { cont; } + check(x % 2 != 0); + } +} -- cgit v1.2.3