]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/match-range.rs
Use assert_eq! in copy_from_slice
[rust.git] / src / test / run-pass / match-range.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 #![feature(exclusive_range_pattern)]
12
13 pub fn main() {
14     match 5_usize {
15       1_usize...5_usize => {}
16       _ => panic!("should match range"),
17     }
18     match 1_usize {
19         1_usize..5_usize => {}
20         _ => panic!("should match range start"),
21     }
22     match 5_usize {
23       6_usize...7_usize => panic!("shouldn't match range"),
24       _ => {}
25     }
26     match 7_usize {
27         6_usize..7_usize => panic!("shouldn't match range end"),
28         _ => {},
29     }
30     match 5_usize {
31       1_usize => panic!("should match non-first range"),
32       2_usize...6_usize => {}
33       _ => panic!("math is broken")
34     }
35     match 'c' {
36       'a'...'z' => {}
37       _ => panic!("should suppport char ranges")
38     }
39     match -3 {
40       -7...5 => {}
41       _ => panic!("should match signed range")
42     }
43     match 3.0f64 {
44       1.0...5.0 => {}
45       _ => panic!("should match float range")
46     }
47     match -1.5f64 {
48       -3.6...3.6 => {}
49       _ => panic!("should match negative float range")
50     }
51     match 3.5 {
52         0.0..3.5 => panic!("should not match the range end"),
53         _ => {},
54     }
55     match 0.0 {
56         0.0..3.5 => {},
57         _ => panic!("should match the range start"),
58     }
59 }