Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
| 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. | |
| 4 | |
| 5 // Test starting isolate with static functions (and toplevel ones, for sanity). | |
| 6 // 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
| |
| 7 | |
| 8 library static_function_test; | |
| 9 import 'dart:isolate'; | |
| 10 import 'dart:async'; | |
| 11 import 'static_function_testlib.dart' as lib; | |
| 12 import '../../pkg/unittest/lib/unittest.dart'; | |
| 13 | |
| 14 void function(SendPort port) { port.send("TOP"); } | |
| 15 void _function(SendPort port) { port.send("_TOP"); } | |
| 16 | |
| 17 class C { | |
| 18 static function(SendPort port) { port.send("YES"); } | |
| 19 static _function(SendPort port) { port.send("PRIVATE"); } | |
| 20 } | |
| 21 | |
| 22 class _C { | |
| 23 static function(SendPort port) { port.send("_YES"); } | |
| 24 static _function(SendPort port) { port.send("_PRIVATE"); } | |
| 25 } | |
| 26 | |
| 27 void spawnTest(name, function, response) { | |
| 28 test(name, () { | |
| 29 ReceivePort r = new ReceivePort(); | |
| 30 Isolate.spawn(function, r.sendPort); | |
| 31 r.listen(expectAsync1((v) { | |
| 32 expect(v, response); | |
| 33 r.close(); | |
| 34 })); | |
| 35 }); | |
| 36 } | |
| 37 | |
| 38 void main() { | |
| 39 // Sanity check. | |
| 40 spawnTest("function", function, "TOP"); | |
| 41 spawnTest("_function", _function, "_TOP"); | |
| 42 spawnTest("lib.function", lib.function, "LIBTOP"); | |
| 43 spawnTest("lib._function", lib.privateFunction, "_LIBTOP"); | |
| 44 | |
| 45 // Local static functions. | |
| 46 spawnTest("class.function", C.function, "YES"); | |
| 47 spawnTest("class._function", C._function, "PRIVATE"); | |
| 48 spawnTest("_class._function", _C.function, "_YES"); | |
| 49 spawnTest("_class._function", _C._function, "_PRIVATE"); | |
| 50 | |
| 51 // Imported static functions. | |
| 52 spawnTest("lib.class.function", lib.C.function, "LIB"); | |
| 53 spawnTest("lib.class._function", lib.C.privateFunction, "LIBPRIVATE"); | |
| 54 spawnTest("lib._class._function", lib.privateClassFunction, "_LIB"); | |
| 55 spawnTest("lib._class._function", lib.privateClassAndFunction, "_LIBPRIVATE"); | |
| 56 } | |
| OLD | NEW |