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 // pretty-expanded FIXME #23616
18 fn test_if() { let rs: bool = if true { true } else { false }; assert!((rs)); }
21 let rs: bool = if false { false } else { true };
26 let rs: bool = if true { true } else if true { false } else { false };
31 let rs: bool = if false { false } else if true { true } else { false };
36 let rs: bool = if false { false } else if false { false } else { true };
40 fn test_inferrence() {
41 let rs = if true { true } else { false };
45 fn test_if_as_if_condition() {
46 let rs1 = if if false { false } else { true } { true } else { false };
48 let rs2 = if if true { false } else { true } { false } else { true };
52 fn test_if_as_block_result() {
53 let rs = if true { if false { false } else { true } } else { false };
64 test_if_as_if_condition();
65 test_if_as_block_result();