]> git.proxmox.com Git - rustc.git/blame - src/test/pretty/block-disambig.rs
Imported Upstream version 1.0.0~beta
[rustc.git] / src / test / pretty / block-disambig.rs
CommitLineData
223e47cc
LB
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
223e47cc 15
1a4d82fc
JJ
16use std::cell::Cell;
17
85aaf69f 18fn test1() { let val = &0; { } *val; }
1a4d82fc 19
c34b1796 20fn test2() -> isize { let val = &0; { } *val }
223e47cc 21
c34b1796
AL
22#[derive(Copy, Clone)]
23struct S { eax: isize }
223e47cc
LB
24
25fn test3() {
1a4d82fc 26 let regs = &Cell::new(S {eax: 0});
223e47cc 27 match true { true => { } _ => { } }
1a4d82fc 28 regs.set(S {eax: 1});
223e47cc
LB
29}
30
1a4d82fc 31fn test4() -> bool { let regs = &true; if true { } *regs || false }
223e47cc 32
c34b1796 33fn test5() -> (isize, isize) { { } (0, 1) }
223e47cc
LB
34
35fn test6() -> bool { { } (true || false) && true }
36
c34b1796 37fn test7() -> usize {
85aaf69f 38 let regs = &0;
223e47cc 39 match true { true => { } _ => { } }
c34b1796 40 (*regs < 2) as usize
223e47cc
LB
41}
42
c34b1796 43fn test8() -> isize {
85aaf69f 44 let val = &0;
223e47cc
LB
45 match true {
46 true => { }
47 _ => { }
48 }
49 if *val < 1 {
50 0
51 } else {
52 1
53 }
54}
55
1a4d82fc 56fn test9() {
85aaf69f 57 let regs = &Cell::new(0);
1a4d82fc
JJ
58 match true { true => { } _ => { } } regs.set(regs.get() + 1);
59}
223e47cc 60
c34b1796 61fn test10() -> isize {
85aaf69f 62 let regs = vec!(0);
223e47cc 63 match true { true => { } _ => { } }
1a4d82fc 64 regs[0]
223e47cc
LB
65}
66
c34b1796 67fn test11() -> Vec<isize> { if true { } vec!(1, 2) }