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

Side by Side Diff: tests/language/expect_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/language/execute_finally9_test.dart ('k') | tests/language/external_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 // Testing the Expect class. 4 // Testing the Expect class.
5 5
6 class ExpectTest { 6 class ExpectTest {
7 7
8 static testEquals(a) { 8 static testEquals(a) {
9 try { 9 try {
10 Expect.equals("AB", a, "within testEquals"); 10 Expect.equals("AB", a, "within testEquals");
11 } catch (Exception msg) { 11 } on Exception catch (msg) {
12 print(msg); 12 print(msg);
13 return; 13 return;
14 } 14 }
15 Expect.equals("AB", "${a}B"); 15 Expect.equals("AB", "${a}B");
16 throw "Expect.equals did not fail"; 16 throw "Expect.equals did not fail";
17 } 17 }
18 18
19 static testIsTrue(f) { 19 static testIsTrue(f) {
20 try { 20 try {
21 Expect.isTrue(f); 21 Expect.isTrue(f);
22 } catch (Exception msg) { 22 } on Exception catch (msg) {
23 print(msg); 23 print(msg);
24 return; 24 return;
25 } 25 }
26 Expect.isFalse(f); 26 Expect.isFalse(f);
27 throw "Expect.isTrue did not fail"; 27 throw "Expect.isTrue did not fail";
28 } 28 }
29 29
30 static testIsFalse(t) { 30 static testIsFalse(t) {
31 try { 31 try {
32 Expect.isFalse(t); 32 Expect.isFalse(t);
33 } catch (Exception msg) { 33 } on Exception catch (msg) {
34 print(msg); 34 print(msg);
35 return; 35 return;
36 } 36 }
37 Expect.isTrue(t); 37 Expect.isTrue(t);
38 throw "Expect.isFalse did not fail"; 38 throw "Expect.isFalse did not fail";
39 } 39 }
40 40
41 static testIdentical(a) { 41 static testIdentical(a) {
42 var ab = "${a}B"; 42 var ab = "${a}B";
43 try { 43 try {
44 Expect.identical("AB", ab); 44 Expect.identical("AB", ab);
45 } catch (Exception msg) { 45 } on Exception catch (msg) {
46 print(msg); 46 print(msg);
47 return; 47 return;
48 } 48 }
49 Expect.equals("AB", ab); 49 Expect.equals("AB", ab);
50 throw "Expect.identical did not fail"; 50 throw "Expect.identical did not fail";
51 } 51 }
52 52
53 static testFail() { 53 static testFail() {
54 try { 54 try {
55 Expect.fail("fail now"); 55 Expect.fail("fail now");
56 } catch (Exception msg) { 56 } on Exception catch (msg) {
57 print(msg); 57 print(msg);
58 return; 58 return;
59 } 59 }
60 throw "Expect.fail did not fail"; 60 throw "Expect.fail did not fail";
61 } 61 }
62 62
63 static void testMain() { 63 static void testMain() {
64 testEquals("A"); 64 testEquals("A");
65 testIsTrue(false); 65 testIsTrue(false);
66 testIsTrue(1); 66 testIsTrue(1);
67 testIsFalse(true); 67 testIsFalse(true);
68 testIsFalse(0); 68 testIsFalse(0);
69 testIdentical("A"); 69 testIdentical("A");
70 testFail(); 70 testFail();
71 } 71 }
72 72
73 } 73 }
74 74
75 main() { 75 main() {
76 ExpectTest.testMain(); 76 ExpectTest.testMain();
77 } 77 }
OLDNEW
« no previous file with comments | « tests/language/execute_finally9_test.dart ('k') | tests/language/external_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698