OLD | NEW |
| 1 // Copyright (c) 2015, 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 library deferred_in_isolate2_test; |
| 6 |
1 import 'dart:isolate'; | 7 import 'dart:isolate'; |
2 import 'dart:async'; | 8 import 'dart:async'; |
3 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
4 | 10 |
5 import 'deferred_in_isolate2_lib.dart' deferred as lib; | 11 import 'deferred_in_isolate2_lib.dart' deferred as lib; |
6 | 12 |
7 loadDeferred(port) { | 13 loadDeferred(port) { |
8 lib.loadLibrary().then((_) { | 14 lib.loadLibrary().then((_) { |
9 port.send(lib.f()); | 15 port.send(lib.f()); |
10 }); | 16 }); |
11 } | 17 } |
12 | 18 |
13 main() { | 19 main() { |
14 test("Deferred loading in isolate", () { | 20 test("Deferred loading in isolate", () { |
15 ReceivePort port = new ReceivePort(); | 21 ReceivePort port = new ReceivePort(); |
16 port.first.then(expectAsync((msg) { | 22 port.first.then(expectAsync((msg) { |
17 expect(msg, equals("hi")); | 23 expect(msg, equals("hi")); |
18 })); | 24 })); |
19 Isolate.spawn(loadDeferred, port.sendPort); | 25 Isolate.spawn(loadDeferred, port.sendPort); |
20 }); | 26 }); |
21 } | 27 } |
OLD | NEW |