| 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 import "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; | 
| 9 import "package:async_helper/async_helper.dart"; | 9 import "package:async_helper/async_helper.dart"; | 
| 10 import 'dart:isolate'; | 10 import 'dart:isolate'; | 
| 11 import 'dart:async'; | 11 import 'dart:async'; | 
| 12 | 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   print("received: ${msg.x}"); | 19   var a = msg[0]; | 
| 20   msg.x = 1; | 20   var replyTo = msg[1]; | 
| 21   print("done updating: ${msg.x}"); | 21   print("received: ${a.x}"); | 
|  | 22   a.x = 1; | 
|  | 23   print("done updating: ${a.x}"); | 
|  | 24   replyTo.send("done"); | 
| 22 } | 25 } | 
| 23 | 26 | 
| 24 main() { | 27 main() { | 
| 25   asyncStart(); | 28   asyncStart(); | 
| 26   var a = new A(); | 29   var a = new A(); | 
| 27   // Sending an A object to another isolate should not work. | 30   ReceivePort rp = new ReceivePort(); | 
| 28   Isolate.spawn(fun, a).then((isolate) { | 31   Isolate.spawn(fun, [a, rp.sendPort]); | 
| 29     new Timer(const Duration(milliseconds: 300), () { | 32   rp.first.then((msg) { | 
| 30       // Changes in other isolate must not reach here. | 33     Expect.equals("done", msg); | 
| 31       Expect.equals(0, a.x); | 34     // Changes in other isolate must not reach here. | 
| 32       asyncEnd(); | 35     Expect.equals(0, a.x); | 
| 33     }); |  | 
| 34   }, onError: (e) { |  | 
| 35     // Sending an A isn't required to work. |  | 
| 36     // It works in the VM, but not in dart2js. |  | 
| 37     print("Send of A failed:\n$e"); |  | 
| 38     asyncEnd(); | 36     asyncEnd(); | 
| 39   }); | 37   }); | 
| 40 } | 38 } | 
| OLD | NEW | 
|---|