OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2014, 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 import "dart:isolate"; |
| 6 import "dart:async"; |
| 7 import "package:expect/expect.dart"; |
| 8 import "package:async_helper/async_helper.dart"; |
| 9 |
| 10 void main([args, message]) { |
| 11 if (message != null) return isolateMain(message); |
| 12 |
| 13 bool isChecked = false; |
| 14 assert((isChecked = true)); |
| 15 if (isChecked) return; // Skip this test in checked mode. |
| 16 |
| 17 var responses = {}; |
| 18 var port = new RawReceivePort(); |
| 19 port.handler = (pair) { |
| 20 responses[pair[0]] = pair[1]; |
| 21 if (responses.length == 3) { |
| 22 port.close(); |
| 23 Expect.isTrue(responses[true], "true @ $isChecked"); |
| 24 Expect.isTrue(responses[false], "false @ $isChecked"); |
| 25 Expect.isTrue(responses[null], "null @ $isChecked"); |
| 26 } |
| 27 }; |
| 28 test(checked) { |
| 29 Isolate.spawnUri(Uri.parse("checked_test.dart"), [], |
| 30 [checked, isChecked, port.sendPort], |
| 31 checked: checked); |
| 32 } |
| 33 test(true); |
| 34 test(false); |
| 35 test(null); |
| 36 } |
| 37 |
| 38 |
| 39 void isolateMain(args) { |
| 40 var checkedFlag = args[0]; |
| 41 var parentIsChecked = args[1]; |
| 42 var responsePort = args[2]; |
| 43 bool isChecked = false; |
| 44 assert((isChecked = true)); |
| 45 bool expected = checkedFlag; |
| 46 if (checkedFlag == null) expected = parentIsChecked; |
| 47 responsePort.send([checkedFlag, expected == isChecked]); |
| 48 } |
OLD | NEW |