2017-09-18 05:47:33 -05:00
|
|
|
|
|
|
|
|
2015-12-23 15:37:52 -06:00
|
|
|
|
2017-05-17 07:19:44 -05:00
|
|
|
#![warn(panic_params)]
|
2015-12-23 15:37:52 -06:00
|
|
|
|
|
|
|
fn missing() {
|
2016-03-12 14:23:01 -06:00
|
|
|
if true {
|
2017-02-08 07:58:07 -06:00
|
|
|
panic!("{}");
|
2016-03-15 15:02:08 -05:00
|
|
|
} else if false {
|
2017-02-08 07:58:07 -06:00
|
|
|
panic!("{:?}");
|
2016-03-12 14:23:01 -06:00
|
|
|
} else {
|
2017-02-08 07:58:07 -06:00
|
|
|
assert!(true, "here be missing values: {}");
|
2016-03-12 14:23:01 -06:00
|
|
|
}
|
2015-12-23 15:37:52 -06:00
|
|
|
}
|
|
|
|
|
2016-03-12 14:23:01 -06:00
|
|
|
fn ok_single() {
|
2015-12-23 15:37:52 -06:00
|
|
|
panic!("foo bar");
|
|
|
|
}
|
|
|
|
|
2016-03-15 15:02:08 -05:00
|
|
|
fn ok_inner() {
|
|
|
|
// Test for #768
|
|
|
|
assert!("foo bar".contains(&format!("foo {}", "bar")));
|
|
|
|
}
|
|
|
|
|
2015-12-23 15:37:52 -06:00
|
|
|
fn ok_multiple() {
|
|
|
|
panic!("{}", "This is {ok}");
|
|
|
|
}
|
|
|
|
|
2016-03-12 14:23:01 -06:00
|
|
|
fn ok_bracket() {
|
|
|
|
match 42 {
|
|
|
|
1337 => panic!("{so is this"),
|
|
|
|
666 => panic!("so is this}"),
|
|
|
|
_ => panic!("}so is that{"),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-21 16:23:54 -05:00
|
|
|
const ONE : u32= 1;
|
|
|
|
|
|
|
|
fn ok_nomsg() {
|
|
|
|
assert!({ 1 == ONE });
|
|
|
|
assert!(if 1 == ONE { ONE == 1 } else { false });
|
|
|
|
}
|
|
|
|
|
2015-12-23 15:37:52 -06:00
|
|
|
fn main() {
|
|
|
|
missing();
|
2016-03-12 14:23:01 -06:00
|
|
|
ok_single();
|
2015-12-23 15:37:52 -06:00
|
|
|
ok_multiple();
|
2016-03-12 14:23:01 -06:00
|
|
|
ok_bracket();
|
2016-03-15 15:02:08 -05:00
|
|
|
ok_inner();
|
2017-08-21 16:23:54 -05:00
|
|
|
ok_nomsg();
|
2015-12-23 15:37:52 -06:00
|
|
|
}
|