PageRenderTime 9ms CodeModel.GetById 1ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/src/test/run-pass/break.rs

http://github.com/jruderman/rust
Rust | 23 lines | 21 code | 2 blank | 0 comment | 22 complexity | a210a4d0a0150413819bded0e5d2665c MD5 | raw file
 1
 2
 3fn main() {
 4    let mut i = 0;
 5    while i < 20 { i += 1; if i == 10 { break; } }
 6    assert (i == 10);
 7    loop { i += 1; if i == 20 { break; } }
 8    assert (i == 20);
 9    for vec::each(~[1, 2, 3, 4, 5, 6]) |x| {
10        if x == 3 { break; } assert (x <= 3);
11    }
12    i = 0;
13    while i < 10 { i += 1; if i % 2 == 0 { again; } assert (i % 2 != 0); }
14    i = 0;
15    loop { 
16        i += 1; if i % 2 == 0 { again; } assert (i % 2 != 0); 
17        if i >= 10 { break; }
18    }
19    for vec::each(~[1, 2, 3, 4, 5, 6]) |x| {
20        if x % 2 == 0 { again; }
21        assert (x % 2 != 0);
22    }
23}