rust/src/test/ui/expr-block.rs

22 lines
445 B
Rust
Raw Normal View History

// run-pass
#![allow(dead_code)]
// Tests for standalone blocks as expressions
2013-03-28 20:39:09 -05:00
fn test_basic() { let rs: bool = { true }; assert!((rs)); }
struct RS { v1: isize, v2: isize }
fn test_rec() { let rs = { RS {v1: 10, v2: 20} }; assert_eq!(rs.v2, 20); }
fn test_filled_with_stuff() {
2015-01-25 15:05:03 -06:00
let rs = { let mut a = 0; while a < 10 { a += 1; } a };
assert_eq!(rs, 10);
}
pub fn main() { test_basic(); test_rec(); test_filled_with_stuff(); }