]> git.lizzy.rs Git - rust.git/blob - src/test/pretty/block-disambig.rs
test: Make manual changes to deal with the fallout from removal of
[rust.git] / src / test / pretty / block-disambig.rs
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.
4 //
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.
10
11 // A bunch of tests for syntactic forms involving blocks that were
12 // previously ambiguous (e.g. 'if true { } *val;' gets parsed as a
13 // binop)
14
15 #[feature(managed_boxes)];
16
17 use std::cell::Cell;
18 use std::vec_ng::Vec;
19
20 fn test1() { let val = @0; { } *val; }
21
22 fn test2() -> int { let val = @0; { } *val }
23
24 struct S { eax: int }
25
26 fn test3() {
27     let regs = @Cell::new(S {eax: 0});
28     match true { true => { } _ => { } }
29     regs.set(S {eax: 1});
30 }
31
32 fn test4() -> bool { let regs = @true; if true { } *regs || false }
33
34 fn test5() -> (int, int) { { } (0, 1) }
35
36 fn test6() -> bool { { } (true || false) && true }
37
38 fn test7() -> uint {
39     let regs = @0;
40     match true { true => { } _ => { } }
41     (*regs < 2) as uint
42 }
43
44 fn test8() -> int {
45     let val = @0;
46     match true {
47         true => { }
48         _    => { }
49     }
50     if *val < 1 {
51         0
52     } else {
53         1
54     }
55 }
56
57 fn test9() {
58     let regs = @Cell::new(0);
59     match true { true => { } _ => { } } regs.set(regs.get() + 1);
60 }
61
62 fn test10() -> int {
63     let regs = @vec!(0);
64     match true { true => { } _ => { } }
65     *(*regs).get(0)
66 }
67
68 fn test11() -> Vec<int> { if true { } vec!(1, 2) }