OLD | NEW |
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 // Dart test program for the "is" type test operator. | 4 // Dart test program for the "is" type test operator. |
5 | 5 |
| 6 import "package:expect/expect.dart"; |
| 7 |
6 testTryCatch(x) { | 8 testTryCatch(x) { |
7 try { | 9 try { |
8 throw x; | 10 throw x; |
9 Expect.fail("Exception '$x' should've been thrown"); | 11 Expect.fail("Exception '$x' should've been thrown"); |
10 } on Object catch (obj) { | 12 } on Object catch (obj) { |
11 Expect.equals(obj, x); | 13 Expect.equals(obj, x); |
12 } | 14 } |
13 } | 15 } |
14 | 16 |
15 main() { | 17 main() { |
(...skipping 20 matching lines...) Expand all Loading... |
36 Expect.isTrue(testEval(false) is Object); | 38 Expect.isTrue(testEval(false) is Object); |
37 Expect.equals(3, evalCount); | 39 Expect.equals(3, evalCount); |
38 Expect.isTrue(testEval(null) is Object); | 40 Expect.isTrue(testEval(null) is Object); |
39 Expect.equals(4, evalCount); | 41 Expect.equals(4, evalCount); |
40 | 42 |
41 // Verify that these objects are catchable | 43 // Verify that these objects are catchable |
42 testTryCatch(444); | 44 testTryCatch(444); |
43 testTryCatch('abc'); | 45 testTryCatch('abc'); |
44 testTryCatch(true); | 46 testTryCatch(true); |
45 } | 47 } |
OLD | NEW |