2014-05-04 17:16:16 -05:00
|
|
|
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
|
|
|
// Test that codegen works correctly when there are multiple refutable
|
|
|
|
// patterns in match expression.
|
|
|
|
|
|
|
|
enum Foo {
|
|
|
|
FooUint(uint),
|
|
|
|
FooNullary,
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2014-11-06 02:05:53 -06:00
|
|
|
let r = match (Foo::FooNullary, 'a') {
|
|
|
|
(Foo::FooUint(..), 'a'...'z') => 1i,
|
|
|
|
(Foo::FooNullary, 'x') => 2i,
|
2014-05-04 17:16:16 -05:00
|
|
|
_ => 0
|
|
|
|
};
|
|
|
|
assert_eq!(r, 0);
|
|
|
|
|
2014-11-06 02:05:53 -06:00
|
|
|
let r = match (Foo::FooUint(0), 'a') {
|
|
|
|
(Foo::FooUint(1), 'a'...'z') => 1i,
|
|
|
|
(Foo::FooUint(..), 'x') => 2i,
|
|
|
|
(Foo::FooNullary, 'a') => 3i,
|
2014-05-04 17:16:16 -05:00
|
|
|
_ => 0
|
|
|
|
};
|
|
|
|
assert_eq!(r, 0);
|
|
|
|
|
2014-11-06 02:05:53 -06:00
|
|
|
let r = match ('a', Foo::FooUint(0)) {
|
|
|
|
('a'...'z', Foo::FooUint(1)) => 1i,
|
|
|
|
('x', Foo::FooUint(..)) => 2i,
|
|
|
|
('a', Foo::FooNullary) => 3i,
|
2014-05-04 17:16:16 -05:00
|
|
|
_ => 0
|
|
|
|
};
|
|
|
|
assert_eq!(r, 0);
|
|
|
|
|
|
|
|
let r = match ('a', 'a') {
|
2014-09-26 23:13:20 -05:00
|
|
|
('a'...'z', 'b') => 1i,
|
|
|
|
('x', 'a'...'z') => 2i,
|
2014-05-04 17:16:16 -05:00
|
|
|
_ => 0
|
|
|
|
};
|
|
|
|
assert_eq!(r, 0);
|
|
|
|
|
|
|
|
let r = match ('a', 'a') {
|
2014-09-26 23:13:20 -05:00
|
|
|
('a'...'z', 'b') => 1i,
|
|
|
|
('x', 'a'...'z') => 2i,
|
2014-04-21 16:58:52 -05:00
|
|
|
('a', 'a') => 3i,
|
2014-05-04 17:16:16 -05:00
|
|
|
_ => 0
|
|
|
|
};
|
|
|
|
assert_eq!(r, 3);
|
|
|
|
}
|