]> git.proxmox.com Git - rustc.git/blob - src/test/run-pass/issue-29740.rs
New upstream version 1.14.0+dfsg1
[rustc.git] / src / test / run-pass / issue-29740.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 // Regression test for #29740. Inefficient MIR matching algorithms
12 // generated way too much code for this sort of case, leading to OOM.
13
14 pub mod KeyboardEventConstants {
15 pub const DOM_KEY_LOCATION_STANDARD: u32 = 0;
16 pub const DOM_KEY_LOCATION_LEFT: u32 = 1;
17 pub const DOM_KEY_LOCATION_RIGHT: u32 = 2;
18 pub const DOM_KEY_LOCATION_NUMPAD: u32 = 3;
19 } // mod KeyboardEventConstants
20
21 pub enum Key {
22 Space,
23 Apostrophe,
24 Comma,
25 Minus,
26 Period,
27 Slash,
28 Num0,
29 Num1,
30 Num2,
31 Num3,
32 Num4,
33 Num5,
34 Num6,
35 Num7,
36 Num8,
37 Num9,
38 Semicolon,
39 Equal,
40 A,
41 B,
42 C,
43 D,
44 E,
45 F,
46 G,
47 H,
48 I,
49 J,
50 K,
51 L,
52 M,
53 N,
54 O,
55 P,
56 Q,
57 R,
58 S,
59 T,
60 U,
61 V,
62 W,
63 X,
64 Y,
65 Z,
66 LeftBracket,
67 Backslash,
68 RightBracket,
69 GraveAccent,
70 World1,
71 World2,
72
73 Escape,
74 Enter,
75 Tab,
76 Backspace,
77 Insert,
78 Delete,
79 Right,
80 Left,
81 Down,
82 Up,
83 PageUp,
84 PageDown,
85 Home,
86 End,
87 CapsLock,
88 ScrollLock,
89 NumLock,
90 PrintScreen,
91 Pause,
92 F1,
93 F2,
94 F3,
95 F4,
96 F5,
97 F6,
98 F7,
99 F8,
100 F9,
101 F10,
102 F11,
103 F12,
104 F13,
105 F14,
106 F15,
107 F16,
108 F17,
109 F18,
110 F19,
111 F20,
112 F21,
113 F22,
114 F23,
115 F24,
116 F25,
117 Kp0,
118 Kp1,
119 Kp2,
120 Kp3,
121 Kp4,
122 Kp5,
123 Kp6,
124 Kp7,
125 Kp8,
126 Kp9,
127 KpDecimal,
128 KpDivide,
129 KpMultiply,
130 KpSubtract,
131 KpAdd,
132 KpEnter,
133 KpEqual,
134 LeftShift,
135 LeftControl,
136 LeftAlt,
137 LeftSuper,
138 RightShift,
139 RightControl,
140 RightAlt,
141 RightSuper,
142 Menu,
143 }
144
145 fn key_from_string(key_string: &str, location: u32) -> Option<Key> {
146 match key_string {
147 " " => Some(Key::Space),
148 "\"" => Some(Key::Apostrophe),
149 "'" => Some(Key::Apostrophe),
150 "<" => Some(Key::Comma),
151 "," => Some(Key::Comma),
152 "_" => Some(Key::Minus),
153 "-" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Minus),
154 ">" => Some(Key::Period),
155 "." if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Period),
156 "?" => Some(Key::Slash),
157 "/" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Slash),
158 "~" => Some(Key::GraveAccent),
159 "`" => Some(Key::GraveAccent),
160 ")" => Some(Key::Num0),
161 "0" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num0),
162 "!" => Some(Key::Num1),
163 "1" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num1),
164 "@" => Some(Key::Num2),
165 "2" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num2),
166 "#" => Some(Key::Num3),
167 "3" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num3),
168 "$" => Some(Key::Num4),
169 "4" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num4),
170 "%" => Some(Key::Num5),
171 "5" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num5),
172 "^" => Some(Key::Num6),
173 "6" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num6),
174 "&" => Some(Key::Num7),
175 "7" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num7),
176 "*" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num8),
177 "8" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num8),
178 "(" => Some(Key::Num9),
179 "9" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num9),
180 ":" => Some(Key::Semicolon),
181 ";" => Some(Key::Semicolon),
182 "+" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Equal),
183 "=" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Equal),
184 "A" => Some(Key::A),
185 "a" => Some(Key::A),
186 "B" => Some(Key::B),
187 "b" => Some(Key::B),
188 "C" => Some(Key::C),
189 "c" => Some(Key::C),
190 "D" => Some(Key::D),
191 "d" => Some(Key::D),
192 "E" => Some(Key::E),
193 "e" => Some(Key::E),
194 "F" => Some(Key::F),
195 "f" => Some(Key::F),
196 "G" => Some(Key::G),
197 "g" => Some(Key::G),
198 "H" => Some(Key::H),
199 "h" => Some(Key::H),
200 "I" => Some(Key::I),
201 "i" => Some(Key::I),
202 "J" => Some(Key::J),
203 "j" => Some(Key::J),
204 "K" => Some(Key::K),
205 "k" => Some(Key::K),
206 "L" => Some(Key::L),
207 "l" => Some(Key::L),
208 "M" => Some(Key::M),
209 "m" => Some(Key::M),
210 "N" => Some(Key::N),
211 "n" => Some(Key::N),
212 "O" => Some(Key::O),
213 "o" => Some(Key::O),
214 "P" => Some(Key::P),
215 "p" => Some(Key::P),
216 "Q" => Some(Key::Q),
217 "q" => Some(Key::Q),
218 "R" => Some(Key::R),
219 "r" => Some(Key::R),
220 "S" => Some(Key::S),
221 "s" => Some(Key::S),
222 "T" => Some(Key::T),
223 "t" => Some(Key::T),
224 "U" => Some(Key::U),
225 "u" => Some(Key::U),
226 "V" => Some(Key::V),
227 "v" => Some(Key::V),
228 "W" => Some(Key::W),
229 "w" => Some(Key::W),
230 "X" => Some(Key::X),
231 "x" => Some(Key::X),
232 "Y" => Some(Key::Y),
233 "y" => Some(Key::Y),
234 "Z" => Some(Key::Z),
235 "z" => Some(Key::Z),
236 "{" => Some(Key::LeftBracket),
237 "[" => Some(Key::LeftBracket),
238 "|" => Some(Key::Backslash),
239 "\\" => Some(Key::Backslash),
240 "}" => Some(Key::RightBracket),
241 "]" => Some(Key::RightBracket),
242 "Escape" => Some(Key::Escape),
243 "Enter" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD
244 => Some(Key::Enter),
245 "Tab" => Some(Key::Tab),
246 "Backspace" => Some(Key::Backspace),
247 "Insert" => Some(Key::Insert),
248 "Delete" => Some(Key::Delete),
249 "ArrowRight" => Some(Key::Right),
250 "ArrowLeft" => Some(Key::Left),
251 "ArrowDown" => Some(Key::Down),
252 "ArrowUp" => Some(Key::Up),
253 "PageUp" => Some(Key::PageUp),
254 "PageDown" => Some(Key::PageDown),
255 "Home" => Some(Key::Home),
256 "End" => Some(Key::End),
257 "CapsLock" => Some(Key::CapsLock),
258 "ScrollLock" => Some(Key::ScrollLock),
259 "NumLock" => Some(Key::NumLock),
260 "PrintScreen" => Some(Key::PrintScreen),
261 "Pause" => Some(Key::Pause),
262 "F1" => Some(Key::F1),
263 "F2" => Some(Key::F2),
264 "F3" => Some(Key::F3),
265 "F4" => Some(Key::F4),
266 "F5" => Some(Key::F5),
267 "F6" => Some(Key::F6),
268 "F7" => Some(Key::F7),
269 "F8" => Some(Key::F8),
270 "F9" => Some(Key::F9),
271 "F10" => Some(Key::F10),
272 "F11" => Some(Key::F11),
273 "F12" => Some(Key::F12),
274 "F13" => Some(Key::F13),
275 "F14" => Some(Key::F14),
276 "F15" => Some(Key::F15),
277 "F16" => Some(Key::F16),
278 "F17" => Some(Key::F17),
279 "F18" => Some(Key::F18),
280 "F19" => Some(Key::F19),
281 "F20" => Some(Key::F20),
282 "F21" => Some(Key::F21),
283 "F22" => Some(Key::F22),
284 "F23" => Some(Key::F23),
285 "F24" => Some(Key::F24),
286 "F25" => Some(Key::F25),
287 "0" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp0),
288 "1" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp1),
289 "2" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp2),
290 "3" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp3),
291 "4" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp4),
292 "5" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp5),
293 "6" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp6),
294 "7" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp7),
295 "8" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp8),
296 "9" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp9),
297 "." if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::KpDecimal),
298 "/" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::KpDivide),
299 "*" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::KpMultiply),
300 "-" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::KpSubtract),
301 "+" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::KpAdd),
302 "Enter" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD
303 => Some(Key::KpEnter),
304 "=" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::KpEqual),
305 "Shift" if location == KeyboardEventConstants::DOM_KEY_LOCATION_LEFT
306 => Some(Key::LeftShift),
307 "Control" if location == KeyboardEventConstants::DOM_KEY_LOCATION_LEFT
308 => Some(Key::LeftControl),
309 "Alt" if location == KeyboardEventConstants::DOM_KEY_LOCATION_LEFT => Some(Key::LeftAlt),
310 "Super" if location == KeyboardEventConstants::DOM_KEY_LOCATION_LEFT
311 => Some(Key::LeftSuper),
312 "Shift" if location == KeyboardEventConstants::DOM_KEY_LOCATION_RIGHT
313 => Some(Key::RightShift),
314 "Control" if location == KeyboardEventConstants::DOM_KEY_LOCATION_RIGHT
315 => Some(Key::RightControl),
316 "Alt" if location == KeyboardEventConstants::DOM_KEY_LOCATION_RIGHT => Some(Key::RightAlt),
317 "Super" if location == KeyboardEventConstants::DOM_KEY_LOCATION_RIGHT
318 => Some(Key::RightSuper),
319 "ContextMenu" => Some(Key::Menu),
320 _ => None
321 }
322 }
323
324 fn main() { }