1 // run-pass
2 
3 #![feature(generators)]
4 #![feature(destructuring_assignment)]
5 
6 #![allow(non_camel_case_types)]
7 #![allow(dead_code)]
8 #![allow(unreachable_code)]
9 #![allow(unused_braces, unused_must_use, unused_parens)]
10 
11 #![recursion_limit = "256"]
12 
13 use std::cell::Cell;
14 use std::mem::swap;
15 
16 // Just a grab bag of stuff that you wouldn't want to actually write.
17 
strange() -> bool18 fn strange() -> bool { let _x: bool = return true; }
19 
funny()20 fn funny() {
21     fn f(_x: ()) { }
22     f(return);
23 }
24 
what()25 fn what() {
26     fn the(x: &Cell<bool>) {
27         return while !x.get() { x.set(true); };
28     }
29     let i = &Cell::new(false);
30     let dont = {||the(i)};
31     dont();
32     assert!((i.get()));
33 }
34 
zombiejesus()35 fn zombiejesus() {
36     loop {
37         while (return) {
38             if (return) {
39                 match (return) {
40                     1 => {
41                         if (return) {
42                             return
43                         } else {
44                             return
45                         }
46                     }
47                     _ => { return }
48                 };
49             } else if (return) {
50                 return;
51             }
52         }
53         if (return) { break; }
54     }
55 }
56 
notsure()57 fn notsure() {
58     let mut _x: isize;
59     let mut _y = (_x = 0) == (_x = 0);
60     let mut _z = (_x = 0) < (_x = 0);
61     let _a = (_x += 0) == (_x = 0);
62     let _b = swap(&mut _y, &mut _z) == swap(&mut _y, &mut _z);
63 }
64 
canttouchthis() -> usize65 fn canttouchthis() -> usize {
66     fn p() -> bool { true }
67     let _a = (assert!((true)) == (assert!(p())));
68     let _c = (assert!((p())) == ());
69     let _b: bool = (println!("{}", 0) == (return 0));
70 }
71 
angrydome()72 fn angrydome() {
73     loop { if break { } }
74     let mut i = 0;
75     loop { i += 1; if i == 1 { match (continue) { 1 => { }, _ => panic!("wat") } }
76       break; }
77 }
78 
evil_lincoln()79 fn evil_lincoln() { let _evil = println!("lincoln"); }
80 
dots()81 fn dots() {
82     assert_eq!(String::from(".................................................."),
83                format!("{:?}", .. .. .. .. .. .. .. .. .. .. .. .. ..
84                                .. .. .. .. .. .. .. .. .. .. .. ..));
85 }
86 
u8(u8: u8)87 fn u8(u8: u8) {
88     if u8 != 0u8 {
89         assert_eq!(8u8, {
90             macro_rules! u8 {
91                 (u8) => {
92                     mod u8 {
93                         pub fn u8<'u8: 'u8 + 'u8>(u8: &'u8 u8) -> &'u8 u8 {
94                             "u8";
95                             u8
96                         }
97                     }
98                 };
99             }
100 
101             u8!(u8);
102             let &u8: &u8 = u8::u8(&8u8);
103             ::u8(0u8);
104             u8
105         });
106     }
107 }
108 
fishy()109 fn fishy() {
110     assert_eq!(String::from("><>"),
111                String::<>::from::<>("><>").chars::<>().rev::<>().collect::<String>());
112 }
113 
union()114 fn union() {
115     union union<'union> { union: &'union union<'union>, }
116 }
117 
special_characters()118 fn special_characters() {
119     let val = !((|(..):(_,_),__@_|__)((&*"\\",'��')/**/,{})=={&[..=..][..];})//
120     ;
121     assert!(!val);
122 }
123 
124 fn punch_card() -> impl std::fmt::Debug {
125     ..=..=.. ..    .. .. .. ..    .. .. .. ..    .. ..=.. ..
126     ..=.. ..=..    .. .. .. ..    .. .. .. ..    ..=..=..=..
127     ..=.. ..=..    ..=.. ..=..    .. ..=..=..    .. ..=.. ..
128     ..=..=.. ..    ..=.. ..=..    ..=.. .. ..    .. ..=.. ..
129     ..=.. ..=..    ..=.. ..=..    .. ..=.. ..    .. ..=.. ..
130     ..=.. ..=..    ..=.. ..=..    .. .. ..=..    .. ..=.. ..
131     ..=.. ..=..    .. ..=..=..    ..=..=.. ..    .. ..=.. ..
132 }
133 
134 fn r#match() {
135     let val = match match match match match () {
136         () => ()
137     } {
138         () => ()
139     } {
140         () => ()
141     } {
142         () => ()
143     } {
144         () => ()
145     };
146     assert_eq!(val, ());
147 }
148 
149 fn i_yield() {
150     static || {
151         yield yield yield yield yield yield yield yield yield;
152     };
153 }
154 
155 fn match_nested_if() {
156     let val = match () {
157         () if if if if true {true} else {false} {true} else {false} {true} else {false} => true,
158         _ => false,
159     };
160     assert!(val);
161 }
162 
163 fn monkey_barrel() {
164     let val = ()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=();
165     assert_eq!(val, ());
166 }
167 
168 pub fn main() {
169     strange();
170     funny();
171     what();
172     zombiejesus();
173     notsure();
174     canttouchthis();
175     angrydome();
176     evil_lincoln();
177     dots();
178     u8(8u8);
179     fishy();
180     union();
181     special_characters();
182     punch_card();
183     r#match();
184     i_yield();
185     match_nested_if();
186     monkey_barrel();
187 }
188