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

Unified Diff: tests/corelib_strong/string_replace_test.dart

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: tests/corelib_strong/string_replace_test.dart
diff --git a/tests/corelib_strong/string_replace_test.dart b/tests/corelib_strong/string_replace_test.dart
index 3e53efd32ccb015328ef923aba84a824335f319b..c0d9660b57edf71f586c20c796f6916fc1c45d28 100644
--- a/tests/corelib_strong/string_replace_test.dart
+++ b/tests/corelib_strong/string_replace_test.dart
@@ -6,16 +6,13 @@ import "package:expect/expect.dart";
main() {
// Test replaceFirst.
- Expect.equals(
- "AtoBtoCDtoE", "AfromBtoCDtoE".replaceFirst("from", "to"));
+ Expect.equals("AtoBtoCDtoE", "AfromBtoCDtoE".replaceFirst("from", "to"));
// Test with the replaced string at the begining.
- Expect.equals(
- "toABtoCDtoE", "fromABtoCDtoE".replaceFirst("from", "to"));
+ Expect.equals("toABtoCDtoE", "fromABtoCDtoE".replaceFirst("from", "to"));
// Test with the replaced string at the end.
- Expect.equals(
- "toABtoCDtoEto", "fromABtoCDtoEto".replaceFirst("from", "to"));
+ Expect.equals("toABtoCDtoEto", "fromABtoCDtoEto".replaceFirst("from", "to"));
// Test when there are no occurence of the string to replace.
Expect.equals("ABC", "ABC".replaceFirst("from", "to"));
@@ -56,12 +53,10 @@ main() {
"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));
+ Expect.equals("foo-bar--bar", "foo-bar-foo-bar".replaceFirst("foo", "", 1));
// Test startIndex with a RegExp with carat
- Expect.equals(
- "foo-bar-foo-bar",
+ Expect.equals("foo-bar-foo-bar",
"foo-bar-foo-bar".replaceFirst(new RegExp(r"^foo"), "", 8));
// Test startIndex with a RegExp
@@ -69,8 +64,7 @@ main() {
"aaa{3}X{3}", "aaa{3}aaa{3}".replaceFirst(new RegExp(r"a{3}"), "X", 1));
// Test startIndex with regexp-looking String
- Expect.equals(
- "aaa{3}aaX", "aaa{3}aaa{3}".replaceFirst("a{3}", "X", 3));
+ Expect.equals("aaa{3}aaX", "aaa{3}aaa{3}".replaceFirst("a{3}", "X", 3));
// Test negative startIndex
Expect.throws(
@@ -85,9 +79,7 @@ main() {
() => "hello".replaceFirst("h", "X", null), (e) => e is ArgumentError);
// Test object startIndex
- Expect.throws(
- () => "hello".replaceFirst("h", "X", new Object()));
-
+ Expect.throws(() => "hello".replaceFirst("h", "X", new Object()));
// Test replaceFirstMapped.
@@ -99,8 +91,7 @@ main() {
"toABtoCDtoE", "fromABtoCDtoE".replaceFirstMapped("from", (_) => "to"));
// Test with the replaced string at the end.
- Expect.equals(
- "toABtoCDtoEto",
+ Expect.equals("toABtoCDtoEto",
"fromABtoCDtoEto".replaceFirstMapped("from", (_) => "to"));
// Test when there are no occurence of the string to replace.
@@ -130,32 +121,27 @@ main() {
Expect.equals("toAtoBtoCto", "AtoBtoCto".replaceFirstMapped("", (_) => "to"));
// Test startIndex.
- Expect.equals(
- "foo-AAA-foo-bar",
+ Expect.equals("foo-AAA-foo-bar",
"foo-bar-foo-bar".replaceFirstMapped("bar", (_) => "AAA", 4));
// Test startIndex skipping one case at the begining.
- Expect.equals(
- "foo-bar-AAA-bar",
+ Expect.equals("foo-bar-AAA-bar",
"foo-bar-foo-bar".replaceFirstMapped("foo", (_) => "AAA", 1));
// Test startIndex skipping one case at the begining.
- Expect.equals(
- "foo-bar-foo-AAA",
+ Expect.equals("foo-bar-foo-AAA",
"foo-bar-foo-bar".replaceFirstMapped("bar", (_) => "AAA", 5));
// Test startIndex replacing with the empty string.
- Expect.equals(
- "foo-bar--bar", "foo-bar-foo-bar".replaceFirstMapped("foo", (_) => "", 1));
+ Expect.equals("foo-bar--bar",
+ "foo-bar-foo-bar".replaceFirstMapped("foo", (_) => "", 1));
// Test startIndex with a RegExp with carat
- Expect.equals(
- "foo-bar-foo-bar",
+ Expect.equals("foo-bar-foo-bar",
"foo-bar-foo-bar".replaceFirstMapped(new RegExp(r"^foo"), (_) => "", 8));
// Test startIndex with a RegExp
- Expect.equals(
- "aaa{3}X{3}",
+ Expect.equals("aaa{3}X{3}",
"aaa{3}aaa{3}".replaceFirstMapped(new RegExp(r"a{3}"), (_) => "X", 1));
// Test startIndex with regexp-looking String
@@ -163,68 +149,68 @@ main() {
"aaa{3}aaX", "aaa{3}aaa{3}".replaceFirstMapped("a{3}", (_) => "X", 3));
// Test negative startIndex
- Expect.throws(
- () => "hello".replaceFirstMapped("h", (_) => "X", -1),
+ Expect.throws(() => "hello".replaceFirstMapped("h", (_) => "X", -1),
(e) => e is RangeError);
// Test startIndex too large
- Expect.throws(
- () => "hello".replaceFirstMapped("h", (_) => "X", 6),
+ Expect.throws(() => "hello".replaceFirstMapped("h", (_) => "X", 6),
(e) => e is RangeError);
// Test null startIndex
- Expect.throws(
- () => "hello".replaceFirstMapped("h", (_) => "X", null),
+ Expect.throws(() => "hello".replaceFirstMapped("h", (_) => "X", null),
(e) => e is ArgumentError);
// Test object startIndex
- Expect.throws(
- () => "hello".replaceFirstMapped("h", (_) => "X", new Object()));
+ Expect
+ .throws(() => "hello".replaceFirstMapped("h", (_) => "X", new Object()));
// Test replacement depending on argument.
- Expect.equals(
- "foo-BAR-foo-bar",
+ Expect.equals("foo-BAR-foo-bar",
"foo-bar-foo-bar".replaceFirstMapped("bar", (v) => v[0].toUpperCase()));
- Expect.equals(
- "foo-[bar]-foo-bar",
+ Expect.equals("foo-[bar]-foo-bar",
"foo-bar-foo-bar".replaceFirstMapped("bar", (v) => "[${v[0]}]"));
Expect.equals("foo-foo-bar-foo-bar-foo-bar",
- "foo-bar-foo-bar".replaceFirstMapped("bar", (v) => v.input));
+ "foo-bar-foo-bar".replaceFirstMapped("bar", (v) => v.input));
// Test replacement throwing.
- Expect.throws(
- () => "foo-bar".replaceFirstMapped("bar", (v) => throw 42),
- (e) => e == 42);
+ Expect.throws(() => "foo-bar".replaceFirstMapped("bar", (v) => throw 42),
+ (e) => e == 42);
// Test replacement returning non-String.
var o = new Object();
- Expect.equals("foo-$o", "foo-bar".replaceFirstMapped("bar",
- (v) { return o; }));
+ Expect.equals(
+ "foo-$o",
+ "foo-bar".replaceFirstMapped("bar", (v) {
+ return o;
+ }));
- Expect.equals("foo-42", "foo-bar".replaceFirstMapped("bar",
- (v) { return 42; }));
+ Expect.equals(
+ "foo-42",
+ "foo-bar".replaceFirstMapped("bar", (v) {
+ return 42;
+ }));
// Test replacement returning object throwing on string-conversion.
var n = new Naughty();
- Expect.throws(
- () => "foo-bar".replaceFirstMapped("bar", (v) { return n; }));
+ Expect.throws(() => "foo-bar".replaceFirstMapped("bar", (v) {
+ return n;
+ }));
for (var string in ["", "x", "foo", "x\u2000z"]) {
for (var replacement in ["", "foo", string]) {
for (int start = 0; start <= string.length; start++) {
var expect;
for (int end = start; end <= string.length; end++) {
- expect = string.substring(0, start) +
- replacement +
- string.substring(end);
+ expect =
+ string.substring(0, start) + replacement + string.substring(end);
Expect.equals(expect, string.replaceRange(start, end, replacement),
- '"$string"[$start:$end]="$replacement"');
+ '"$string"[$start:$end]="$replacement"');
}
// Reuse expect from "end == string.length" case when omitting end.
Expect.equals(expect, string.replaceRange(start, null, replacement),
- '"$string"[$start:]="$replacement"');
+ '"$string"[$start:]="$replacement"');
}
}
Expect.throws(() => string.replaceRange(0, 0, null));

Powered by Google App Engine
This is Rietveld 408576698