]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/issue-13867.rs
Remove the in-tree `flate` crate
[rust.git] / src / test / run-pass / issue-13867.rs
1 // Copyright 2012-2014 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 // Test that codegen works correctly when there are multiple refutable
12 // patterns in match expression.
13
14
15 enum Foo {
16     FooUint(usize),
17     FooNullary,
18 }
19
20 fn main() {
21     let r = match (Foo::FooNullary, 'a') {
22         (Foo::FooUint(..), 'a'...'z') => 1,
23         (Foo::FooNullary, 'x') => 2,
24         _ => 0
25     };
26     assert_eq!(r, 0);
27
28     let r = match (Foo::FooUint(0), 'a') {
29         (Foo::FooUint(1), 'a'...'z') => 1,
30         (Foo::FooUint(..), 'x') => 2,
31         (Foo::FooNullary, 'a') => 3,
32         _ => 0
33     };
34     assert_eq!(r, 0);
35
36     let r = match ('a', Foo::FooUint(0)) {
37         ('a'...'z', Foo::FooUint(1)) => 1,
38         ('x', Foo::FooUint(..)) => 2,
39         ('a', Foo::FooNullary) => 3,
40         _ => 0
41     };
42     assert_eq!(r, 0);
43
44     let r = match ('a', 'a') {
45         ('a'...'z', 'b') => 1,
46         ('x', 'a'...'z') => 2,
47         _ => 0
48     };
49     assert_eq!(r, 0);
50
51     let r = match ('a', 'a') {
52         ('a'...'z', 'b') => 1,
53         ('x', 'a'...'z') => 2,
54         ('a', 'a') => 3,
55         _ => 0
56     };
57     assert_eq!(r, 3);
58 }