2019-07-27 00:54:25 +03:00
|
|
|
// run-pass
|
2020-03-27 21:56:19 +01:00
|
|
|
#![allow(unused_braces)]
|
2018-09-14 12:20:28 +02:00
|
|
|
#![allow(dead_code)]
|
2011-06-15 11:19:50 -07:00
|
|
|
|
2011-03-31 21:45:08 -04:00
|
|
|
// Tests for standalone blocks as expressions
|
2015-03-22 13:13:15 -07:00
|
|
|
|
2013-03-28 18:39:09 -07:00
|
|
|
fn test_basic() { let rs: bool = { true }; assert!((rs)); }
|
2011-03-31 21:45:08 -04:00
|
|
|
|
2015-03-25 17:06:52 -07:00
|
|
|
struct RS { v1: isize, v2: isize }
|
2013-01-25 22:46:32 -08:00
|
|
|
|
2015-06-07 21:00:38 +03:00
|
|
|
fn test_rec() { let rs = { RS {v1: 10, v2: 20} }; assert_eq!(rs.v2, 20); }
|
2011-03-31 21:45:08 -04:00
|
|
|
|
|
|
|
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 };
|
2013-05-18 22:02:45 -04:00
|
|
|
assert_eq!(rs, 10);
|
2011-03-31 21:45:08 -04:00
|
|
|
}
|
|
|
|
|
2013-02-01 19:43:17 -08:00
|
|
|
pub fn main() { test_basic(); test_rec(); test_filled_with_stuff(); }
|