rust/src/test/run-pass/expr-block.rs

20 lines
432 B
Rust
Raw Normal View History

#![allow(dead_code)]
// Tests for standalone blocks as expressions
2013-03-28 18:39:09 -07: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 22:05:03 +01: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(); }