]>
Commit | Line | Data |
---|---|---|
416331ca XL |
1 | // run-pass |
2 | ||
dc9dc135 | 3 | #![feature(generators)] |
923072b8 | 4 | #![feature(unboxed_closures, fn_traits)] |
dc9dc135 | 5 | |
0bf4aa26 XL |
6 | #![allow(non_camel_case_types)] |
7 | #![allow(dead_code)] | |
8 | #![allow(unreachable_code)] | |
3dfed10e | 9 | #![allow(unused_braces, unused_must_use, unused_parens)] |
923072b8 | 10 | #![allow(uncommon_codepoints, confusable_idents)] |
1a4d82fc | 11 | |
9fa01778 | 12 | #![recursion_limit = "256"] |
8faf50e0 | 13 | |
1a4d82fc JJ |
14 | use std::cell::Cell; |
15 | use std::mem::swap; | |
970d7e83 | 16 | |
223e47cc LB |
17 | // Just a grab bag of stuff that you wouldn't want to actually write. |
18 | ||
19 | fn strange() -> bool { let _x: bool = return true; } | |
20 | ||
21 | fn funny() { | |
22 | fn f(_x: ()) { } | |
23 | f(return); | |
24 | } | |
25 | ||
26 | fn what() { | |
1a4d82fc JJ |
27 | fn the(x: &Cell<bool>) { |
28 | return while !x.get() { x.set(true); }; | |
29 | } | |
30 | let i = &Cell::new(false); | |
85aaf69f | 31 | let dont = {||the(i)}; |
223e47cc | 32 | dont(); |
1a4d82fc | 33 | assert!((i.get())); |
223e47cc LB |
34 | } |
35 | ||
36 | fn zombiejesus() { | |
37 | loop { | |
38 | while (return) { | |
39 | if (return) { | |
40 | match (return) { | |
85aaf69f | 41 | 1 => { |
223e47cc LB |
42 | if (return) { |
43 | return | |
44 | } else { | |
45 | return | |
46 | } | |
47 | } | |
48 | _ => { return } | |
49 | }; | |
50 | } else if (return) { | |
51 | return; | |
52 | } | |
53 | } | |
54 | if (return) { break; } | |
55 | } | |
56 | } | |
57 | ||
58 | fn notsure() { | |
c34b1796 | 59 | let mut _x: isize; |
223e47cc LB |
60 | let mut _y = (_x = 0) == (_x = 0); |
61 | let mut _z = (_x = 0) < (_x = 0); | |
62 | let _a = (_x += 0) == (_x = 0); | |
1a4d82fc | 63 | let _b = swap(&mut _y, &mut _z) == swap(&mut _y, &mut _z); |
223e47cc LB |
64 | } |
65 | ||
c34b1796 | 66 | fn canttouchthis() -> usize { |
223e47cc LB |
67 | fn p() -> bool { true } |
68 | let _a = (assert!((true)) == (assert!(p()))); | |
69 | let _c = (assert!((p())) == ()); | |
c34b1796 | 70 | let _b: bool = (println!("{}", 0) == (return 0)); |
223e47cc LB |
71 | } |
72 | ||
73 | fn angrydome() { | |
74 | loop { if break { } } | |
85aaf69f SL |
75 | let mut i = 0; |
76 | loop { i += 1; if i == 1 { match (continue) { 1 => { }, _ => panic!("wat") } } | |
223e47cc LB |
77 | break; } |
78 | } | |
79 | ||
1a4d82fc | 80 | fn evil_lincoln() { let _evil = println!("lincoln"); } |
223e47cc | 81 | |
041b39d2 XL |
82 | fn dots() { |
83 | assert_eq!(String::from(".................................................."), | |
84 | format!("{:?}", .. .. .. .. .. .. .. .. .. .. .. .. .. | |
85 | .. .. .. .. .. .. .. .. .. .. .. ..)); | |
86 | } | |
87 | ||
94b46f34 XL |
88 | fn u8(u8: u8) { |
89 | if u8 != 0u8 { | |
90 | assert_eq!(8u8, { | |
91 | macro_rules! u8 { | |
92 | (u8) => { | |
93 | mod u8 { | |
94 | pub fn u8<'u8: 'u8 + 'u8>(u8: &'u8 u8) -> &'u8 u8 { | |
95 | "u8"; | |
96 | u8 | |
97 | } | |
041b39d2 | 98 | } |
94b46f34 XL |
99 | }; |
100 | } | |
041b39d2 | 101 | |
94b46f34 XL |
102 | u8!(u8); |
103 | let &u8: &u8 = u8::u8(&8u8); | |
104 | ::u8(0u8); | |
105 | u8 | |
106 | }); | |
107 | } | |
041b39d2 XL |
108 | } |
109 | ||
110 | fn fishy() { | |
111 | assert_eq!(String::from("><>"), | |
112 | String::<>::from::<>("><>").chars::<>().rev::<>().collect::<String>()); | |
113 | } | |
114 | ||
3b2f2976 XL |
115 | fn union() { |
116 | union union<'union> { union: &'union union<'union>, } | |
117 | } | |
118 | ||
94b46f34 | 119 | fn special_characters() { |
923072b8 | 120 | let val = !((|(..):(_,_),(|__@_|__)|__)((&*"\\",'π€')/**/,{})=={&[..=..][..];})// |
94b46f34 XL |
121 | ; |
122 | assert!(!val); | |
123 | } | |
124 | ||
8faf50e0 XL |
125 | fn punch_card() -> impl std::fmt::Debug { |
126 | ..=..=.. .. .. .. .. .. .. .. .. .. .. ..=.. .. | |
127 | ..=.. ..=.. .. .. .. .. .. .. .. .. ..=..=..=.. | |
128 | ..=.. ..=.. ..=.. ..=.. .. ..=..=.. .. ..=.. .. | |
129 | ..=..=.. .. ..=.. ..=.. ..=.. .. .. .. ..=.. .. | |
130 | ..=.. ..=.. ..=.. ..=.. .. ..=.. .. .. ..=.. .. | |
131 | ..=.. ..=.. ..=.. ..=.. .. .. ..=.. .. ..=.. .. | |
132 | ..=.. ..=.. .. ..=..=.. ..=..=.. .. .. ..=.. .. | |
133 | } | |
134 | ||
532ac7d7 XL |
135 | fn r#match() { |
136 | let val = match match match match match () { | |
137 | () => () | |
138 | } { | |
139 | () => () | |
140 | } { | |
141 | () => () | |
142 | } { | |
143 | () => () | |
144 | } { | |
145 | () => () | |
146 | }; | |
147 | assert_eq!(val, ()); | |
148 | } | |
149 | ||
dc9dc135 XL |
150 | fn i_yield() { |
151 | static || { | |
152 | yield yield yield yield yield yield yield yield yield; | |
153 | }; | |
154 | } | |
155 | ||
156 | fn match_nested_if() { | |
157 | let val = match () { | |
158 | () if if if if true {true} else {false} {true} else {false} {true} else {false} => true, | |
159 | _ => false, | |
160 | }; | |
161 | assert!(val); | |
162 | } | |
163 | ||
fc512014 XL |
164 | fn monkey_barrel() { |
165 | let val = ()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=(); | |
166 | assert_eq!(val, ()); | |
167 | } | |
168 | ||
923072b8 FG |
169 | fn ππππππππ() { |
170 | type ππππ = i32; | |
171 | fn πππππ() -> ππππ { | |
172 | let ππππππ = 42; | |
173 | return ππππππ; | |
174 | } | |
175 | assert_eq!(loop { | |
176 | break πππππ (); | |
177 | }, 42); | |
178 | } | |
179 | ||
180 | fn function() { | |
181 | struct foo; | |
182 | impl FnOnce<()> for foo { | |
183 | type Output = foo; | |
184 | extern "rust-call" fn call_once(self, _args: ()) -> Self::Output { | |
185 | foo | |
186 | } | |
187 | } | |
188 | let foo = foo () ()() ()()() ()()()() ()()()()(); | |
189 | } | |
190 | ||
04454e1e FG |
191 | fn bathroom_stall() { |
192 | let mut i = 1; | |
193 | matches!(2, _|_|_|_|_|_ if (i+=1) != (i+=1)); | |
194 | assert_eq!(i, 13); | |
195 | } | |
196 | ||
223e47cc LB |
197 | pub fn main() { |
198 | strange(); | |
199 | funny(); | |
200 | what(); | |
201 | zombiejesus(); | |
202 | notsure(); | |
203 | canttouchthis(); | |
204 | angrydome(); | |
205 | evil_lincoln(); | |
041b39d2 | 206 | dots(); |
94b46f34 | 207 | u8(8u8); |
041b39d2 | 208 | fishy(); |
3b2f2976 | 209 | union(); |
94b46f34 | 210 | special_characters(); |
8faf50e0 | 211 | punch_card(); |
532ac7d7 | 212 | r#match(); |
dc9dc135 XL |
213 | i_yield(); |
214 | match_nested_if(); | |
fc512014 | 215 | monkey_barrel(); |
923072b8 FG |
216 | ππππππππ(); |
217 | function(); | |
04454e1e | 218 | bathroom_stall(); |
223e47cc | 219 | } |