]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/weird-exprs.rs
Ignore new test on Windows
[rust.git] / src / test / run-pass / weird-exprs.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 // compile-flags: -Z borrowck=compare
12
13 #![recursion_limit = "128"]
14
15 use std::cell::Cell;
16 use std::mem::swap;
17
18 // Just a grab bag of stuff that you wouldn't want to actually write.
19
20 fn strange() -> bool { let _x: bool = return true; }
21
22 fn funny() {
23     fn f(_x: ()) { }
24     f(return);
25 }
26
27 fn what() {
28     fn the(x: &Cell<bool>) {
29         return while !x.get() { x.set(true); };
30     }
31     let i = &Cell::new(false);
32     let dont = {||the(i)};
33     dont();
34     assert!((i.get()));
35 }
36
37 fn zombiejesus() {
38     loop {
39         while (return) {
40             if (return) {
41                 match (return) {
42                     1 => {
43                         if (return) {
44                             return
45                         } else {
46                             return
47                         }
48                     }
49                     _ => { return }
50                 };
51             } else if (return) {
52                 return;
53             }
54         }
55         if (return) { break; }
56     }
57 }
58
59 fn notsure() {
60     let mut _x: isize;
61     let mut _y = (_x = 0) == (_x = 0);
62     let mut _z = (_x = 0) < (_x = 0);
63     let _a = (_x += 0) == (_x = 0);
64     let _b = swap(&mut _y, &mut _z) == swap(&mut _y, &mut _z);
65 }
66
67 fn canttouchthis() -> usize {
68     fn p() -> bool { true }
69     let _a = (assert!((true)) == (assert!(p())));
70     let _c = (assert!((p())) == ());
71     let _b: bool = (println!("{}", 0) == (return 0));
72 }
73
74 fn angrydome() {
75     loop { if break { } }
76     let mut i = 0;
77     loop { i += 1; if i == 1 { match (continue) { 1 => { }, _ => panic!("wat") } }
78       break; }
79 }
80
81 fn evil_lincoln() { let _evil = println!("lincoln"); }
82
83 fn dots() {
84     assert_eq!(String::from(".................................................."),
85                format!("{:?}", .. .. .. .. .. .. .. .. .. .. .. .. ..
86                                .. .. .. .. .. .. .. .. .. .. .. ..));
87 }
88
89 fn u8(u8: u8) {
90     if u8 != 0u8 {
91         assert_eq!(8u8, {
92             macro_rules! u8 {
93                 (u8) => {
94                     mod u8 {
95                         pub fn u8<'u8: 'u8 + 'u8>(u8: &'u8 u8) -> &'u8 u8 {
96                             "u8";
97                             u8
98                         }
99                     }
100                 };
101             }
102
103             u8!(u8);
104             let &u8: &u8 = u8::u8(&8u8);
105             ::u8(0u8);
106             u8
107         });
108     }
109 }
110
111 fn fishy() {
112     assert_eq!(String::from("><>"),
113                String::<>::from::<>("><>").chars::<>().rev::<>().collect::<String>());
114 }
115
116 fn union() {
117     union union<'union> { union: &'union union<'union>, }
118 }
119
120 fn special_characters() {
121     let val = !((|(..):(_,_),__@_|__)((&*"\\",'🤔')/**/,{})=={&[..=..][..];})//
122     ;
123     assert!(!val);
124 }
125
126 fn punch_card() -> impl std::fmt::Debug {
127     ..=..=.. ..    .. .. .. ..    .. .. .. ..    .. ..=.. ..
128     ..=.. ..=..    .. .. .. ..    .. .. .. ..    ..=..=..=..
129     ..=.. ..=..    ..=.. ..=..    .. ..=..=..    .. ..=.. ..
130     ..=..=.. ..    ..=.. ..=..    ..=.. .. ..    .. ..=.. ..
131     ..=.. ..=..    ..=.. ..=..    .. ..=.. ..    .. ..=.. ..
132     ..=.. ..=..    ..=.. ..=..    .. .. ..=..    .. ..=.. ..
133     ..=.. ..=..    .. ..=..=..    ..=..=.. ..    .. ..=.. ..
134 }
135
136 pub fn main() {
137     strange();
138     funny();
139     what();
140     zombiejesus();
141     notsure();
142     canttouchthis();
143     angrydome();
144     evil_lincoln();
145     dots();
146     u8(8u8);
147     fishy();
148     union();
149     special_characters();
150     punch_card();
151 }