OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012, 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 foo(a, b, c) {} |
| 6 |
| 7 class A { |
| 8 foo() => 42; |
| 9 } |
| 10 |
| 11 void main() { |
| 12 Expect.throws( |
| 13 () => foo(throw 1, 2, 3), |
| 14 (e) => e == 1); |
| 15 Expect.throws( |
| 16 () => foo(1, throw 2, 3), |
| 17 (e) => e == 2); |
| 18 Expect.throws( |
| 19 () => foo(1, 2, throw 3), |
| 20 (e) => e == 3); |
| 21 Expect.throws( |
| 22 () => throw 3 + 7, |
| 23 (e) => e == 10); |
| 24 Expect.throws( |
| 25 () => -throw 3, |
| 26 (e) => e == 3); |
| 27 Expect.throws( |
| 28 () => throw -3, |
| 29 (e) => e == -3); |
| 30 Expect.throws( |
| 31 () => throw 3 * 7, |
| 32 (e) => e == 21); |
| 33 Expect.throws( |
| 34 () => throw new A()..foo(), |
| 35 (e) => e is A); |
| 36 Expect.throws( |
| 37 ([a]) => throw ?a ? 1 : 2, |
| 38 (e) => e == 2); |
| 39 Expect.throws( |
| 40 ([a]) => throw ?a, |
| 41 (e) => e == false); |
| 42 Expect.throws( |
| 43 () => throw +42, |
| 44 (e) => e == 42); |
| 45 Expect.throws( |
| 46 () => throw [], |
| 47 (e) => e is List); |
| 48 Expect.throws( |
| 49 () => throw [42], |
| 50 (e) => e is List); |
| 51 Expect.throws( |
| 52 () => throw (42), |
| 53 (e) => e == 42); |
| 54 Expect.throws( |
| 55 () => throw {}, |
| 56 (e) => e is Map); |
| 57 var value = 42; |
| 58 Expect.throws( |
| 59 () => throw ++value, |
| 60 (e) => e == 43); |
| 61 Expect.throws( |
| 62 () => throw --value, |
| 63 (e) => e == 42); |
| 64 |
| 65 throw (); /// 01: compile-time error |
| 66 } |
OLD | NEW |