]> git.proxmox.com Git - rustc.git/blame - src/test/run-pass/break.rs
Imported Upstream version 1.0.0~beta
[rustc.git] / src / test / run-pass / break.rs
CommitLineData
223e47cc
LB
1// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
c34b1796
AL
11// pretty-expanded FIXME #23616
12
223e47cc 13pub fn main() {
85aaf69f 14 let mut i = 0;
223e47cc 15 while i < 20 { i += 1; if i == 10 { break; } }
970d7e83 16 assert_eq!(i, 10);
223e47cc 17 loop { i += 1; if i == 20 { break; } }
970d7e83 18 assert_eq!(i, 20);
85aaf69f
SL
19 let xs = [1, 2, 3, 4, 5, 6];
20 for x in &xs {
223e47cc
LB
21 if *x == 3 { break; } assert!((*x <= 3));
22 }
23 i = 0;
1a4d82fc 24 while i < 10 { i += 1; if i % 2 == 0 { continue; } assert!((i % 2 != 0)); }
223e47cc 25 i = 0;
970d7e83 26 loop {
1a4d82fc 27 i += 1; if i % 2 == 0 { continue; } assert!((i % 2 != 0));
223e47cc
LB
28 if i >= 10 { break; }
29 }
85aaf69f
SL
30 let ys = vec!(1, 2, 3, 4, 5, 6);
31 for x in &ys {
1a4d82fc 32 if *x % 2 == 0 { continue; }
223e47cc
LB
33 assert!((*x % 2 != 0));
34 }
35}