OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 | 4 |
5 // Test that dart2js can handle unexpected exception types. | 5 // Test that dart2js can handle unexpected exception types. |
6 | 6 |
7 library native_exception_test; | 7 library native_exception_test; |
8 | 8 |
9 import 'dart:_foreign_helper' show JS; | 9 import 'dart:_foreign_helper' show JS; |
10 import 'dart:_js_helper'; | 10 import 'dart:_js_helper'; |
11 import 'package:expect/expect.dart'; | 11 import 'package:expect/expect.dart'; |
12 | 12 |
13 main() { | 13 main() { |
14 var previous; | 14 var previous; |
15 check(e) { | 15 check(e) { |
16 print('$e'); | 16 print('$e'); |
17 Expect.equals(e, e); | 17 Expect.equals(e, e); |
18 Expect.notEquals(e, new Object()); | 18 Expect.notEquals(e, new Object()); |
19 Expect.notEquals(e, previous); | 19 Expect.notEquals(e, previous); |
20 previous = e; | 20 previous = e; |
21 return '$e' != '[object Object]'; | 21 return '$e' != '[object Object]'; |
22 } | 22 } |
23 Expect.throws(() { JS('void', 'noGlobalVariableWithThisName'); }, check); | 23 |
24 Expect.throws(() { JS('void', 'throw 3'); }, check); | 24 Expect.throws(() { |
25 Expect.throws( | 25 JS('void', 'noGlobalVariableWithThisName'); |
26 () { | 26 }, check); |
27 JS('bool', 'Object.prototype.hasOwnProperty.call(undefined, "foo")'); | 27 Expect.throws(() { |
28 }, | 28 JS('void', 'throw 3'); |
29 check); | 29 }, check); |
30 Expect.throws(() { JS('void', 'throw new ReferenceError()'); }, check); | 30 Expect.throws(() { |
31 Expect.throws(() { JS('void', 'throw void 0'); }, check); | 31 JS('bool', 'Object.prototype.hasOwnProperty.call(undefined, "foo")'); |
32 Expect.throws(() { JS('void', 'throw "a string"'); }, check); | 32 }, check); |
33 Expect.throws(() { JS('void', 'throw null'); }, check); | 33 Expect.throws(() { |
| 34 JS('void', 'throw new ReferenceError()'); |
| 35 }, check); |
| 36 Expect.throws(() { |
| 37 JS('void', 'throw void 0'); |
| 38 }, check); |
| 39 Expect.throws(() { |
| 40 JS('void', 'throw "a string"'); |
| 41 }, check); |
| 42 Expect.throws(() { |
| 43 JS('void', 'throw null'); |
| 44 }, check); |
34 } | 45 } |
OLD | NEW |