]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/issue-13867.rs
fb76dbf2f6905af0dfd5aa111b63ef6ccb6236a1
[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 enum Foo {
15     FooUint(uint),
16     FooNullary,
17 }
18
19 fn main() {
20     let r = match (FooNullary, 'a') {
21         (FooUint(..), 'a'..'z') => 1,
22         (FooNullary, 'x') => 2,
23         _ => 0
24     };
25     assert_eq!(r, 0);
26
27     let r = match (FooUint(0), 'a') {
28         (FooUint(1), 'a'..'z') => 1,
29         (FooUint(..), 'x') => 2,
30         (FooNullary, 'a') => 3,
31         _ => 0
32     };
33     assert_eq!(r, 0);
34
35     let r = match ('a', FooUint(0)) {
36         ('a'..'z', FooUint(1)) => 1,
37         ('x', FooUint(..)) => 2,
38         ('a', FooNullary) => 3,
39         _ => 0
40     };
41     assert_eq!(r, 0);
42
43     let r = match ('a', 'a') {
44         ('a'..'z', 'b') => 1,
45         ('x', 'a'..'z') => 2,
46         _ => 0
47     };
48     assert_eq!(r, 0);
49
50     let r = match ('a', 'a') {
51         ('a'..'z', 'b') => 1,
52         ('x', 'a'..'z') => 2,
53         ('a', 'a') => 3,
54         _ => 0
55     };
56     assert_eq!(r, 3);
57 }