| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 // Regression test for http://dartbug.com/18942 | 5 // Regression test for http://dartbug.com/18942 |
| 6 | 6 |
| 7 library LeakTest; | 7 library LeakTest; |
| 8 |
| 8 import "package:expect/expect.dart"; | 9 import "package:expect/expect.dart"; |
| 9 import "package:async_helper/async_helper.dart"; | 10 import "package:async_helper/async_helper.dart"; |
| 10 import 'dart:isolate'; | 11 import 'dart:isolate'; |
| 11 import 'dart:async'; | 12 import 'dart:async'; |
| 12 | 13 |
| 13 | |
| 14 class A { | 14 class A { |
| 15 var x = 0; | 15 var x = 0; |
| 16 } | 16 } |
| 17 | 17 |
| 18 fun(msg) { | 18 fun(msg) { |
| 19 var a = msg[0]; | 19 var a = msg[0]; |
| 20 var replyTo = msg[1]; | 20 var replyTo = msg[1]; |
| 21 print("received: ${a.x}"); | 21 print("received: ${a.x}"); |
| 22 a.x = 1; | 22 a.x = 1; |
| 23 print("done updating: ${a.x}"); | 23 print("done updating: ${a.x}"); |
| 24 replyTo.send("done"); | 24 replyTo.send("done"); |
| 25 } | 25 } |
| 26 | 26 |
| 27 main() { | 27 main() { |
| 28 asyncStart(); | 28 asyncStart(); |
| 29 var a = new A(); | 29 var a = new A(); |
| 30 ReceivePort rp = new ReceivePort(); | 30 ReceivePort rp = new ReceivePort(); |
| 31 Isolate.spawn(fun, [a, rp.sendPort]); | 31 Isolate.spawn(fun, [a, rp.sendPort]); |
| 32 rp.first.then((msg) { | 32 rp.first.then((msg) { |
| 33 Expect.equals("done", msg); | 33 Expect.equals("done", msg); |
| 34 // Changes in other isolate must not reach here. | 34 // Changes in other isolate must not reach here. |
| 35 Expect.equals(0, a.x); | 35 Expect.equals(0, a.x); |
| 36 asyncEnd(); | 36 asyncEnd(); |
| 37 }); | 37 }); |
| 38 } | 38 } |
| OLD | NEW |