diff options
| author | Kevin Cantu <me@kevincantu.org> | 2012-02-12 22:00:56 -0800 |
|---|---|---|
| committer | Kevin Cantu <me@kevincantu.org> | 2012-02-13 01:56:58 -0800 |
| commit | c81867474a2cac8fcb646390ae5f3782dda45aae (patch) | |
| tree | 69b3cf2bf0b51eb664349599399d8a4ec379f705 /src/compiletest | |
| parent | 748b63f63f4fb2ac8583900adb5a283990be276b (diff) | |
| download | rust-c81867474a2cac8fcb646390ae5f3782dda45aae.tar.gz rust-c81867474a2cac8fcb646390ae5f3782dda45aae.zip | |
(core::str) add find_bytes and export it...
Diffstat (limited to 'src/compiletest')
| -rw-r--r-- | src/compiletest/errors.rs | 8 | ||||
| -rw-r--r-- | src/compiletest/header.rs | 21 | ||||
| -rw-r--r-- | src/compiletest/runtest.rs | 2 |
3 files changed, 18 insertions, 13 deletions
diff --git a/src/compiletest/errors.rs b/src/compiletest/errors.rs index 9d81b6f00e2..f6b32e2fd31 100644 --- a/src/compiletest/errors.rs +++ b/src/compiletest/errors.rs @@ -24,9 +24,11 @@ fn load_errors(testfile: str) -> [expected_error] { fn parse_expected(line_num: uint, line: str) -> [expected_error] unsafe { let error_tag = "//!"; - let idx0 = str::find(line, error_tag); - if idx0 < 0 { ret []; } - let idx = (idx0 as uint) + str::len_bytes(error_tag); + let idx; + alt str::find_bytes(line, error_tag) { + option::none { ret []; } + option::some(nn) { idx = (nn as uint) + str::len_bytes(error_tag); } + } // "//!^^^ kind msg" denotes a message expected // three lines above current line: diff --git a/src/compiletest/header.rs b/src/compiletest/header.rs index f9c7a7a66e0..a976c5fb98c 100644 --- a/src/compiletest/header.rs +++ b/src/compiletest/header.rs @@ -100,18 +100,21 @@ fn parse_pp_exact(line: str, testfile: str) -> option<str> { } fn parse_name_directive(line: str, directive: str) -> bool { - str::find(line, directive) >= 0 + str::contains(line, directive) } fn parse_name_value_directive(line: str, directive: str) -> option<str> unsafe { let keycolon = directive + ":"; - if str::find(line, keycolon) >= 0 { - let colon = str::find(line, keycolon) as uint; - let value = - str::unsafe::slice_bytes(line, colon + str::len_bytes(keycolon), - str::len_bytes(line)); - #debug("%s: %s", directive, value); - option::some(value) - } else { option::none } + alt str::find_bytes(line, keycolon) { + option::some(colon) { + let value = + str::unsafe::slice_bytes(line, + colon + str::len_bytes(keycolon), + str::len_bytes(line)); + #debug("%s: %s", directive, value); + option::some(value) + } + option::none { option::none } + } } diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index cf5a57c60de..5fb0bca25fa 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -199,7 +199,7 @@ fn check_error_patterns(props: test_props, let next_err_idx = 0u; let next_err_pat = props.error_patterns[next_err_idx]; for line: str in str::split_byte(procres.stderr, '\n' as u8) { - if str::find(line, next_err_pat) > 0 { + if str::contains(line, next_err_pat) { #debug("found error pattern %s", next_err_pat); next_err_idx += 1u; if next_err_idx == vec::len(props.error_patterns) { |
