]> git.proxmox.com Git - rustc.git/blame - src/test/run-pass/match-range.rs
New upstream version 1.19.0+dfsg1
[rustc.git] / src / test / run-pass / match-range.rs
CommitLineData
223e47cc
LB
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.
32a655c1
SL
10
11#![feature(exclusive_range_pattern)]
223e47cc
LB
12
13pub fn main() {
85aaf69f
SL
14 match 5_usize {
15 1_usize...5_usize => {}
1a4d82fc 16 _ => panic!("should match range"),
223e47cc 17 }
32a655c1
SL
18 match 1_usize {
19 1_usize..5_usize => {}
20 _ => panic!("should match range start"),
21 }
85aaf69f
SL
22 match 5_usize {
23 6_usize...7_usize => panic!("shouldn't match range"),
223e47cc
LB
24 _ => {}
25 }
32a655c1
SL
26 match 7_usize {
27 6_usize..7_usize => panic!("shouldn't match range end"),
28 _ => {},
29 }
85aaf69f
SL
30 match 5_usize {
31 1_usize => panic!("should match non-first range"),
32 2_usize...6_usize => {}
1a4d82fc 33 _ => panic!("math is broken")
223e47cc
LB
34 }
35 match 'c' {
1a4d82fc
JJ
36 'a'...'z' => {}
37 _ => panic!("should suppport char ranges")
223e47cc 38 }
85aaf69f 39 match -3 {
1a4d82fc
JJ
40 -7...5 => {}
41 _ => panic!("should match signed range")
223e47cc 42 }
1a4d82fc
JJ
43 match 3.0f64 {
44 1.0...5.0 => {}
45 _ => panic!("should match float range")
223e47cc 46 }
1a4d82fc
JJ
47 match -1.5f64 {
48 -3.6...3.6 => {}
49 _ => panic!("should match negative float range")
223e47cc 50 }
32a655c1
SL
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 }
223e47cc 59}