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

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

Issue 10891020: Update almost all tests (except co19) to use the new try-catch syntax. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge. Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « tests/corelib/string_base_vm_test.dart ('k') | tests/html/audiocontext_test.dart » ('j') | 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) 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 // TODO(ngeoffray): test String methods with null arguments. 5 // TODO(ngeoffray): test String methods with null arguments.
6 class StringTest { 6 class StringTest {
7 7
8 static testMain() { 8 static testMain() {
9 testOutOfRange(); 9 testOutOfRange();
10 testIllegalArgument(); 10 testIllegalArgument();
(...skipping 10 matching lines...) Expand all
21 testCompareTo(); 21 testCompareTo();
22 testToList(); 22 testToList();
23 testCharCodes(); 23 testCharCodes();
24 } 24 }
25 25
26 static void testOutOfRange() { 26 static void testOutOfRange() {
27 String a = "Hello"; 27 String a = "Hello";
28 bool exception_caught = false; 28 bool exception_caught = false;
29 try { 29 try {
30 var c = a[20]; // Throw exception. 30 var c = a[20]; // Throw exception.
31 } catch (IndexOutOfRangeException e) { 31 } on IndexOutOfRangeException catch (e) {
32 exception_caught = true; 32 exception_caught = true;
33 } 33 }
34 Expect.equals(true, exception_caught); 34 Expect.equals(true, exception_caught);
35 } 35 }
36 36
37 static testIllegalArgument() { 37 static testIllegalArgument() {
38 String a = "Hello"; 38 String a = "Hello";
39 bool exception_caught = false; 39 bool exception_caught = false;
40 try { 40 try {
41 var c = a[2.2]; // Throw exception. 41 var c = a[2.2]; // Throw exception.
42 Expect.equals(true, false); 42 Expect.equals(true, false);
43 } catch (IllegalArgumentException e) { 43 } on IllegalArgumentException catch (e) {
44 exception_caught = true; 44 exception_caught = true;
45 } catch (TypeError e) { // Thrown in checked mode only. 45 } on TypeError catch (e) { // Thrown in checked mode only.
46 exception_caught = true; 46 exception_caught = true;
47 } 47 }
48 Expect.equals(true, exception_caught); 48 Expect.equals(true, exception_caught);
49 } 49 }
50 50
51 static testIndex() { 51 static testIndex() {
52 String str = "string"; 52 String str = "string";
53 for (int i = 0; i < str.length; i++) { 53 for (int i = 0; i < str.length; i++) {
54 Expect.equals(true, str[i] is String); 54 Expect.equals(true, str[i] is String);
55 Expect.equals(1, str[i].length); 55 Expect.equals(1, str[i].length);
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 } 292 }
293 test("abc"); 293 test("abc");
294 test(""); 294 test("");
295 test(" "); 295 test(" ");
296 } 296 }
297 } 297 }
298 298
299 main() { 299 main() {
300 StringTest.testMain(); 300 StringTest.testMain();
301 } 301 }
OLDNEW
« no previous file with comments | « tests/corelib/string_base_vm_test.dart ('k') | tests/html/audiocontext_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698