2018-08-30 14:18:55 +02:00
|
|
|
//@ run-pass
|
2012-12-10 17:32:48 -08:00
|
|
|
|
2013-02-01 19:43:17 -08:00
|
|
|
pub fn main() {
|
2015-02-18 05:42:01 -05:00
|
|
|
match 5_usize {
|
2018-05-28 19:42:11 -07:00
|
|
|
1_usize..=5_usize => {}
|
2014-10-09 15:17:22 -04:00
|
|
|
_ => panic!("should match range"),
|
2011-09-28 12:07:33 -07:00
|
|
|
}
|
2017-01-10 22:13:53 +01:00
|
|
|
match 1_usize {
|
|
|
|
1_usize..5_usize => {}
|
|
|
|
_ => panic!("should match range start"),
|
|
|
|
}
|
2015-02-18 05:42:01 -05:00
|
|
|
match 5_usize {
|
2018-05-28 19:42:11 -07:00
|
|
|
6_usize..=7_usize => panic!("shouldn't match range"),
|
2012-08-03 19:59:04 -07:00
|
|
|
_ => {}
|
2011-09-28 12:07:33 -07:00
|
|
|
}
|
2017-01-10 22:13:53 +01:00
|
|
|
match 7_usize {
|
|
|
|
6_usize..7_usize => panic!("shouldn't match range end"),
|
|
|
|
_ => {},
|
|
|
|
}
|
2015-02-18 05:42:01 -05:00
|
|
|
match 5_usize {
|
|
|
|
1_usize => panic!("should match non-first range"),
|
2018-05-28 19:42:11 -07:00
|
|
|
2_usize..=6_usize => {}
|
2014-10-09 15:17:22 -04:00
|
|
|
_ => panic!("math is broken")
|
2011-09-28 12:07:33 -07:00
|
|
|
}
|
2012-08-06 12:34:08 -07:00
|
|
|
match 'c' {
|
2018-05-28 19:42:11 -07:00
|
|
|
'a'..='z' => {}
|
2018-08-19 15:30:23 +02:00
|
|
|
_ => panic!("should support char ranges")
|
2011-09-28 12:07:33 -07:00
|
|
|
}
|
2015-01-25 22:05:03 +01:00
|
|
|
match -3 {
|
2018-05-28 19:42:11 -07:00
|
|
|
-7..=5 => {}
|
2014-10-09 15:17:22 -04:00
|
|
|
_ => panic!("should match signed range")
|
2011-09-28 12:07:33 -07:00
|
|
|
}
|
2014-06-27 12:30:25 -07:00
|
|
|
match 3.0f64 {
|
2018-05-28 19:42:11 -07:00
|
|
|
1.0..=5.0 => {}
|
2014-10-09 15:17:22 -04:00
|
|
|
_ => panic!("should match float range")
|
2011-09-28 12:07:33 -07:00
|
|
|
}
|
2014-06-27 12:30:25 -07:00
|
|
|
match -1.5f64 {
|
2018-05-28 19:42:11 -07:00
|
|
|
-3.6..=3.6 => {}
|
2014-10-09 15:17:22 -04:00
|
|
|
_ => panic!("should match negative float range")
|
2011-09-28 12:07:33 -07:00
|
|
|
}
|
2017-01-10 22:13:53 +01:00
|
|
|
match 3.5 {
|
|
|
|
0.0..3.5 => panic!("should not match the range end"),
|
|
|
|
_ => {},
|
|
|
|
}
|
|
|
|
match 0.0 {
|
|
|
|
0.0..3.5 => {},
|
|
|
|
_ => panic!("should match the range start"),
|
|
|
|
}
|
2011-09-28 12:07:33 -07:00
|
|
|
}
|