Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2014, 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 // Test that deferred libraries are supported from isolates other than the root | |
| 6 // isolate. | |
| 7 | |
| 8 import 'dart:isolate'; | |
| 9 | |
| 10 main() { | |
| 11 try { | |
| 12 var receivePort = new RawReceivePort(); | |
| 13 var expectedMsg = "Deferred Loaded."; | |
| 14 | |
| 15 receivePort.handler = (msg) { | |
| 16 if (msg != expectedMsg) { | |
| 17 print("Test failed."); | |
| 18 throw msg; // Fail the test if the message is not expected. | |
| 19 } | |
| 20 print('Test done.'); | |
| 21 receivePort.close(); | |
| 22 }; | |
| 23 | |
| 24 var stopwatch = new Stopwatch()..start(); | |
| 25 Isolate.spawnUri(new Uri(path: 'deferred_in_isolate_app.dart'), | |
| 26 [expectedMsg], | |
| 27 [receivePort.sendPort]).then((isolate) { | |
| 28 print('Isolate spawn: ${stopwatch.elapsedMilliseconds}ms'); | |
| 29 }).catchError((error) { | |
| 30 print(error); | |
| 31 }); | |
| 32 } catch (exception, stackTrace) { | |
| 33 print('Test failed.'); | |
|
Vyacheslav Egorov (Google)
2014/07/17 12:38:27
The test failed but we still exit with 0 error cod
Ivan Posva
2014/07/17 12:45:13
Oops. Added a rethrow.
| |
| 34 print(exception); | |
| 35 print(stackTrace); | |
| 36 } | |
| 37 } | |
| OLD | NEW |