diff options
| author | Marijn Haverbeke <[email protected]> | 2011-03-25 16:28:16 +0100 |
|---|---|---|
| committer | Marijn Haverbeke <[email protected]> | 2011-03-27 14:11:23 +0200 |
| commit | 6ecdc04788334420db05d9894e18d1d7a605ab4f (patch) | |
| tree | aba6169530f041b59507490b9ab28b1ac2835d18 /src/test | |
| parent | shootout: Hoist out the vector indexing on nbody; don't rely on LICM, which i... (diff) | |
| download | rust-6ecdc04788334420db05d9894e18d1d7a605ab4f.tar.xz rust-6ecdc04788334420db05d9894e18d1d7a605ab4f.zip | |
Add support for break and cont to rustc
Testing proper cleanup is hampered by
https://github.com/graydon/rust/issues/293
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/run-pass/break.rs | 40 |
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); + } +} |