]> git.lizzy.rs Git - rust.git/blob - src/test/ui/binding/match-range.rs
Auto merge of #99612 - yanchen4791:issue-95079-fix, r=compiler-errors
[rust.git] / src / test / ui / binding / match-range.rs
1 // run-pass
2 #![allow(illegal_floating_point_literal_pattern)] // FIXME #41620
3 #![feature(exclusive_range_pattern)]
4
5 pub fn main() {
6     match 5_usize {
7       1_usize..=5_usize => {}
8       _ => panic!("should match range"),
9     }
10     match 1_usize {
11         1_usize..5_usize => {}
12         _ => panic!("should match range start"),
13     }
14     match 5_usize {
15       6_usize..=7_usize => panic!("shouldn't match range"),
16       _ => {}
17     }
18     match 7_usize {
19         6_usize..7_usize => panic!("shouldn't match range end"),
20         _ => {},
21     }
22     match 5_usize {
23       1_usize => panic!("should match non-first range"),
24       2_usize..=6_usize => {}
25       _ => panic!("math is broken")
26     }
27     match 'c' {
28       'a'..='z' => {}
29       _ => panic!("should support char ranges")
30     }
31     match -3 {
32       -7..=5 => {}
33       _ => panic!("should match signed range")
34     }
35     match 3.0f64 {
36       1.0..=5.0 => {}
37       _ => panic!("should match float range")
38     }
39     match -1.5f64 {
40       -3.6..=3.6 => {}
41       _ => panic!("should match negative float range")
42     }
43     match 3.5 {
44         0.0..3.5 => panic!("should not match the range end"),
45         _ => {},
46     }
47     match 0.0 {
48         0.0..3.5 => {},
49         _ => panic!("should match the range start"),
50     }
51 }