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

Side by Side Diff: tests/language/src/TryCatchTest.dart

Issue 10248007: test rename overhaul: step 8 - language tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 class MyException {
6 MyException() {}
7 }
8
9 class MyException1 extends MyException {
10 MyException1() : super() {}
11 }
12
13 class MyException2 extends MyException {
14 MyException2() : super() {}
15 }
16
17 class TryCatchTest {
18 static void test1() {
19 var foo = 0;
20 try {
21 throw new MyException1();
22 } catch (MyException2 e) {
23 foo = 1;
24 } catch (MyException1 e) {
25 foo = 2;
26 } catch (MyException e) {
27 foo = 3;
28 }
29 Expect.equals(2, foo);
30 }
31
32 static void test2() {
33 var foo = 0;
34 try {
35 throw new MyException1();
36 } catch (MyException2 e) {
37 foo = 1;
38 } catch (MyException e) {
39 foo = 2;
40 } catch (MyException1 e) {
41 foo = 3;
42 }
43 Expect.equals(2, foo);
44 }
45
46 static void test3() {
47 var foo = 0;
48 try {
49 throw new MyException();
50 } catch (MyException2 e) {
51 foo = 1;
52 } catch (MyException1 e) {
53 foo = 2;
54 } catch (MyException e) {
55 foo = 3;
56 }
57 Expect.equals(3, foo);
58 }
59
60 static void test4() {
61 var foo = 0;
62 try {
63 try {
64 throw new MyException();
65 } catch (MyException2 e) {
66 foo = 1;
67 } catch (MyException1 e) {
68 foo = 2;
69 }
70 } catch (MyException e) {
71 Expect.equals(0, foo);
72 foo = 3;
73 }
74 Expect.equals(3, foo);
75 }
76
77 static void test5() {
78 var foo = 0;
79 try {
80 throw new MyException1();
81 } catch (MyException2 e) {
82 foo = 1;
83 } catch (var e) {
84 foo = 2;
85 }
86 Expect.equals(2, foo);
87 }
88
89 static void test6() {
90 var foo = 0;
91 try {
92 throw new MyException();
93 } catch (MyException2 e) {
94 foo = 1;
95 } catch (MyException1 e) {
96 foo = 2;
97 } catch (var e) {
98 foo = 3;
99 }
100 Expect.equals(3, foo);
101 }
102
103 static void test7() {
104 var foo = 0;
105 try {
106 try {
107 throw new MyException();
108 } catch (MyException2 e) {
109 foo = 1;
110 } catch (MyException1 e) {
111 foo = 2;
112 }
113 } catch (var e) {
114 Expect.equals(0, foo);
115 foo = 3;
116 }
117 Expect.equals(3, foo);
118 }
119
120 static void test8() {
121 var e = 3;
122 var caught = false;
123 try {
124 throw new MyException();
125 } catch (var exc) {
126 caught = true;
127 }
128 Expect.equals(true, caught);
129 Expect.equals(3, e);
130 }
131
132 static void testMain() {
133 test1();
134 test2();
135 test3();
136 test4();
137 test5();
138 test6();
139 test7();
140 test8();
141 }
142 }
143
144 main() {
145 TryCatchTest.testMain();
146 }
OLDNEW
« no previous file with comments | « tests/language/src/TryCatchSyntaxTest.dart ('k') | tests/language/src/TypeChecksInFactoryMethodTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698