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

Unified Diff: tests/corelib_2/string_split_test.dart

Issue 3005533002: Fix the return type of String.split in DDC to be correct (Closed)
Patch Set: Created 3 years, 4 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
« tests/corelib_2/corelib_2.status ('K') | « tests/corelib_2/corelib_2.status ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/corelib_2/string_split_test.dart
diff --git a/tests/corelib_2/string_split_test.dart b/tests/corelib_2/string_split_test.dart
index de7b2492eba492f35821d37b4f5c79e1c9c9eae7..4234afe362c52fb7136fbcd30e88dd3a0b8200f8 100644
--- a/tests/corelib_2/string_split_test.dart
+++ b/tests/corelib_2/string_split_test.dart
@@ -10,7 +10,7 @@ main() {
testSplitPattern();
}
-testSplit(List expect, String string, Pattern pattern) {
+testSplit(List<String> expect, String string, Pattern pattern) {
String patternString;
if (pattern is String) {
patternString = '"$pattern"';
@@ -19,8 +19,20 @@ testSplit(List expect, String string, Pattern pattern) {
} else {
patternString = pattern.toString();
}
- Expect.listEquals(
- expect, string.split(pattern), '"$string".split($patternString)');
+ List actual = string.split(pattern);
+
+ // Check that the list is growable/mutable
+ actual
+ ..add('42')
+ ..removeLast();
+
+ // Ensure that the correct type is reified.
+ actual = actual as List<String>;
+ Expect.throws(() {
+ actual.add(42);
+ }, (e) => e is TypeError, 'List<String>.add should not accept an int');
+
+ Expect.listEquals(expect, actual, '"$string".split($patternString)');
}
/** String patterns. */
« tests/corelib_2/corelib_2.status ('K') | « tests/corelib_2/corelib_2.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698