OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 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 | 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 import "dart:isolate"; | 5 import "dart:isolate"; |
6 import "package:unittest/unittest.dart"; | 6 import "package:unittest/unittest.dart"; |
7 | 7 |
8 Uri toDartDataUri(String source) { | 8 Uri toDartDataUri(String source) { |
9 return Uri.parse("data:application/dart;charset=utf-8," | 9 return Uri.parse("data:application/dart;charset=utf-8," |
10 "${Uri.encodeComponent(source)}"); | 10 "${Uri.encodeComponent(source)}"); |
11 } | 11 } |
12 | 12 |
13 main() { | 13 main() { |
14 test('Simple response', () { | 14 test('Simple response', () { |
15 String source = """ | 15 String source = """ |
16 import "dart:isolate"; | 16 import "dart:isolate"; |
17 main(List args, SendPort replyPort) { | 17 main(List args, SendPort replyPort) { |
18 replyPort.send(42); | 18 replyPort.send(42); |
19 } | 19 } |
20 """; | 20 """; |
21 | 21 |
22 RawReceivePort receivePort; | 22 RawReceivePort receivePort; |
23 receivePort = new RawReceivePort(expectAsync((int message) { | 23 receivePort = new RawReceivePort(expectAsync((int message) { |
24 expect(message, equals(42)); | 24 expect(message, equals(42)); |
25 receivePort.close(); | 25 receivePort.close(); |
26 })); | 26 })); |
27 Isolate.spawnUri(toDartDataUri(source), [], receivePort.sendPort); | 27 Isolate.spawnUri(toDartDataUri(source), [], receivePort.sendPort); |
28 }); | 28 }); |
29 } | 29 } |
OLD | NEW |