Add one more test for vector destructuring

This commit is contained in:
Seo Sanghyeon 2013-03-11 19:53:41 +09:00
parent 9e85589ad3
commit 070137ce90

View File

@ -1,4 +1,4 @@
pub fn main() {
fn a() {
let x = [1];
match x {
[_, _, _, _, _, .._] => ::core::util::unreachable(),
@ -11,3 +11,44 @@ pub fn main() {
[] => ::core::util::unreachable()
}
}
fn b() {
let x = [1, 2, 3];
match x {
[a, b, ..c] => {
fail_unless!(a == 1);
fail_unless!(b == 2);
fail_unless!(c == &[3]);
}
_ => fail!()
}
match x {
[..a, b, c] => {
fail_unless!(a == &[1]);
fail_unless!(b == 2);
fail_unless!(c == 3);
}
_ => fail!()
}
match x {
[a, ..b, c] => {
fail_unless!(a == 1);
fail_unless!(b == &[2]);
fail_unless!(c == 3);
}
_ => fail!()
}
match x {
[a, b, c] => {
fail_unless!(a == 1);
fail_unless!(b == 2);
fail_unless!(c == 3);
}
_ => fail!()
}
}
pub fn main() {
a();
b();
}