Expunge match checks
This commit is contained in:
parent
b0f289397c
commit
51d98d9c7b
9 changed files with 54 additions and 28 deletions
|
@ -412,9 +412,10 @@ fn test_select2_stress() {
|
|||
let mut as = 0;
|
||||
let mut bs = 0;
|
||||
for iter::repeat(msgs * times * 2u) {
|
||||
match check select2(po_a, po_b) {
|
||||
match select2(po_a, po_b) {
|
||||
either::left(~"a") => as += 1,
|
||||
either::right(~"b") => bs += 1
|
||||
either::right(~"b") => bs += 1,
|
||||
_ => fail ~"test_select_2_stress failed"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -312,13 +312,17 @@ fn program_output(prog: &str, args: &[~str]) ->
|
|||
let mut count = 2;
|
||||
while count > 0 {
|
||||
let stream = comm::recv(p);
|
||||
match check stream {
|
||||
match stream {
|
||||
(1, s) => {
|
||||
outs = s;
|
||||
}
|
||||
(2, s) => {
|
||||
errs = s;
|
||||
}
|
||||
(n, _) => {
|
||||
fail(#fmt("program_output received an unexpected file \
|
||||
number: %u", n));
|
||||
}
|
||||
};
|
||||
count -= 1;
|
||||
};
|
||||
|
|
|
@ -2771,10 +2771,11 @@ mod tests {
|
|||
fn test_chars_iter() {
|
||||
let mut i = 0;
|
||||
do chars_iter(~"x\u03c0y") |ch| {
|
||||
match check i {
|
||||
match i {
|
||||
0 => assert ch == 'x',
|
||||
1 => assert ch == '\u03c0',
|
||||
2 => assert ch == 'y'
|
||||
2 => assert ch == 'y',
|
||||
_ => fail ~"test_chars_iter failed"
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
|
@ -2787,10 +2788,11 @@ mod tests {
|
|||
let mut i = 0;
|
||||
|
||||
do bytes_iter(~"xyz") |bb| {
|
||||
match check i {
|
||||
match i {
|
||||
0 => assert bb == 'x' as u8,
|
||||
1 => assert bb == 'y' as u8,
|
||||
2 => assert bb == 'z' as u8
|
||||
2 => assert bb == 'z' as u8,
|
||||
_ => fail ~"test_bytes_iter failed"
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
|
|
|
@ -30,22 +30,25 @@ impl ~[u8]: to_base64 {
|
|||
i += 3u;
|
||||
}
|
||||
|
||||
match check len % 3u {
|
||||
0u => (),
|
||||
1u => {
|
||||
// Heh, would be cool if we knew this was exhaustive
|
||||
// (the dream of bounded integer types)
|
||||
match len % 3 {
|
||||
0 => (),
|
||||
1 => {
|
||||
let n = (self[i] as uint) << 16u;
|
||||
str::push_char(s, chars[(n >> 18u) & 63u]);
|
||||
str::push_char(s, chars[(n >> 12u) & 63u]);
|
||||
str::push_char(s, '=');
|
||||
str::push_char(s, '=');
|
||||
}
|
||||
2u => {
|
||||
2 => {
|
||||
let n = (self[i] as uint) << 16u | (self[i + 1u] as uint) << 8u;
|
||||
str::push_char(s, chars[(n >> 18u) & 63u]);
|
||||
str::push_char(s, chars[(n >> 12u) & 63u]);
|
||||
str::push_char(s, chars[(n >> 6u) & 63u]);
|
||||
str::push_char(s, '=');
|
||||
}
|
||||
_ => fail ~"Algebra is broken, please alert the math police"
|
||||
}
|
||||
|
||||
s
|
||||
|
|
|
@ -602,14 +602,17 @@ fn test_option_int() {
|
|||
fn deserialize_0<S: serialization::deserializer>(s: S) -> option<int> {
|
||||
do s.read_enum(~"core::option::t") {
|
||||
do s.read_enum_variant |i| {
|
||||
match check i {
|
||||
0u => none,
|
||||
1u => {
|
||||
match i {
|
||||
0 => none,
|
||||
1 => {
|
||||
let v0 = do s.read_enum_variant_arg(0u) {
|
||||
deserialize_1(s)
|
||||
};
|
||||
some(v0)
|
||||
}
|
||||
_ => {
|
||||
fail #fmt("deserialize_0: unexpected variant %u", i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -431,11 +431,12 @@ mod tests {
|
|||
let args = ~[~"--test=20"];
|
||||
let opts = ~[reqopt(~"test")];
|
||||
let rs = getopts(args, opts);
|
||||
match check rs {
|
||||
match rs {
|
||||
ok(m) => {
|
||||
assert (opt_present(m, ~"test"));
|
||||
assert (opt_str(m, ~"test") == ~"20");
|
||||
}
|
||||
_ => { fail ~"test_reqopt_long failed"; }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,11 @@ pure fn tail<T: copy>(ls: @list<T>) -> @list<T> {
|
|||
|
||||
/// Returns the first element of a list
|
||||
pure fn head<T: copy>(ls: @list<T>) -> T {
|
||||
match check *ls { cons(hd, _) => hd }
|
||||
match *ls {
|
||||
cons(hd, _) => hd,
|
||||
// makes me sad
|
||||
_ => fail ~"head invoked on empty list"
|
||||
}
|
||||
}
|
||||
|
||||
/// Appends one list to another
|
||||
|
|
|
@ -260,9 +260,10 @@ fn deserialize_option<D: deserializer,T: copy>(d: D, st: fn() -> T)
|
|||
-> option<T> {
|
||||
do d.read_enum(~"option") {
|
||||
do d.read_enum_variant |i| {
|
||||
match check i {
|
||||
0u => none,
|
||||
1u => some(d.read_enum_variant_arg(0u, || st() ))
|
||||
match i {
|
||||
0 => none,
|
||||
1 => some(d.read_enum_variant_arg(0u, || st() )),
|
||||
_ => fail(#fmt("Bad variant for option: %u", i))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -572,26 +572,30 @@ fn strptime(s: ~str, format: ~str) -> result<tm, ~str> {
|
|||
fn strftime(format: ~str, tm: tm) -> ~str {
|
||||
fn parse_type(ch: char, tm: tm) -> ~str {
|
||||
//FIXME (#2350): Implement missing types.
|
||||
match check ch {
|
||||
'A' => match check tm.tm_wday as int {
|
||||
let die = || #fmt("strftime: can't understand this format %c ",
|
||||
ch);
|
||||
match ch {
|
||||
'A' => match tm.tm_wday as int {
|
||||
0 => ~"Sunday",
|
||||
1 => ~"Monday",
|
||||
2 => ~"Tuesday",
|
||||
3 => ~"Wednesday",
|
||||
4 => ~"Thursday",
|
||||
5 => ~"Friday",
|
||||
6 => ~"Saturday"
|
||||
6 => ~"Saturday",
|
||||
_ => die()
|
||||
},
|
||||
'a' => match check tm.tm_wday as int {
|
||||
'a' => match tm.tm_wday as int {
|
||||
0 => ~"Sun",
|
||||
1 => ~"Mon",
|
||||
2 => ~"Tue",
|
||||
3 => ~"Wed",
|
||||
4 => ~"Thu",
|
||||
5 => ~"Fri",
|
||||
6 => ~"Sat"
|
||||
6 => ~"Sat",
|
||||
_ => die()
|
||||
},
|
||||
'B' => match check tm.tm_mon as int {
|
||||
'B' => match tm.tm_mon as int {
|
||||
0 => ~"January",
|
||||
1 => ~"February",
|
||||
2 => ~"March",
|
||||
|
@ -603,9 +607,10 @@ fn strftime(format: ~str, tm: tm) -> ~str {
|
|||
8 => ~"September",
|
||||
9 => ~"October",
|
||||
10 => ~"November",
|
||||
11 => ~"December"
|
||||
11 => ~"December",
|
||||
_ => die()
|
||||
},
|
||||
'b' | 'h' => match check tm.tm_mon as int {
|
||||
'b' | 'h' => match tm.tm_mon as int {
|
||||
0 => ~"Jan",
|
||||
1 => ~"Feb",
|
||||
2 => ~"Mar",
|
||||
|
@ -618,6 +623,7 @@ fn strftime(format: ~str, tm: tm) -> ~str {
|
|||
9 => ~"Oct",
|
||||
10 => ~"Nov",
|
||||
11 => ~"Dec",
|
||||
_ => die()
|
||||
},
|
||||
'C' => fmt!{"%02d", (tm.tm_year as int + 1900) / 100},
|
||||
'c' => {
|
||||
|
@ -712,7 +718,8 @@ fn strftime(format: ~str, tm: tm) -> ~str {
|
|||
fmt!{"%c%02d%02d", sign, h as int, m as int}
|
||||
}
|
||||
//'+' {}
|
||||
'%' => ~"%"
|
||||
'%' => ~"%",
|
||||
_ => die()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue