OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 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 | 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 #include "bin/builtin.h" | 5 #include "bin/builtin.h" |
6 #include "include/dart_api.h" | 6 #include "include/dart_api.h" |
7 #include "include/dart_mirrors_api.h" | 7 #include "include/dart_mirrors_api.h" |
8 #include "include/dart_native_api.h" | 8 #include "include/dart_native_api.h" |
9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
10 #include "platform/json.h" | 10 #include "platform/json.h" |
(...skipping 5727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5738 EXPECT_EQ(ILLEGAL_PORT, error_port); | 5738 EXPECT_EQ(ILLEGAL_PORT, error_port); |
5739 | 5739 |
5740 // Create the port w/o a current isolate, just to make sure that works. | 5740 // Create the port w/o a current isolate, just to make sure that works. |
5741 Dart_Port port_id1 = | 5741 Dart_Port port_id1 = |
5742 Dart_NewNativePort("Port123", NewNativePort_send123, true); | 5742 Dart_NewNativePort("Port123", NewNativePort_send123, true); |
5743 | 5743 |
5744 TestIsolateScope __test_isolate__; | 5744 TestIsolateScope __test_isolate__; |
5745 const char* kScriptChars = | 5745 const char* kScriptChars = |
5746 "import 'dart:isolate';\n" | 5746 "import 'dart:isolate';\n" |
5747 "void callPort(SendPort port) {\n" | 5747 "void callPort(SendPort port) {\n" |
5748 " port.call(null).then((message) {\n" | 5748 " var receivePort = new ReceivePort();\n" |
5749 " throw new Exception(message);\n" | 5749 " port.send(null, receivePort.toSendPort());\n" |
5750 " });\n" | 5750 " receivePort.receive((message, _) {\n" |
| 5751 " receivePort.close();\n" |
| 5752 " throw new Exception(message);\n" |
| 5753 " });\n" |
5751 "}\n"; | 5754 "}\n"; |
5752 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); | 5755 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
5753 Dart_EnterScope(); | 5756 Dart_EnterScope(); |
5754 | 5757 |
5755 // Create a port w/ a current isolate, to make sure that works too. | 5758 // Create a port w/ a current isolate, to make sure that works too. |
5756 Dart_Port port_id2 = | 5759 Dart_Port port_id2 = |
5757 Dart_NewNativePort("Port321", NewNativePort_send321, true); | 5760 Dart_NewNativePort("Port321", NewNativePort_send321, true); |
5758 | 5761 |
5759 Dart_Handle send_port1 = Dart_NewSendPort(port_id1); | 5762 Dart_Handle send_port1 = Dart_NewSendPort(port_id1); |
5760 EXPECT_VALID(send_port1); | 5763 EXPECT_VALID(send_port1); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5802 " throw new Exception('MakeChildExit');\n" | 5805 " throw new Exception('MakeChildExit');\n" |
5803 " } else {\n" | 5806 " } else {\n" |
5804 " replyTo.call('hello');\n" | 5807 " replyTo.call('hello');\n" |
5805 " port.close();\n" | 5808 " port.close();\n" |
5806 " }\n" | 5809 " }\n" |
5807 " });\n" | 5810 " });\n" |
5808 "}\n" | 5811 "}\n" |
5809 "\n" | 5812 "\n" |
5810 "void main(exc_child, exc_parent) {\n" | 5813 "void main(exc_child, exc_parent) {\n" |
5811 " var port = spawnFunction(entry);\n" | 5814 " var port = spawnFunction(entry);\n" |
5812 " port.call(exc_child).then((message) {\n" | 5815 " var receivePort = new ReceivePort();\n" |
| 5816 " port.send(exc_child, receivePort.toSendPort());\n" |
| 5817 " receivePort.receive((message, _) {\n" |
| 5818 " receivePort.close();\n" |
5813 " if (message != 'hello') throw new Exception('ShouldNotHappen');\n" | 5819 " if (message != 'hello') throw new Exception('ShouldNotHappen');\n" |
5814 " if (exc_parent) throw new Exception('MakeParentExit');\n" | 5820 " if (exc_parent) throw new Exception('MakeParentExit');\n" |
5815 " });\n" | 5821 " });\n" |
5816 "}\n"; | 5822 "}\n"; |
5817 | 5823 |
5818 if (Dart_CurrentIsolate() != NULL) { | 5824 if (Dart_CurrentIsolate() != NULL) { |
5819 Dart_ExitIsolate(); | 5825 Dart_ExitIsolate(); |
5820 } | 5826 } |
5821 Dart_Isolate isolate = TestCase::CreateTestIsolate(); | 5827 Dart_Isolate isolate = TestCase::CreateTestIsolate(); |
5822 ASSERT(isolate != NULL); | 5828 ASSERT(isolate != NULL); |
(...skipping 1496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7319 NewString("main"), | 7325 NewString("main"), |
7320 0, | 7326 0, |
7321 NULL); | 7327 NULL); |
7322 int64_t value = 0; | 7328 int64_t value = 0; |
7323 result = Dart_IntegerToInt64(result, &value); | 7329 result = Dart_IntegerToInt64(result, &value); |
7324 EXPECT_VALID(result); | 7330 EXPECT_VALID(result); |
7325 EXPECT_EQ(8, value); | 7331 EXPECT_EQ(8, value); |
7326 } | 7332 } |
7327 | 7333 |
7328 } // namespace dart | 7334 } // namespace dart |
OLD | NEW |