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

Side by Side Diff: tests/corelib_2/string_test.dart

Issue 2983253002: Migrated test block 29 to Dart 2.0 (Closed)
Patch Set: Migrated test block 29 to Dart 2.0 Created 3 years, 5 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
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 void main() { 7 void main() {
8 testOutOfRange(); 8 testOutOfRange();
9 testIllegalArgument();
10 testConcat(); 9 testConcat();
11 testIndex(); 10 testIndex();
12 testCodeUnitAt(); 11 testCodeUnitAt();
13 testEquals(); 12 testEquals();
14 testEndsWith(); 13 testEndsWith();
15 testStartsWith(); 14 testStartsWith();
16 testIndexOf(); 15 testIndexOf();
17 testLastIndexOf(); 16 testLastIndexOf();
18 testContains(); 17 testContains();
19 testReplaceAll(); 18 testReplaceAll();
(...skipping 16 matching lines...) Expand all
36 String a = "Hello"; 35 String a = "Hello";
37 bool exception_caught = false; 36 bool exception_caught = false;
38 try { 37 try {
39 var c = a[20]; // Throw exception. 38 var c = a[20]; // Throw exception.
40 } on RangeError catch (e) { 39 } on RangeError catch (e) {
41 exception_caught = true; 40 exception_caught = true;
42 } 41 }
43 Expect.isTrue(exception_caught); 42 Expect.isTrue(exception_caught);
44 } 43 }
45 44
46 void testIllegalArgument() {
47 String a = "Hello";
48 bool exception_caught = false;
49 try {
50 var c = a[2.2]; // Throw exception.
51 Expect.fail("Accepting double as index");
52 } on ArgumentError catch (e) {
53 exception_caught = true;
54 } on TypeError catch (e) {
55 // Thrown in checked mode only.
56 exception_caught = true;
57 }
58 Expect.isTrue(exception_caught);
59 }
60
61 void testIndex() { 45 void testIndex() {
62 String str = "string"; 46 String str = "string";
63 for (int i = 0; i < str.length; i++) { 47 for (int i = 0; i < str.length; i++) {
64 Expect.isTrue(str[i] is String); 48 Expect.isTrue(str[i] is String);
65 testStringLength(1, str[i]); 49 testStringLength(1, str[i]);
66 } 50 }
67 } 51 }
68 52
69 void testCodeUnitAt() { 53 void testCodeUnitAt() {
70 String str = "string"; 54 String str = "string";
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 Expect.equals('a', ''.padRight(1, 'a')); 469 Expect.equals('a', ''.padRight(1, 'a'));
486 Expect.equals('aaaaa', ''.padRight(5, 'a')); 470 Expect.equals('aaaaa', ''.padRight(5, 'a'));
487 Expect.equals('', ''.padRight(-2, 'a')); 471 Expect.equals('', ''.padRight(-2, 'a'));
488 472
489 Expect.equals('xyzxyzxyzxyzxyz', ''.padRight(5, 'xyz')); 473 Expect.equals('xyzxyzxyzxyzxyz', ''.padRight(5, 'xyz'));
490 Expect.equals('axyzxyzxyzxyz', 'a'.padRight(5, 'xyz')); 474 Expect.equals('axyzxyzxyzxyz', 'a'.padRight(5, 'xyz'));
491 Expect.equals('aaxyzxyzxyz', 'aa'.padRight(5, 'xyz')); 475 Expect.equals('aaxyzxyzxyz', 'aa'.padRight(5, 'xyz'));
492 Expect.equals('aa\u{10002}\u{10002}\u{10002}', 'aa'.padRight(5, '\u{10002}')); 476 Expect.equals('aa\u{10002}\u{10002}\u{10002}', 'aa'.padRight(5, '\u{10002}'));
493 Expect.equals('a', 'a'.padRight(10, '')); 477 Expect.equals('a', 'a'.padRight(10, ''));
494 } 478 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698