OLD | NEW |
1 // Copyright (c) 2014, the Fletch project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dartino 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 import 'dart:fletch'; | 5 import 'dart:fletch'; |
6 | 6 |
7 import 'package:expect/expect.dart'; | 7 import 'package:expect/expect.dart'; |
8 | 8 |
9 main(arguments) { | 9 main(arguments) { |
10 var forceGC = (arguments.length == 1) ? arguments[0] : null; | 10 var forceGC = (arguments.length == 1) ? arguments[0] : null; |
11 // Create a port but throw away the channel. | 11 // Create a port but throw away the channel. |
12 var port = new Port(new Channel()); | 12 var port = new Port(new Channel()); |
13 if (forceGC != null) forceGC(); | 13 if (forceGC != null) forceGC(); |
14 // Send a number of messages to the port. | 14 // Send a number of messages to the port. |
15 for (int i = 0; i < 10; i++) port.send(i); | 15 for (int i = 0; i < 10; i++) port.send(i); |
16 // Create another port and send and receive a message. | 16 // Create another port and send and receive a message. |
17 var channel = new Channel(); | 17 var channel = new Channel(); |
18 port = new Port(channel); | 18 port = new Port(channel); |
19 port.send(42); | 19 port.send(42); |
20 Expect.equals(42, channel.receive()); | 20 Expect.equals(42, channel.receive()); |
21 } | 21 } |
OLD | NEW |