about summary refs log tree commit diff
path: root/src/compiletest
diff options
context:
space:
mode:
authorHuon Wilson <dbau.pp+github@gmail.com>2013-06-09 23:10:50 +1000
committerHuon Wilson <dbau.pp+github@gmail.com>2013-06-10 23:02:54 +1000
commit1e8982bdb26208d9d9ed4cdcbcd21cc9ef35bd46 (patch)
tree54f03a318e14bcdbdb56e01b3c80d00a9db87a17 /src/compiletest
parent2ff6b298c5f23f48aa993fced41b6e29e446b7ce (diff)
downloadrust-1e8982bdb26208d9d9ed4cdcbcd21cc9ef35bd46.tar.gz
rust-1e8982bdb26208d9d9ed4cdcbcd21cc9ef35bd46.zip
std: replace str::each_split* with an iterator
Diffstat (limited to 'src/compiletest')
-rw-r--r--src/compiletest/header.rs4
-rw-r--r--src/compiletest/runtest.rs19
2 files changed, 9 insertions, 14 deletions
diff --git a/src/compiletest/header.rs b/src/compiletest/header.rs
index b147dc806e2..782571fc679 100644
--- a/src/compiletest/header.rs
+++ b/src/compiletest/header.rs
@@ -141,8 +141,8 @@ fn parse_check_line(line: &str) -> Option<~str> {
 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 mut strs = ~[];
-        for str::each_splitn_char(*nv, '=', 1u) |s| { strs.push(s.to_owned()); }
+        let mut strs: ~[~str] = nv.splitn_iter('=', 1).transform(|s| s.to_owned()).collect();
+
         match strs.len() {
           1u => (strs.pop(), ~""),
           2u => {
diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs
index b4a20886ad8..444f4c8d539 100644
--- a/src/compiletest/runtest.rs
+++ b/src/compiletest/runtest.rs
@@ -278,7 +278,7 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
         // check if each line in props.check_lines appears in the
         // output (in order)
         let mut i = 0u;
-        for str::each_line(ProcRes.stdout) |line| {
+        for ProcRes.stdout.line_iter().advance |line| {
             if check_lines[i].trim() == line.trim() {
                 i += 1u;
             }
@@ -308,7 +308,7 @@ fn check_error_patterns(props: &TestProps,
     let mut next_err_idx = 0u;
     let mut next_err_pat = &props.error_patterns[next_err_idx];
     let mut done = false;
-    for str::each_line(ProcRes.stderr) |line| {
+    for ProcRes.stderr.line_iter().advance |line| {
         if str::contains(line, *next_err_pat) {
             debug!("found error pattern %s", *next_err_pat);
             next_err_idx += 1u;
@@ -358,7 +358,7 @@ fn check_expected_errors(expected_errors: ~[errors::ExpectedError],
     //    filename:line1:col1: line2:col2: *warning:* msg
     // where line1:col1: is the starting point, line2:col2:
     // is the ending point, and * represents ANSI color codes.
-    for str::each_line(ProcRes.stderr) |line| {
+    for ProcRes.stderr.line_iter().advance |line| {
         let mut was_expected = false;
         for vec::eachi(expected_errors) |i, ee| {
             if !found_flags[i] {
@@ -612,15 +612,11 @@ fn make_run_args(config: &config, _props: &TestProps, testfile: &Path) ->
 }
 
 fn split_maybe_args(argstr: &Option<~str>) -> ~[~str] {
-    fn rm_whitespace(v: ~[~str]) -> ~[~str] {
-        v.filtered(|s| !str::is_whitespace(*s))
-    }
-
     match *argstr {
         Some(ref s) => {
-            let mut ss = ~[];
-            for str::each_split_char(*s, ' ') |s| { ss.push(s.to_owned()) }
-            rm_whitespace(ss)
+            s.split_iter(' ')
+                .filter_map(|s| if s.is_whitespace() {None} else {Some(s.to_owned())})
+                .collect()
         }
         None => ~[]
     }
@@ -739,8 +735,7 @@ fn _arm_exec_compiled_test(config: &config, props: &TestProps,
     let cmdline = make_cmdline("", args.prog, args.args);
 
     // get bare program string
-    let mut tvec = ~[];
-    for str::each_split_char(args.prog, '/') |ts| { tvec.push(ts.to_owned()) }
+    let tvec: ~[~str] = args.prog.split_iter('/').transform(|ts| ts.to_owned()).collect();
     let prog_short = tvec.pop();
 
     // copy to target