Chromium Code Reviews| Index: tests/isolate/static_function_test.dart |
| diff --git a/tests/isolate/static_function_test.dart b/tests/isolate/static_function_test.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4a80fcc4a3ddc90b993f3bdf133ea2582dc75a62 |
| --- /dev/null |
| +++ b/tests/isolate/static_function_test.dart |
| @@ -0,0 +1,56 @@ |
| +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +// Test starting isolate with static functions (and toplevel ones, for sanity). |
| +// VMOptions=--enable_type_checks --enable_asserts |
|
Ivan Posva
2013/11/12 07:19:49
Why are you enforcing these VM options here?
Lasse Reichstein Nielsen
2013/11/12 07:28:51
Not needed. They were in the test file I started o
|
| + |
| +library static_function_test; |
| +import 'dart:isolate'; |
| +import 'dart:async'; |
| +import 'static_function_testlib.dart' as lib; |
| +import '../../pkg/unittest/lib/unittest.dart'; |
| + |
| +void function(SendPort port) { port.send("TOP"); } |
| +void _function(SendPort port) { port.send("_TOP"); } |
| + |
| +class C { |
| + static function(SendPort port) { port.send("YES"); } |
| + static _function(SendPort port) { port.send("PRIVATE"); } |
| +} |
| + |
| +class _C { |
| + static function(SendPort port) { port.send("_YES"); } |
| + static _function(SendPort port) { port.send("_PRIVATE"); } |
| +} |
| + |
| +void spawnTest(name, function, response) { |
| + test(name, () { |
| + ReceivePort r = new ReceivePort(); |
| + Isolate.spawn(function, r.sendPort); |
| + r.listen(expectAsync1((v) { |
| + expect(v, response); |
| + r.close(); |
| + })); |
| + }); |
| +} |
| + |
| +void main() { |
| + // Sanity check. |
| + spawnTest("function", function, "TOP"); |
| + spawnTest("_function", _function, "_TOP"); |
| + spawnTest("lib.function", lib.function, "LIBTOP"); |
| + spawnTest("lib._function", lib.privateFunction, "_LIBTOP"); |
| + |
| + // Local static functions. |
| + spawnTest("class.function", C.function, "YES"); |
| + spawnTest("class._function", C._function, "PRIVATE"); |
| + spawnTest("_class._function", _C.function, "_YES"); |
| + spawnTest("_class._function", _C._function, "_PRIVATE"); |
| + |
| + // Imported static functions. |
| + spawnTest("lib.class.function", lib.C.function, "LIB"); |
| + spawnTest("lib.class._function", lib.C.privateFunction, "LIBPRIVATE"); |
| + spawnTest("lib._class._function", lib.privateClassFunction, "_LIB"); |
| + spawnTest("lib._class._function", lib.privateClassAndFunction, "_LIBPRIVATE"); |
| +} |