]> git.proxmox.com Git - rustc.git/blame - src/test/run-pass/weird-exprs.rs
* Introduce some changes by Angus Lees
[rustc.git] / src / test / run-pass / weird-exprs.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
1a4d82fc
JJ
11
12use std::cell::Cell;
13use std::mem::swap;
970d7e83 14
223e47cc
LB
15// Just a grab bag of stuff that you wouldn't want to actually write.
16
17fn strange() -> bool { let _x: bool = return true; }
18
19fn funny() {
20 fn f(_x: ()) { }
21 f(return);
22}
23
24fn what() {
1a4d82fc
JJ
25 fn the(x: &Cell<bool>) {
26 return while !x.get() { x.set(true); };
27 }
28 let i = &Cell::new(false);
29 let dont = {|&:|the(i)};
223e47cc 30 dont();
1a4d82fc 31 assert!((i.get()));
223e47cc
LB
32}
33
34fn zombiejesus() {
35 loop {
36 while (return) {
37 if (return) {
38 match (return) {
1a4d82fc 39 1i => {
223e47cc
LB
40 if (return) {
41 return
42 } else {
43 return
44 }
45 }
46 _ => { return }
47 };
48 } else if (return) {
49 return;
50 }
51 }
52 if (return) { break; }
53 }
54}
55
56fn notsure() {
1a4d82fc 57 let mut _x: int;
223e47cc
LB
58 let mut _y = (_x = 0) == (_x = 0);
59 let mut _z = (_x = 0) < (_x = 0);
60 let _a = (_x += 0) == (_x = 0);
1a4d82fc 61 let _b = swap(&mut _y, &mut _z) == swap(&mut _y, &mut _z);
223e47cc
LB
62}
63
64fn canttouchthis() -> uint {
65 fn p() -> bool { true }
66 let _a = (assert!((true)) == (assert!(p())));
67 let _c = (assert!((p())) == ());
1a4d82fc 68 let _b: bool = (println!("{}", 0i) == (return 0u));
223e47cc
LB
69}
70
71fn angrydome() {
72 loop { if break { } }
1a4d82fc
JJ
73 let mut i = 0i;
74 loop { i += 1; if i == 1 { match (continue) { 1i => { }, _ => panic!("wat") } }
223e47cc
LB
75 break; }
76}
77
1a4d82fc 78fn evil_lincoln() { let _evil = println!("lincoln"); }
223e47cc
LB
79
80pub fn main() {
81 strange();
82 funny();
83 what();
84 zombiejesus();
85 notsure();
86 canttouchthis();
87 angrydome();
88 evil_lincoln();
89}