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
17 fn test_if() { let rs: bool = if true { true } else { false }; assert!((rs)); }
20 let rs: bool = if false { false } else { true };
25 let rs: bool = if true { true } else if true { false } else { false };
30 let rs: bool = if false { false } else if true { true } else { false };
35 let rs: bool = if false { false } else if false { false } else { true };
39 fn test_inferrence() {
40 let rs = if true { true } else { false };
44 fn test_if_as_if_condition() {
45 let rs1 = if if false { false } else { true } { true } else { false };
47 let rs2 = if if true { false } else { true } { false } else { true };
51 fn test_if_as_block_result() {
52 let rs = if true { if false { false } else { true } } else { false };
63 test_if_as_if_condition();
64 test_if_as_block_result();