Chromium Code Reviews| Index: tests/corelib/string_replace_test.dart |
| diff --git a/tests/corelib/string_replace_test.dart b/tests/corelib/string_replace_test.dart |
| index 136cc960d88baabcedcd41111cfe3297740dffb1..30223ff8eb09c4349d850967dfd15f9556469f2e 100644 |
| --- a/tests/corelib/string_replace_test.dart |
| +++ b/tests/corelib/string_replace_test.dart |
| @@ -42,6 +42,30 @@ class StringReplaceTest { |
| // Test replacing the empty string. |
| Expect.equals("toAtoBtoCto", "AtoBtoCto".replaceFirst("", "to")); |
| + |
| + // Test startIndex. |
| + Expect.equals( |
| + "foo-AAA-foo-bar", "foo-bar-foo-bar".replaceFirst("bar", "AAA", 4)); |
| + |
| + // Test startIndex skipping one case at the begining. |
| + Expect.equals( |
| + "foo-bar-AAA-bar", "foo-bar-foo-bar".replaceFirst("foo", "AAA", 1)); |
| + |
| + // Test startIndex skipping one case at the begining. |
| + Expect.equals( |
| + "foo-bar-foo-AAA", "foo-bar-foo-bar".replaceFirst("bar", "AAA", 5)); |
| + |
| + // Test startIndex replacing with the empty string. |
| + Expect.equals( |
| + "foo-bar--bar", "foo-bar-foo-bar".replaceFirst("foo", "", 1)); |
| + |
| + // Test negative startIndex |
|
Bill Hesse
2014/08/11 07:47:47
Add tests for null and object as startIndex.
srawlins
2014/08/14 00:42:45
Done.
|
| + Expect.throws( |
| + () => "hello".replaceFirst("h", "X", -1), (e) => e is RangeError); |
| + |
| + // Test startIndex too large |
| + Expect.throws( |
| + () => "hello".replaceFirst("h", "X", 6), (e) => e is RangeError); |
| } |
| } |
|
Lasse Reichstein Nielsen
2014/08/13 08:35:09
Test with regexps too, and with strings that conta
srawlins
2014/08/14 00:42:45
Done.
|