diff options
| author | Brian Anderson <[email protected]> | 2011-05-11 00:05:03 -0400 |
|---|---|---|
| committer | Brian Anderson <[email protected]> | 2011-05-11 01:38:16 -0400 |
| commit | e35984b6c67f2adf1c12d84c48fdf4f01be020e5 (patch) | |
| tree | 73ee96cb57bcb696357ccc9252b2dd499905131e /src/test | |
| parent | More alias-ification of trans. (diff) | |
| download | rust-e35984b6c67f2adf1c12d84c48fdf4f01be020e5.tar.xz rust-e35984b6c67f2adf1c12d84c48fdf4f01be020e5.zip | |
Introduce str_slice runtime function
This reduces the time to execute the new lib-str tests from 1:40ish to a few
seconds and will eventually allow the full lib-sha1 test to run in a
reasonable amount of time. XFAIL lib-str in stage0 - it will run very slowly
until the next snapshot.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/run-pass/lib-str.rs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/test/run-pass/lib-str.rs b/src/test/run-pass/lib-str.rs index 58779f67..8985c22e 100644 --- a/src/test/run-pass/lib-str.rs +++ b/src/test/run-pass/lib-str.rs @@ -1,3 +1,6 @@ +// xfail-boot +// xfail-stage0 + use std; import std.Str; @@ -98,6 +101,36 @@ fn test_to_upper() { assert (Str.eq(expected, actual)); } +fn test_slice() { + assert (Str.eq("ab", Str.slice("abc", 0u, 2u))); + assert (Str.eq("bc", Str.slice("abc", 1u, 3u))); + assert (Str.eq("", Str.slice("abc", 1u, 1u))); + + fn a_million_letter_a() -> str { + auto i = 0; + auto res = ""; + while (i < 100000) { + res += "aaaaaaaaaa"; + i += 1; + } + ret res; + } + + fn half_a_million_letter_a() -> str { + auto i = 0; + auto res = ""; + while (i < 100000) { + res += "aaaaa"; + i += 1; + } + ret res; + } + + assert (Str.eq(half_a_million_letter_a(), + Str.slice(a_million_letter_a(), + 0u, + 500000u))); +} fn main() { test_bytes_len(); @@ -108,4 +141,5 @@ fn main() { test_concat(); test_connect(); test_to_upper(); + test_slice(); } |