| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 // Test starting isolate with static functions (and toplevel ones, for sanity). | 5 // Test starting isolate with static functions (and toplevel ones, for sanity). |
| 6 | 6 |
| 7 library static_function_test; | 7 library static_function_test; |
| 8 import 'dart:isolate'; | 8 import 'dart:isolate'; |
| 9 import 'dart:async'; | 9 import 'dart:async'; |
| 10 import 'static_function_lib.dart' as lib; | 10 import 'static_function_lib.dart' as lib; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 | 56 |
| 57 class _C { | 57 class _C { |
| 58 static void function(SendPort port) { port.send("_YES"); } | 58 static void function(SendPort port) { port.send("_YES"); } |
| 59 static void _function(SendPort port) { port.send("_PRIVATE"); } | 59 static void _function(SendPort port) { port.send("_PRIVATE"); } |
| 60 } | 60 } |
| 61 | 61 |
| 62 void spawnTest(name, function, response) { | 62 void spawnTest(name, function, response) { |
| 63 test(name, () { | 63 test(name, () { |
| 64 ReceivePort r = new ReceivePort(); | 64 ReceivePort r = new ReceivePort(); |
| 65 Isolate.spawn(function, r.sendPort); | 65 Isolate.spawn(function, r.sendPort); |
| 66 r.listen(expectAsync1((v) { | 66 r.listen(expectAsync((v) { |
| 67 expect(v, response); | 67 expect(v, response); |
| 68 r.close(); | 68 r.close(); |
| 69 })); | 69 })); |
| 70 }); | 70 }); |
| 71 } | 71 } |
| 72 | 72 |
| 73 void functionFailTest(name, function) { | 73 void functionFailTest(name, function) { |
| 74 test("throws on $name", () { | 74 test("throws on $name", () { |
| 75 Isolate.spawn(function, null).catchError(expectAsync1((e) { | 75 Isolate.spawn(function, null).catchError(expectAsync((e) { |
| 76 /* do nothing */ | 76 /* do nothing */ |
| 77 })); | 77 })); |
| 78 }); | 78 }); |
| 79 } | 79 } |
| 80 | 80 |
| 81 void main([args, port]) { | 81 void main([args, port]) { |
| 82 if (testRemote(main, port)) return; | 82 if (testRemote(main, port)) return; |
| 83 // Sanity check. | 83 // Sanity check. |
| 84 spawnTest("function", function, "TOP"); | 84 spawnTest("function", function, "TOP"); |
| 85 spawnTest("_function", _function, "_TOP"); | 85 spawnTest("_function", _function, "_TOP"); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 103 functionFailTest("dynamic closure", dynamicClosure); | 103 functionFailTest("dynamic closure", dynamicClosure); |
| 104 functionFailTest("named dynamic closure", namedDynamicClosure); | 104 functionFailTest("named dynamic closure", namedDynamicClosure); |
| 105 functionFailTest("instance closure", new C().instanceClosure); | 105 functionFailTest("instance closure", new C().instanceClosure); |
| 106 functionFailTest("initializer closure", | 106 functionFailTest("initializer closure", |
| 107 new C().constructorInitializerClosure); | 107 new C().constructorInitializerClosure); |
| 108 functionFailTest("constructor closure", new C().constructorBodyClosure); | 108 functionFailTest("constructor closure", new C().constructorBodyClosure); |
| 109 functionFailTest("named constructor closure", | 109 functionFailTest("named constructor closure", |
| 110 new C().namedConstructorBodyClosure); | 110 new C().namedConstructorBodyClosure); |
| 111 functionFailTest("instance method", new C().instanceMethod); | 111 functionFailTest("instance method", new C().instanceMethod); |
| 112 } | 112 } |
| OLD | NEW |