OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 import "dart:async"; |
| 6 import "dart:js"; |
| 7 import "dart:collection" show Queue; |
| 8 import "package:expect/expect.dart"; |
| 9 import "package:async_helper/async_helper.dart"; |
| 10 |
| 11 var errors = new Queue(); |
| 12 int ctr = 0; |
| 13 |
| 14 main() { |
| 15 print("STARTED"); |
| 16 asyncStart(); |
| 17 |
| 18 void errorHandler(self, message, url, line, [column, error]) { |
| 19 print(">> $message / $ctr"); |
| 20 var expect = errors.removeFirst(); |
| 21 if (ctr == 2) { |
| 22 asyncEnd(); |
| 23 print("DONE"); |
| 24 } |
| 25 Expect.equals(expect[0].toString(), message); |
| 26 Expect.equals(expect[1].toString(), error["stack"].toString()); |
| 27 } |
| 28 context["onerror"] = new JsFunction.withThis(errorHandler); |
| 29 |
| 30 void throwit() { |
| 31 var err = ++ctr; |
| 32 try { |
| 33 throw err; |
| 34 } catch (e, s) { |
| 35 errors.add([e, s]); |
| 36 rethrow; |
| 37 } |
| 38 } |
| 39 |
| 40 () async { |
| 41 () async { |
| 42 throwit(); |
| 43 }(); |
| 44 throwit(); |
| 45 }(); |
| 46 } |
OLD | NEW |