// <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.
+//
+// ignore-lexer-test FIXME #15877
// Tests that match expression handles overlapped literal and range
// properly in the presence of guard function.
}
fn lit_shadow_range() {
- assert_eq!(2i, match 1 {
- 1 if false => 1,
- 1..2 => 2,
+ assert_eq!(2i, match 1i {
+ 1 if false => 1i,
+ 1...2 => 2,
_ => 3
});
let x = 0i;
assert_eq!(2i, match x+1 {
- 0 => 0,
+ 0 => 0i,
1 if false => 1,
- 1..2 => 2,
+ 1...2 => 2,
_ => 3
});
assert_eq!(2i, match val() {
- 1 if false => 1,
- 1..2 => 2,
+ 1 if false => 1i,
+ 1...2 => 2,
_ => 3
});
assert_eq!(2i, match CONST {
- 0 => 0,
+ 0 => 0i,
1 if false => 1,
- 1..2 => 2,
+ 1...2 => 2,
_ => 3
});
// value is out of the range of second arm, should match wildcard pattern
- assert_eq!(3i, match 3 {
- 1 if false => 1,
- 1..2 => 2,
+ assert_eq!(3i, match 3i {
+ 1 if false => 1i,
+ 1...2 => 2,
_ => 3
});
}
fn range_shadow_lit() {
- assert_eq!(2i, match 1 {
- 1..2 if false => 1,
+ assert_eq!(2i, match 1i {
+ 1...2 if false => 1i,
1 => 2,
_ => 3
});
let x = 0i;
assert_eq!(2i, match x+1 {
- 0 => 0,
- 1..2 if false => 1,
+ 0 => 0i,
+ 1...2 if false => 1,
1 => 2,
_ => 3
});
assert_eq!(2i, match val() {
- 1..2 if false => 1,
+ 1...2 if false => 1i,
1 => 2,
_ => 3
});
assert_eq!(2i, match CONST {
- 0 => 0,
- 1..2 if false => 1,
+ 0 => 0i,
+ 1...2 if false => 1,
1 => 2,
_ => 3
});
// ditto
- assert_eq!(3i, match 3 {
- 1..2 if false => 1,
+ assert_eq!(3i, match 3i {
+ 1...2 if false => 1i,
1 => 2,
_ => 3
});
}
fn range_shadow_range() {
- assert_eq!(2i, match 1 {
- 0..2 if false => 1,
- 1..3 => 2,
+ assert_eq!(2i, match 1i {
+ 0...2 if false => 1i,
+ 1...3 => 2,
_ => 3,
});
let x = 0i;
assert_eq!(2i, match x+1 {
100 => 0,
- 0..2 if false => 1,
- 1..3 => 2,
+ 0...2 if false => 1,
+ 1...3 => 2,
_ => 3,
});
assert_eq!(2i, match val() {
- 0..2 if false => 1,
- 1..3 => 2,
+ 0...2 if false => 1,
+ 1...3 => 2,
_ => 3,
});
assert_eq!(2i, match CONST {
100 => 0,
- 0..2 if false => 1,
- 1..3 => 2,
+ 0...2 if false => 1,
+ 1...3 => 2,
_ => 3,
});
// ditto
- assert_eq!(3i, match 5 {
- 0..2 if false => 1,
- 1..3 => 2,
+ assert_eq!(3i, match 5i {
+ 0...2 if false => 1i,
+ 1...3 => 2,
_ => 3,
});
}
fn multi_pats_shadow_lit() {
- assert_eq!(2i, match 1 {
- 100 => 0,
- 0 | 1..10 if false => 1,
+ assert_eq!(2i, match 1i {
+ 100 => 0i,
+ 0 | 1...10 if false => 1,
1 => 2,
_ => 3,
});
}
fn multi_pats_shadow_range() {
- assert_eq!(2i, match 1 {
- 100 => 0,
- 0 | 1..10 if false => 1,
- 1..3 => 2,
+ assert_eq!(2i, match 1i {
+ 100 => 0i,
+ 0 | 1...10 if false => 1,
+ 1...3 => 2,
_ => 3,
});
}
fn lit_shadow_multi_pats() {
- assert_eq!(2i, match 1 {
- 100 => 0,
+ assert_eq!(2i, match 1i {
+ 100 => 0i,
1 if false => 1,
- 0 | 1..10 => 2,
+ 0 | 1...10 => 2,
_ => 3,
});
}
fn range_shadow_multi_pats() {
- assert_eq!(2i, match 1 {
- 100 => 0,
- 1..3 if false => 1,
- 0 | 1..10 => 2,
+ assert_eq!(2i, match 1i {
+ 100 => 0i,
+ 1...3 if false => 1,
+ 0 | 1...10 => 2,
_ => 3,
});
}
// This test basically mimics how trace_macros! macro is implemented,
// which is a rare combination of vector patterns, multiple wild-card
// patterns and guard functions.
- let r = match [Bar(0, false)].as_slice() {
- [Bar(_, pred)] if pred => 1i,
- [Bar(_, pred)] if !pred => 2i,
+ let r = match [Foo::Bar(0, false)].as_slice() {
+ [Foo::Bar(_, pred)] if pred => 1i,
+ [Foo::Bar(_, pred)] if !pred => 2i,
_ => 0i,
};
- assert_eq!(2, r);
+ assert_eq!(2i, r);
}