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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 Isolate.spawn(function, r.sendPort); | 65 Isolate.spawn(function, r.sendPort); |
66 r.listen(expectAsync1((v) { | 66 r.listen(expectAsync1((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 throwsTest(name, function) { | 73 void throwsTest(name, function) { |
74 test("throws on $name", () { | 74 test("throws on $name", () { |
75 expect(() { Isolate.spawn(function, null); }, throws); | 75 Isolate.spawn(function, null).catchError(expectAsync1((e) { |
| 76 /* do nothing */ |
| 77 })); |
76 }); | 78 }); |
77 } | 79 } |
78 | 80 |
79 void main([args, port]) { | 81 void main([args, port]) { |
80 if (testRemote(main, port)) return; | 82 if (testRemote(main, port)) return; |
81 // Sanity check. | 83 // Sanity check. |
82 spawnTest("function", function, "TOP"); | 84 spawnTest("function", function, "TOP"); |
83 spawnTest("_function", _function, "_TOP"); | 85 spawnTest("_function", _function, "_TOP"); |
84 spawnTest("lib.function", lib.function, "LIBTOP"); | 86 spawnTest("lib.function", lib.function, "LIBTOP"); |
85 spawnTest("lib._function", lib.privateFunction, "_LIBTOP"); | 87 spawnTest("lib._function", lib.privateFunction, "_LIBTOP"); |
(...skipping 13 matching lines...) Expand all Loading... |
99 // Negative tests | 101 // Negative tests |
100 throwsTest("static closure", staticClosure); | 102 throwsTest("static closure", staticClosure); |
101 throwsTest("dynamic closure", dynamicClosure); | 103 throwsTest("dynamic closure", dynamicClosure); |
102 throwsTest("named dynamic closure", namedDynamicClosure); | 104 throwsTest("named dynamic closure", namedDynamicClosure); |
103 throwsTest("instance closure", new C().instanceClosure); | 105 throwsTest("instance closure", new C().instanceClosure); |
104 throwsTest("initializer closure", new C().constructorInitializerClosure); | 106 throwsTest("initializer closure", new C().constructorInitializerClosure); |
105 throwsTest("constructor closure", new C().constructorBodyClosure); | 107 throwsTest("constructor closure", new C().constructorBodyClosure); |
106 throwsTest("named constructor closure", new C().namedConstructorBodyClosure); | 108 throwsTest("named constructor closure", new C().namedConstructorBodyClosure); |
107 throwsTest("instance method", new C().instanceMethod); | 109 throwsTest("instance method", new C().instanceMethod); |
108 } | 110 } |
OLD | NEW |