Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(311)

Side by Side Diff: tests/corelib/string_replace_all_test.dart

Issue 1559953002: Revert "js_runtime: streamline stringReplaceAllUnchecked" (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sdk/lib/_internal/js_runtime/lib/string_helper.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 6
7 testReplaceAll() { 7 testReplaceAll() {
8 Expect.equals( 8 Expect.equals(
9 "aXXcaXXdae", "abcabdae".replaceAll("b", "XX")); 9 "aXXcaXXdae", "abcabdae".replaceAll("b", "XX"));
10 10
(...skipping 28 matching lines...) Expand all
39 // Test replacing by the empty string. 39 // Test replacing by the empty string.
40 Expect.equals( 40 Expect.equals(
41 "bcbde", "abcabdae".replaceAll("a", "")); 41 "bcbde", "abcabdae".replaceAll("a", ""));
42 Expect.equals("AB", "AfromB".replaceAll("from", "")); 42 Expect.equals("AB", "AfromB".replaceAll("from", ""));
43 43
44 // Test changing the empty string. 44 // Test changing the empty string.
45 Expect.equals("to", "".replaceAll("", "to")); 45 Expect.equals("to", "".replaceAll("", "to"));
46 46
47 // Test replacing the empty string. 47 // Test replacing the empty string.
48 Expect.equals("toAtoBtoCto", "ABC".replaceAll("", "to")); 48 Expect.equals("toAtoBtoCto", "ABC".replaceAll("", "to"));
49
50 // Pattern strings containing RegExp metacharacters - these are not
51 // interpreted as RegExps.
52 Expect.equals(r"$$", "||".replaceAll("|", r"$"));
53 Expect.equals(r"$$$$", "||".replaceAll("|", r"$$"));
54 Expect.equals(r"x$|x", "x|.|x".replaceAll("|.", r"$"));
55 Expect.equals(r"$$", "..".replaceAll(".", r"$"));
56 Expect.equals(r"[$$$$]", "[..]".replaceAll(".", r"$$"));
57 Expect.equals(r"[$]", "[..]".replaceAll("..", r"$"));
58 Expect.equals(r"$$", r"\\".replaceAll(r"\", r"$"));
59 } 49 }
60 50
61 testReplaceAllMapped() { 51 testReplaceAllMapped() {
62 String mark(Match m) => "[${m[0]}]"; 52 String mark(Match m) => "[${m[0]}]";
63 Expect.equals( 53 Expect.equals(
64 "a[b]ca[b]dae", "abcabdae".replaceAllMapped("b", mark)); 54 "a[b]ca[b]dae", "abcabdae".replaceAllMapped("b", mark));
65 55
66 // Test with the replaced string at the begining. 56 // Test with the replaced string at the begining.
67 Expect.equals( 57 Expect.equals(
68 "[a]bc[a]bd[a]e", "abcabdae".replaceAllMapped("a", mark)); 58 "[a]bc[a]bd[a]e", "abcabdae".replaceAllMapped("a", mark));
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 "<>a<bc>a<bd>a<e>", 140 "<>a<bc>a<bd>a<e>",
151 "abcabdae".splitMapJoin("a", onNonMatch: wrap)); 141 "abcabdae".splitMapJoin("a", onNonMatch: wrap));
152 142
153 } 143 }
154 144
155 main() { 145 main() {
156 testReplaceAll(); 146 testReplaceAll();
157 testReplaceAllMapped(); 147 testReplaceAllMapped();
158 testSplitMapJoin(); 148 testSplitMapJoin();
159 } 149 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/js_runtime/lib/string_helper.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698