PageRenderTime 11ms CodeModel.GetById 1ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/src/test/run-pass/expr-alt.rs

http://github.com/jruderman/rust
Rust | 44 lines | 32 code | 9 blank | 3 comment | 0 complexity | 281dac604e295995f95f7dd32170b548 MD5 | raw file
 1
 2
 3
 4// -*- rust -*-
 5
 6// Tests for using match as an expression
 7fn test_basic() {
 8    let mut rs: bool = match true { true => { true } false => { false } };
 9    assert (rs);
10    rs = match false { true => { false } false => { true } };
11    assert (rs);
12}
13
14fn test_inferrence() {
15    let mut rs = match true { true => { true } false => { false } };
16    assert (rs);
17}
18
19fn test_alt_as_alt_head() {
20    // Yeah, this is kind of confusing ...
21
22    let rs =
23        match match false { true => { true } false => { false } } {
24          true => { false }
25          false => { true }
26        };
27    assert (rs);
28}
29
30fn test_alt_as_block_result() {
31    let rs =
32        match false {
33          true => { false }
34          false => { match true { true => { true } false => { false } } }
35        };
36    assert (rs);
37}
38
39fn main() {
40    test_basic();
41    test_inferrence();
42    test_alt_as_alt_head();
43    test_alt_as_block_result();
44}