Remove match check from test cases

This commit is contained in:
Tim Chevalier 2012-08-23 14:44:58 -07:00
parent 01a5845db5
commit e9622f09aa
22 changed files with 57 additions and 39 deletions

View File

@ -19,26 +19,29 @@ fn calc(children: uint, parent_ch: comm::Chan<msg>) {
}
for iter::repeat (children) {
match check comm::recv(port) {
match comm::recv(port) {
ready(child_ch) => {
vec::push(child_chs, child_ch);
}
_ => fail ~"task-perf-one-million failed (port not ready)"
}
}
comm::send(parent_ch, ready(chan));
match check comm::recv(port) {
match comm::recv(port) {
start => {
do vec::iter (child_chs) |child_ch| {
comm::send(child_ch, start);
}
}
_ => fail ~"task-perf-one-million failed (port not in start state)"
}
for iter::repeat (children) {
match check comm::recv(port) {
match comm::recv(port) {
done(child_sum) => { sum += child_sum; }
_ => fail ~"task-perf-one-million failed (port not done)"
}
}
@ -60,13 +63,15 @@ fn main(args: ~[~str]) {
do task::spawn {
calc(children, chan);
};
match check comm::recv(port) {
match comm::recv(port) {
ready(chan) => {
comm::send(chan, start);
}
_ => fail ~"task-perf-one-million failed (port not ready)"
}
let sum = match check comm::recv(port) {
let sum = match comm::recv(port) {
done(sum) => { sum }
_ => fail ~"task-perf-one-million failed (port not done)"
};
error!("How many tasks? %d tasks.", sum);
}

View File

@ -5,28 +5,33 @@
//error-pattern: unreachable
fn main() {
match check 5u {
match 5u {
1u to 10u => { }
5u to 6u => { }
_ => {}
};
match check 5u {
match 5u {
3u to 6u => { }
4u to 6u => { }
_ => {}
};
match check 5u {
match 5u {
4u to 6u => { }
4u to 6u => { }
_ => {}
};
match check 'c' {
match 'c' {
'A' to 'z' => {}
'a' to 'z' => {}
_ => {}
};
match check 1.0 {
match 1.0 {
0.01 to 6.5 => {}
0.02 => {}
_ => {}
};
}

View File

@ -5,9 +5,10 @@ enum cycle {
fn main() {
let x = ~node({mut a: ~empty});
// Create a cycle!
match check *x { //~ NOTE loan of immutable local variable granted here
match *x { //~ NOTE loan of immutable local variable granted here
node(ref y) => {
y.a <- x; //~ ERROR moving out of immutable local variable prohibited due to outstanding loan
}
empty => {}
};
}

View File

@ -3,7 +3,7 @@
fn f() -> int {
// Make sure typestate doesn't interpreturn this match expression
// as the function result
match check true { true => { } };
match true { true => { } _ => {} };
}
fn main() { }

View File

@ -8,7 +8,7 @@ fn test2() -> int { let val = @0; { } *val }
fn test3() {
let regs = @{mut eax: 0};
match check true { true => { } }
match true { true => { } _ => { } }
(*regs).eax = 1;
}
@ -20,14 +20,15 @@ fn test6() -> bool { { } (true || false) && true }
fn test7() -> uint {
let regs = @0;
match check true { true => { } }
match true { true => { } _ => { } }
(*regs < 2) as uint
}
fn test8() -> int {
let val = @0;
match check true {
match true {
true => { }
_ => { }
}
if *val < 1 {
0
@ -36,11 +37,11 @@ fn test8() -> int {
}
}
fn test9() { let regs = @mut 0; match check true { true => { } } *regs += 1; }
fn test9() { let regs = @mut 0; match true { true => { } _ => { } } *regs += 1; }
fn test10() -> int {
let regs = @mut ~[0];
match check true { true => { } }
match true { true => { } _ => { } }
(*regs)[0]
}

View File

@ -10,8 +10,8 @@ fn if_semi() -> int { if true { f() } else { f() }; -1 }
fn if_nosemi() -> int { (if true { 0 } else { 0 }) - 1 }
fn alt_semi() -> int { match check true { true => { f() } }; -1 }
fn alt_semi() -> int { match true { true => { f() } _ => { } }; -1 }
fn alt_no_semi() -> int { (match check true { true => { 0 } }) - 1 }
fn alt_no_semi() -> int { (match true { true => { 0 } _ => { 1 } }) - 1 }
fn stmt() { { f() }; -1; }

View File

@ -1,8 +1,9 @@
// error-pattern:squirrelcupcake
fn cmp() -> int {
match check (option::some('a'), option::none::<char>) {
match (option::some('a'), option::none::<char>) {
(option::some(_), _) => { fail ~"squirrelcupcake"; }
(_, option::some(_)) => { fail; }
_ => { fail ~"wat"; }
}
}

View File

@ -4,8 +4,9 @@ fn test_box() {
@0;
}
fn test_str() {
let res = match check false { true => { ~"happy" } };
assert res == ~"happy";
let res = match false { true => { ~"happy" },
_ => fail ~"non-exhaustive match failure" };
assert res == ~"happy";
}
fn main() {
test_box();

View File

@ -1,3 +1,3 @@
// n.b. This was only ever failing with optimization disabled.
fn a() -> int { match check return 1 { 2 => 3 } }
fn a() -> int { match return 1 { 2 => 3, _ => fail } }
fn main() { a(); }

View File

@ -1,9 +1,10 @@
fn altlit(f: int) -> int {
match check f {
match f {
10 => { debug!("case 10"); return 20; }
11 => { debug!("case 11"); return 22; }
_ => fail ~"the impossible happened"
}
}

View File

@ -7,9 +7,10 @@ fn main() {
6u..7u => fail ~"shouldn't match range",
_ => {}
}
match check 5u {
match 5u {
1u => fail ~"should match non-first range",
2u..6u => {}
_ => fail ~"math is broken"
}
match 'c' {
'a'..'z' => {}

View File

@ -1,7 +1,7 @@
// Issue #53
fn main() {
match check ~"test" { ~"not-test" => fail, ~"test" => (), _ => fail }
match ~"test" { ~"not-test" => fail, ~"test" => (), _ => fail }
enum t { tag1(~str), tag2, }
@ -13,9 +13,9 @@ fn main() {
_ => fail
}
let x = match check ~"a" { ~"a" => 1, ~"b" => 2 };
let x = match ~"a" { ~"a" => 1, ~"b" => 2, _ => fail };
assert (x == 1);
match check ~"a" { ~"a" => { } ~"b" => { } }
match ~"a" { ~"a" => { } ~"b" => { }, _ => fail }
}

View File

@ -1,6 +1,6 @@
// Check that issue #954 stays fixed
fn main() {
match check -1 { -1 => {} }
match -1 { -1 => {}, _ => fail ~"wat" }
assert 1-1 == 0;
}

View File

@ -5,12 +5,13 @@
// Tests for match as expressions resulting in boxed types
fn test_box() {
let res = match check true { true => { @100 } };
let res = match true { true => { @100 } _ => fail ~"wat" };
assert (*res == 100);
}
fn test_str() {
let res = match check true { true => { ~"happy" } };
let res = match true { true => { ~"happy" },
_ => fail ~"not happy at all" };
assert (res == ~"happy");
}

View File

@ -5,7 +5,7 @@
type compare<T> = fn@(@T, @T) -> bool;
fn test_generic<T>(expected: @T, eq: compare<T>) {
let actual: @T = match check true { true => { expected } };
let actual: @T = match true { true => { expected }, _ => fail };
assert (eq(expected, actual));
}

View File

@ -5,7 +5,7 @@
type compare<T> = fn@(T, T) -> bool;
fn test_generic<T: copy>(expected: T, eq: compare<T>) {
let actual: T = match check true { true => { expected } };
let actual: T = match true { true => { expected }, _ => fail ~"wat" };
assert (eq(expected, actual));
}

View File

@ -4,7 +4,7 @@
type compare<T> = fn@(~T, ~T) -> bool;
fn test_generic<T: copy>(expected: ~T, eq: compare<T>) {
let actual: ~T = match check true { true => { expected } };
let actual: ~T = match true { true => { expected }, _ => fail ~"wat" };
assert (eq(expected, actual));
}

View File

@ -5,7 +5,7 @@
type compare<T> = fn@(T, T) -> bool;
fn test_generic<T: copy>(expected: T, eq: compare<T>) {
let actual: T = match check true { true => { expected } };
let actual: T = match true { true => expected, _ => fail ~"wat" };
assert (eq(expected, actual));
}

View File

@ -5,7 +5,7 @@
type compare<T> = fn@(T, T) -> bool;
fn test_generic<T: copy>(expected: T, eq: compare<T>) {
let actual: T = match check true { true => { expected } };
let actual: T = match true { true => { expected }, _ => fail ~"wat" };
assert (eq(expected, actual));
}

View File

@ -5,7 +5,7 @@
// Tests for match as expressions resulting in structural types
fn test_rec() {
let rs = match check true { true => { {i: 100} } };
let rs = match true { true => {i: 100}, _ => fail };
assert (rs == {i: 100});
}

View File

@ -5,7 +5,7 @@
// Tests for match as expressions resulting in boxed types
fn test_box() {
let res = match check true { true => { ~100 } };
let res = match true { true => { ~100 }, _ => fail };
assert (*res == 100);
}

View File

@ -59,7 +59,8 @@ fn canttouchthis() -> uint {
fn angrydome() {
loop { if break { } }
let mut i = 0;
loop { i += 1; if i == 1 { match check again { 1 => { } } } break; }
loop { i += 1; if i == 1 { match again { 1 => { }, _ => fail ~"wat" } }
break; }
}
fn evil_lincoln() { let evil <- debug!("lincoln"); }