aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/run-pass/break.rs40
1 files changed, 40 insertions, 0 deletions
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);
+ }
+}