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

Side by Side Diff: tests/language/assertion_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/arithmetic_test.dart ('k') | tests/language/bad_named_parameters2_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 // VMOptions=--enable_type_checks 4 // VMOptions=--enable_type_checks
5 // 5 //
6 // Dart test program testing assert statements. 6 // Dart test program testing assert statements.
7 7
8 class AssertionTest { 8 class AssertionTest {
9 static testTrue() { 9 static testTrue() {
10 int i = 0; 10 int i = 0;
11 try { 11 try {
12 assert(true); 12 assert(true);
13 } catch (AssertionError error) { 13 } on AssertionError catch (error) {
14 i = 1; 14 i = 1;
15 } 15 }
16 return i; 16 return i;
17 } 17 }
18 18
19 static testFalse() { 19 static testFalse() {
20 int i = 0; 20 int i = 0;
21 try { 21 try {
22 assert(false); 22 assert(false);
23 } catch (AssertionError error) { 23 } on AssertionError catch (error) {
24 i = 1; 24 i = 1;
25 } 25 }
26 return i; 26 return i;
27 } 27 }
28 28
29 static unknown(var a) { 29 static unknown(var a) {
30 return (a) ? true : false; 30 return (a) ? true : false;
31 } 31 }
32 32
33 static testUnknown() { 33 static testUnknown() {
34 var x = unknown(false); 34 var x = unknown(false);
35 int i = 0; 35 int i = 0;
36 try { 36 try {
37 assert(x); 37 assert(x);
38 } catch (AssertionError error) { 38 } on AssertionError catch (error) {
39 i = 1; 39 i = 1;
40 } 40 }
41 return i; 41 return i;
42 } 42 }
43 43
44 static testClosure() { 44 static testClosure() {
45 int i = 0; 45 int i = 0;
46 try { 46 try {
47 assert(() => false); 47 assert(() => false);
48 } catch (AssertionError error) { 48 } on AssertionError catch (error) {
49 i = 1; 49 i = 1;
50 } 50 }
51 return i; 51 return i;
52 } 52 }
53 53
54 static testClosure2() { 54 static testClosure2() {
55 int i = 0; 55 int i = 0;
56 try { 56 try {
57 var x = () => false; 57 var x = () => false;
58 assert(x); 58 assert(x);
59 } catch (AssertionError error) { 59 } on AssertionError catch (error) {
60 i = 1; 60 i = 1;
61 } 61 }
62 return i; 62 return i;
63 } 63 }
64 64
65 static testMain() { 65 static testMain() {
66 Expect.equals(0, testTrue()); 66 Expect.equals(0, testTrue());
67 Expect.equals(1, testFalse()); 67 Expect.equals(1, testFalse());
68 Expect.equals(1, testClosure()); 68 Expect.equals(1, testClosure());
69 Expect.equals(1, testClosure2()); 69 Expect.equals(1, testClosure2());
70 } 70 }
71 } 71 }
72 72
73 main() { 73 main() {
74 AssertionTest.testMain(); 74 AssertionTest.testMain();
75 } 75 }
OLDNEW
« no previous file with comments | « tests/language/arithmetic_test.dart ('k') | tests/language/bad_named_parameters2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698