Long lines

This commit is contained in:
Brian Anderson 2012-09-28 02:26:20 -07:00
parent bc9efaad9c
commit a09a49627e
9 changed files with 77 additions and 67 deletions

View File

@ -718,7 +718,7 @@ mod tests {
// send to other readers
for vec::each(reader_convos) |x| {
match *x {
(rc, _) => rc.send(()),
(ref rc, _) => rc.send(()),
}
}
}
@ -727,7 +727,7 @@ mod tests {
// complete handshake with other readers
for vec::each(reader_convos) |x| {
match *x {
(_, rp) => rp.recv(),
(_, ref rp) => rp.recv(),
}
}
wc1.send(()); // tell writer to try again

View File

@ -199,13 +199,21 @@ enum Fail_ {
/// Convert a `fail_` enum into an error string
fn fail_str(+f: Fail_) -> ~str {
return match f {
ArgumentMissing(ref nm) => ~"Argument to option '" + *nm + ~"' missing.",
UnrecognizedOption(ref nm) => ~"Unrecognized option: '" + *nm + ~"'.",
OptionMissing(ref nm) => ~"Required option '" + *nm + ~"' missing.",
OptionDuplicated(ref nm) => ~"Option '" + *nm + ~"' given more than once.",
UnexpectedArgument(ref nm) => {
~"Option " + *nm + ~" does not take an argument."
}
ArgumentMissing(ref nm) => {
~"Argument to option '" + *nm + ~"' missing."
}
UnrecognizedOption(ref nm) => {
~"Unrecognized option: '" + *nm + ~"'."
}
OptionMissing(ref nm) => {
~"Required option '" + *nm + ~"' missing."
}
OptionDuplicated(ref nm) => {
~"Option '" + *nm + ~"' given more than once."
}
UnexpectedArgument(ref nm) => {
~"Option " + *nm + ~" does not take an argument."
}
};
}
@ -476,7 +484,7 @@ mod tests {
let opts = ~[reqopt(~"test")];
let rs = getopts(args, opts);
match rs {
Ok(m) => {
Ok(copy m) => {
assert (opt_present(m, ~"test"));
assert (opt_str(m, ~"test") == ~"20");
}
@ -490,7 +498,7 @@ mod tests {
let opts = ~[reqopt(~"test")];
let rs = getopts(args, opts);
match rs {
Err(f) => check_fail_type(f, OptionMissing_),
Err(copy f) => check_fail_type(f, OptionMissing_),
_ => fail
}
}
@ -501,7 +509,7 @@ mod tests {
let opts = ~[reqopt(~"test")];
let rs = getopts(args, opts);
match rs {
Err(f) => check_fail_type(f, ArgumentMissing_),
Err(copy f) => check_fail_type(f, ArgumentMissing_),
_ => fail
}
}
@ -512,7 +520,7 @@ mod tests {
let opts = ~[reqopt(~"test")];
let rs = getopts(args, opts);
match rs {
Err(f) => check_fail_type(f, OptionDuplicated_),
Err(copy f) => check_fail_type(f, OptionDuplicated_),
_ => fail
}
}
@ -523,7 +531,7 @@ mod tests {
let opts = ~[reqopt(~"t")];
let rs = getopts(args, opts);
match rs {
Ok(m) => {
Ok(copy m) => {
assert (opt_present(m, ~"t"));
assert (opt_str(m, ~"t") == ~"20");
}
@ -537,7 +545,7 @@ mod tests {
let opts = ~[reqopt(~"t")];
let rs = getopts(args, opts);
match rs {
Err(f) => check_fail_type(f, OptionMissing_),
Err(copy f) => check_fail_type(f, OptionMissing_),
_ => fail
}
}
@ -548,7 +556,7 @@ mod tests {
let opts = ~[reqopt(~"t")];
let rs = getopts(args, opts);
match rs {
Err(f) => check_fail_type(f, ArgumentMissing_),
Err(copy f) => check_fail_type(f, ArgumentMissing_),
_ => fail
}
}
@ -559,7 +567,7 @@ mod tests {
let opts = ~[reqopt(~"t")];
let rs = getopts(args, opts);
match rs {
Err(f) => check_fail_type(f, OptionDuplicated_),
Err(copy f) => check_fail_type(f, OptionDuplicated_),
_ => fail
}
}
@ -572,7 +580,7 @@ mod tests {
let opts = ~[optopt(~"test")];
let rs = getopts(args, opts);
match rs {
Ok(m) => {
Ok(copy m) => {
assert (opt_present(m, ~"test"));
assert (opt_str(m, ~"test") == ~"20");
}
@ -586,7 +594,7 @@ mod tests {
let opts = ~[optopt(~"test")];
let rs = getopts(args, opts);
match rs {
Ok(m) => assert (!opt_present(m, ~"test")),
Ok(copy m) => assert (!opt_present(m, ~"test")),
_ => fail
}
}
@ -597,7 +605,7 @@ mod tests {
let opts = ~[optopt(~"test")];
let rs = getopts(args, opts);
match rs {
Err(f) => check_fail_type(f, ArgumentMissing_),
Err(copy f) => check_fail_type(f, ArgumentMissing_),
_ => fail
}
}
@ -608,7 +616,7 @@ mod tests {
let opts = ~[optopt(~"test")];
let rs = getopts(args, opts);
match rs {
Err(f) => check_fail_type(f, OptionDuplicated_),
Err(copy f) => check_fail_type(f, OptionDuplicated_),
_ => fail
}
}
@ -619,7 +627,7 @@ mod tests {
let opts = ~[optopt(~"t")];
let rs = getopts(args, opts);
match rs {
Ok(m) => {
Ok(copy m) => {
assert (opt_present(m, ~"t"));
assert (opt_str(m, ~"t") == ~"20");
}
@ -633,7 +641,7 @@ mod tests {
let opts = ~[optopt(~"t")];
let rs = getopts(args, opts);
match rs {
Ok(m) => assert (!opt_present(m, ~"t")),
Ok(copy m) => assert (!opt_present(m, ~"t")),
_ => fail
}
}
@ -644,7 +652,7 @@ mod tests {
let opts = ~[optopt(~"t")];
let rs = getopts(args, opts);
match rs {
Err(f) => check_fail_type(f, ArgumentMissing_),
Err(copy f) => check_fail_type(f, ArgumentMissing_),
_ => fail
}
}
@ -655,7 +663,7 @@ mod tests {
let opts = ~[optopt(~"t")];
let rs = getopts(args, opts);
match rs {
Err(f) => check_fail_type(f, OptionDuplicated_),
Err(copy f) => check_fail_type(f, OptionDuplicated_),
_ => fail
}
}
@ -668,7 +676,7 @@ mod tests {
let opts = ~[optflag(~"test")];
let rs = getopts(args, opts);
match rs {
Ok(m) => assert (opt_present(m, ~"test")),
Ok(copy m) => assert (opt_present(m, ~"test")),
_ => fail
}
}
@ -679,7 +687,7 @@ mod tests {
let opts = ~[optflag(~"test")];
let rs = getopts(args, opts);
match rs {
Ok(m) => assert (!opt_present(m, ~"test")),
Ok(copy m) => assert (!opt_present(m, ~"test")),
_ => fail
}
}
@ -690,7 +698,7 @@ mod tests {
let opts = ~[optflag(~"test")];
let rs = getopts(args, opts);
match rs {
Err(f) => {
Err(copy f) => {
log(error, fail_str(f));
check_fail_type(f, UnexpectedArgument_);
}
@ -704,7 +712,7 @@ mod tests {
let opts = ~[optflag(~"test")];
let rs = getopts(args, opts);
match rs {
Err(f) => check_fail_type(f, OptionDuplicated_),
Err(copy f) => check_fail_type(f, OptionDuplicated_),
_ => fail
}
}
@ -715,7 +723,7 @@ mod tests {
let opts = ~[optflag(~"t")];
let rs = getopts(args, opts);
match rs {
Ok(m) => assert (opt_present(m, ~"t")),
Ok(copy m) => assert (opt_present(m, ~"t")),
_ => fail
}
}
@ -726,7 +734,7 @@ mod tests {
let opts = ~[optflag(~"t")];
let rs = getopts(args, opts);
match rs {
Ok(m) => assert (!opt_present(m, ~"t")),
Ok(copy m) => assert (!opt_present(m, ~"t")),
_ => fail
}
}
@ -737,7 +745,7 @@ mod tests {
let opts = ~[optflag(~"t")];
let rs = getopts(args, opts);
match rs {
Ok(m) => {
Ok(ref m) => {
// The next variable after the flag is just a free argument
assert (m.free[0] == ~"20");
@ -752,7 +760,7 @@ mod tests {
let opts = ~[optflag(~"t")];
let rs = getopts(args, opts);
match rs {
Err(f) => check_fail_type(f, OptionDuplicated_),
Err(copy f) => check_fail_type(f, OptionDuplicated_),
_ => fail
}
}
@ -765,7 +773,7 @@ mod tests {
let opts = ~[optmulti(~"test")];
let rs = getopts(args, opts);
match rs {
Ok(m) => {
Ok(copy m) => {
assert (opt_present(m, ~"test"));
assert (opt_str(m, ~"test") == ~"20");
}
@ -779,7 +787,7 @@ mod tests {
let opts = ~[optmulti(~"test")];
let rs = getopts(args, opts);
match rs {
Ok(m) => assert (!opt_present(m, ~"test")),
Ok(copy m) => assert (!opt_present(m, ~"test")),
_ => fail
}
}
@ -790,7 +798,7 @@ mod tests {
let opts = ~[optmulti(~"test")];
let rs = getopts(args, opts);
match rs {
Err(f) => check_fail_type(f, ArgumentMissing_),
Err(copy f) => check_fail_type(f, ArgumentMissing_),
_ => fail
}
}
@ -801,7 +809,7 @@ mod tests {
let opts = ~[optmulti(~"test")];
let rs = getopts(args, opts);
match rs {
Ok(m) => {
Ok(copy m) => {
assert (opt_present(m, ~"test"));
assert (opt_str(m, ~"test") == ~"20");
let pair = opt_strs(m, ~"test");
@ -818,7 +826,7 @@ mod tests {
let opts = ~[optmulti(~"t")];
let rs = getopts(args, opts);
match rs {
Ok(m) => {
Ok(copy m) => {
assert (opt_present(m, ~"t"));
assert (opt_str(m, ~"t") == ~"20");
}
@ -832,7 +840,7 @@ mod tests {
let opts = ~[optmulti(~"t")];
let rs = getopts(args, opts);
match rs {
Ok(m) => assert (!opt_present(m, ~"t")),
Ok(copy m) => assert (!opt_present(m, ~"t")),
_ => fail
}
}
@ -843,7 +851,7 @@ mod tests {
let opts = ~[optmulti(~"t")];
let rs = getopts(args, opts);
match rs {
Err(f) => check_fail_type(f, ArgumentMissing_),
Err(copy f) => check_fail_type(f, ArgumentMissing_),
_ => fail
}
}
@ -854,7 +862,7 @@ mod tests {
let opts = ~[optmulti(~"t")];
let rs = getopts(args, opts);
match rs {
Ok(m) => {
Ok(copy m) => {
assert (opt_present(m, ~"t"));
assert (opt_str(m, ~"t") == ~"20");
let pair = opt_strs(m, ~"t");
@ -871,7 +879,7 @@ mod tests {
let opts = ~[optmulti(~"t")];
let rs = getopts(args, opts);
match rs {
Err(f) => check_fail_type(f, UnrecognizedOption_),
Err(copy f) => check_fail_type(f, UnrecognizedOption_),
_ => fail
}
}
@ -882,7 +890,7 @@ mod tests {
let opts = ~[optmulti(~"test")];
let rs = getopts(args, opts);
match rs {
Err(f) => check_fail_type(f, UnrecognizedOption_),
Err(copy f) => check_fail_type(f, UnrecognizedOption_),
_ => fail
}
}
@ -899,7 +907,7 @@ mod tests {
optopt(~"notpresent")];
let rs = getopts(args, opts);
match rs {
Ok(m) => {
Ok(copy m) => {
assert (m.free[0] == ~"prog");
assert (m.free[1] == ~"free1");
assert (opt_str(m, ~"s") == ~"20");
@ -924,8 +932,8 @@ mod tests {
let args = ~[~"-e", ~"foo", ~"--encrypt", ~"foo"];
let opts = ~[optopt(~"e"), optopt(~"encrypt")];
let matches = match getopts(args, opts) {
result::Ok(m) => m,
result::Err(_f) => fail
result::Ok(move m) => m,
result::Err(_) => fail
};
assert opts_present(matches, ~[~"e"]);
assert opts_present(matches, ~[~"encrypt"]);
@ -945,8 +953,8 @@ mod tests {
let args = ~[~"-Lfoo"];
let opts = ~[optmulti(~"L")];
let matches = match getopts(args, opts) {
result::Ok(m) => m,
result::Err(_f) => fail
result::Ok(move m) => m,
result::Err(_) => fail
};
assert opts_present(matches, ~[~"L"]);
assert opts_str(matches, ~[~"L"]) == ~"foo";

View File

@ -1133,7 +1133,7 @@ mod tests {
for items.each |item| {
match *item {
(key, value) => { d.insert(copy key, copy value); },
(copy key, copy value) => { d.insert(key, value); },
}
};

View File

@ -329,11 +329,11 @@ mod test {
#[test]
fn test_ip_ipv4_bad_parse() {
match v4::try_parse_addr(~"b4df00d") {
result::Err(err_info) => {
result::Err(ref err_info) => {
log(debug, fmt!("got error as expected %?", err_info));
assert true;
}
result::Ok(addr) => {
result::Ok(ref addr) => {
fail fmt!("Expected failure, but got addr %?", addr);
}
}
@ -342,11 +342,11 @@ mod test {
#[ignore(target_os="win32")]
fn test_ip_ipv6_bad_parse() {
match v6::try_parse_addr(~"::,~2234k;") {
result::Err(err_info) => {
result::Err(ref err_info) => {
log(debug, fmt!("got error as expected %?", err_info));
assert true;
}
result::Ok(addr) => {
result::Ok(ref addr) => {
fail fmt!("Expected failure, but got addr %?", addr);
}
}

View File

@ -703,8 +703,9 @@ fn listen_common(+host_ip: ip::IpAddr, port: uint, backlog: uint,
stream_closed_po.recv();
match kill_result {
// some failure post bind/listen
Some(ref err_data) => result::Err(GenericListenErr(err_data.err_name,
err_data.err_msg)),
Some(ref err_data) => result::Err(GenericListenErr(
err_data.err_name,
err_data.err_msg)),
// clean exit
None => result::Ok(())
}

View File

@ -1239,7 +1239,7 @@ mod tests {
*x.content, x.byte_offset,
x.byte_offset + x.byte_len);
}
node::Concat(x) => {
node::Concat(ref x) => {
aux(str, x.left);
aux(str, x.right);
}

View File

@ -23,8 +23,8 @@ pub fn mkdtemp(tmpdir: &Path, suffix: &str) -> Option<Path> {
fn test_mkdtemp() {
let r = mkdtemp(&Path("."), "foobar");
match r {
Some(p) => {
os::remove_dir(&p);
Some(ref p) => {
os::remove_dir(p);
assert(str::ends_with(p.to_str(), "foobar"));
}
_ => assert(false)

View File

@ -124,7 +124,8 @@ fn run_tests_console(opts: &TestOpts,
let noun = if st.total != 1u { ~"tests" } else { ~"test" };
st.out.write_line(fmt!("\nrunning %u %s", st.total, noun));
}
TeWait(ref test) => st.out.write_str(fmt!("test %s ... ", test.name)),
TeWait(ref test) => st.out.write_str(
fmt!("test %s ... ", test.name)),
TeResult(copy test, result) => {
match st.log_out {
Some(f) => write_log(f, result, &test),
@ -490,7 +491,7 @@ mod tests {
fn first_free_arg_should_be_a_filter() {
let args = ~[~"progname", ~"filter"];
let opts = match parse_opts(args) {
either::Left(o) => o,
either::Left(copy o) => o,
_ => fail ~"Malformed arg in first_free_arg_should_be_a_filter"
};
assert ~"filter" == opts.filter.get();
@ -500,7 +501,7 @@ mod tests {
fn parse_ignored_flag() {
let args = ~[~"progname", ~"filter", ~"--ignored"];
let opts = match parse_opts(args) {
either::Left(o) => o,
either::Left(copy o) => o,
_ => fail ~"Malformed arg in parse_ignored_flag"
};
assert (opts.run_ignored);
@ -563,7 +564,7 @@ mod tests {
for vec::each(pairs) |p| {
match *p {
(a, b) => { assert (a == b.name); }
(ref a, ref b) => { assert (*a == b.name); }
}
}
}

View File

@ -978,7 +978,7 @@ mod tests {
tzset();
match strptime(~"", ~"") {
Ok(tm) => {
Ok(ref tm) => {
assert tm.tm_sec == 0_i32;
assert tm.tm_min == 0_i32;
assert tm.tm_hour == 0_i32;
@ -1000,8 +1000,8 @@ mod tests {
== Err(~"Invalid time");
match strptime(~"Fri Feb 13 15:31:30 2009", format) {
Err(e) => fail e,
Ok(tm) => {
Err(copy e) => fail e,
Ok(ref tm) => {
assert tm.tm_sec == 30_i32;
assert tm.tm_min == 31_i32;
assert tm.tm_hour == 15_i32;
@ -1019,8 +1019,8 @@ mod tests {
fn test(s: &str, format: &str) -> bool {
match strptime(s, format) {
Ok(tm) => tm.strftime(format) == str::from_slice(s),
Err(e) => fail e
Ok(ref tm) => tm.strftime(format) == str::from_slice(s),
Err(copy e) => fail e
}
}