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.
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.
15 // Tests for if as expressions
16 fn test_if() { let rs: bool = if true { true } else { false }; assert!((rs)); }
19 let rs: bool = if false { false } else { true };
24 let rs: bool = if true { true } else if true { false } else { false };
29 let rs: bool = if false { false } else if true { true } else { false };
34 let rs: bool = if false { false } else if false { false } else { true };
38 fn test_inferrence() {
39 let rs = if true { true } else { false };
43 fn test_if_as_if_condition() {
44 let rs1 = if if false { false } else { true } { true } else { false };
46 let rs2 = if if true { false } else { true } { false } else { true };
50 fn test_if_as_block_result() {
51 let rs = if true { if false { false } else { true } } else { false };
62 test_if_as_if_condition();
63 test_if_as_block_result();