]> git.lizzy.rs Git - rust.git/blob - tests/ui/panic.rs
Merge pull request #2735 from rust-lang-nursery/ice_melting
[rust.git] / tests / ui / panic.rs
1
2
3
4 #![warn(panic_params)]
5
6 fn missing() {
7     if true {
8         panic!("{}");
9     } else if false {
10         panic!("{:?}");
11     } else {
12         assert!(true, "here be missing values: {}");
13     }
14
15     panic!("{{{this}}}");
16 }
17
18 fn ok_single() {
19     panic!("foo bar");
20 }
21
22 fn ok_inner() {
23     // Test for #768
24     assert!("foo bar".contains(&format!("foo {}", "bar")));
25 }
26
27 fn ok_multiple() {
28     panic!("{}", "This is {ok}");
29 }
30
31 fn ok_bracket() {
32     match 42 {
33         1337 => panic!("{so is this"),
34         666 => panic!("so is this}"),
35         _ => panic!("}so is that{"),
36     }
37 }
38
39 const ONE : u32= 1;
40
41 fn ok_nomsg() {
42     assert!({ 1 == ONE });
43     assert!(if 1 == ONE { ONE == 1 } else { false });
44 }
45
46 fn ok_escaped() {
47     panic!("{{ why should this not be ok? }}");
48     panic!(" or {{ that ?");
49     panic!(" or }} this ?");
50     panic!(" {or {{ that ?");
51     panic!(" }or }} this ?");
52     panic!("{{ test }");
53     panic!("{case }}");
54 }
55
56 fn main() {
57     missing();
58     ok_single();
59     ok_multiple();
60     ok_bracket();
61     ok_inner();
62     ok_nomsg();
63     ok_escaped();
64 }