Convert alt to match. Stop parsing alt

This commit is contained in:
Brian Anderson
2012-08-06 12:34:08 -07:00
parent d3a9bb1bd4
commit ecaf9e39c9
359 changed files with 2938 additions and 2915 deletions

View File

@@ -37,7 +37,7 @@ fn parse_config(args: ~[~str]) -> config {
assert (vec::is_not_empty(args));
let args_ = vec::tail(args);
let matches =
alt getopts::getopts(args_, opts) {
match getopts::getopts(args_, opts) {
ok(m) => m,
err(f) => fail getopts::fail_str(f)
};
@@ -80,7 +80,7 @@ fn log_config(config: config) {
}
fn opt_str(maybestr: option<~str>) -> ~str {
alt maybestr { option::some(s) => s, option::none => ~"(none)" }
match maybestr { option::some(s) => s, option::none => ~"(none)" }
}
fn str_opt(maybestr: ~str) -> option<~str> {
@@ -88,7 +88,7 @@ fn str_opt(maybestr: ~str) -> option<~str> {
}
fn str_mode(s: ~str) -> mode {
alt s {
match s {
~"compile-fail" => mode_compile_fail,
~"run-fail" => mode_run_fail,
~"run-pass" => mode_run_pass,
@@ -98,7 +98,7 @@ fn str_mode(s: ~str) -> mode {
}
fn mode_str(mode: mode) -> ~str {
alt mode {
match mode {
mode_compile_fail => ~"compile-fail",
mode_run_fail => ~"run-fail",
mode_run_pass => ~"run-pass",
@@ -115,13 +115,13 @@ fn run_tests(config: config) {
fn test_opts(config: config) -> test::test_opts {
{filter:
alt config.filter {
match config.filter {
option::some(s) => option::some(s),
option::none => option::none
},
run_ignored: config.run_ignored,
logfile:
alt config.logfile {
match config.logfile {
option::some(s) => option::some(s),
option::none => option::none
}
@@ -144,7 +144,7 @@ fn make_tests(config: config) -> ~[test::test_desc] {
fn is_test(config: config, testfile: ~str) -> bool {
// Pretty-printer does not work with .rc files yet
let valid_extensions =
alt config.mode {
match config.mode {
mode_pretty => ~[~".rs"],
_ => ~[~".rc", ~".rs"]
};

View File

@@ -23,7 +23,7 @@ fn load_errors(testfile: ~str) -> ~[expected_error] {
fn parse_expected(line_num: uint, line: ~str) -> ~[expected_error] unsafe {
let error_tag = ~"//~";
let mut idx;
alt str::find_str(line, error_tag) {
match str::find_str(line, error_tag) {
option::none => return ~[],
option::some(nn) => { idx = (nn as uint) + str::len(error_tag); }
}

View File

@@ -30,7 +30,7 @@ fn load_props(testfile: ~str) -> test_props {
let mut compile_flags = option::none;
let mut pp_exact = option::none;
for iter_header(testfile) |ln| {
alt parse_error_pattern(ln) {
match parse_error_pattern(ln) {
option::some(ep) => vec::push(error_patterns, ep),
option::none => ()
};
@@ -107,7 +107,7 @@ fn parse_exec_env(line: ~str) -> option<(~str, ~str)> {
do parse_name_value_directive(line, ~"exec-env").map |nv| {
// nv is either FOO or FOO=BAR
let strs = str::splitn_char(nv, '=', 1u);
alt strs.len() {
match strs.len() {
1u => (strs[0], ~""),
2u => (strs[0], strs[1]),
n => fail fmt!{"Expected 1 or 2 strings, not %u", n}
@@ -116,7 +116,7 @@ fn parse_exec_env(line: ~str) -> option<(~str, ~str)> {
}
fn parse_pp_exact(line: ~str, testfile: ~str) -> option<~str> {
alt parse_name_value_directive(line, ~"pp-exact") {
match parse_name_value_directive(line, ~"pp-exact") {
option::some(s) => option::some(s),
option::none => {
if parse_name_directive(line, ~"pp-exact") {
@@ -135,7 +135,7 @@ fn parse_name_directive(line: ~str, directive: ~str) -> bool {
fn parse_name_value_directive(line: ~str,
directive: ~str) -> option<~str> unsafe {
let keycolon = directive + ~":";
alt str::find_str(line, keycolon) {
match str::find_str(line, keycolon) {
option::some(colon) => {
let value = str::slice(line, colon + str::len(keycolon),
str::len(line));

View File

@@ -76,7 +76,7 @@ fn run(lib_path: ~str,
let mut outs = ~"";
let mut count = 2;
while count > 0 {
alt p.recv() {
match p.recv() {
(1, s) => {
outs = s;
}

View File

@@ -18,7 +18,7 @@ fn run(config: config, testfile: ~str) {
}
debug!{"running %s", testfile};
let props = load_props(testfile);
alt config.mode {
match config.mode {
mode_compile_fail => run_cfail_test(config, props, testfile),
mode_run_fail => run_rfail_test(config, props, testfile),
mode_run_pass => run_rpass_test(config, props, testfile),
@@ -90,7 +90,7 @@ fn run_pretty_test(config: config, props: test_props, testfile: ~str) {
} else { logv(config, ~"testing for converging pretty-printing"); }
let rounds =
alt props.pp_exact { option::some(_) => 1, option::none => 2 };
match props.pp_exact { option::some(_) => 1, option::none => 2 };
let mut srcs = ~[result::get(io::read_whole_file_str(testfile))];
@@ -109,7 +109,7 @@ fn run_pretty_test(config: config, props: test_props, testfile: ~str) {
}
let mut expected =
alt props.pp_exact {
match props.pp_exact {
option::some(file) => {
let filepath = path::connect(path::dirname(testfile), file);
result::get(io::read_whole_file_str(filepath))
@@ -383,7 +383,7 @@ fn make_run_args(config: config, _props: test_props, testfile: ~str) ->
// If we've got another tool to run under (valgrind),
// then split apart its command
let runtool =
alt config.runtool {
match config.runtool {
option::some(s) => option::some(s),
option::none => option::none
};
@@ -402,7 +402,7 @@ fn split_maybe_args(argstr: option<~str>) -> ~[~str] {
vec::filter_map(v, flt)
}
alt argstr {
match argstr {
option::some(s) => rm_whitespace(str::split_char(s, ' ')),
option::none => ~[]
}

View File

@@ -7,7 +7,7 @@ fn make_new_path(path: ~str) -> ~str {
// Windows just uses PATH as the library search path, so we have to
// maintain the current value while adding our own
alt getenv(lib_path_env_var()) {
match getenv(lib_path_env_var()) {
option::some(curr) => {
fmt!{"%s%s%s", path, path_div(), curr}
}