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 "include/dart_api.h" | 5 #include "include/dart_api.h" |
6 #include "platform/assert.h" | 6 #include "platform/assert.h" |
7 #include "platform/json.h" | 7 #include "platform/json.h" |
8 #include "platform/utils.h" | 8 #include "platform/utils.h" |
9 #include "vm/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
10 #include "vm/dart_api_impl.h" | 10 #include "vm/dart_api_impl.h" |
(...skipping 5588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5599 reinterpret_cast<Dart_CObject*>(Dart_ScopeAllocate(sizeof(Dart_CObject))); | 5599 reinterpret_cast<Dart_CObject*>(Dart_ScopeAllocate(sizeof(Dart_CObject))); |
5600 response->type = Dart_CObject::kInt32; | 5600 response->type = Dart_CObject::kInt32; |
5601 response->value.as_int32 = 321; | 5601 response->value.as_int32 = 321; |
5602 Dart_PostCObject(reply_port_id, response); | 5602 Dart_PostCObject(reply_port_id, response); |
5603 } | 5603 } |
5604 | 5604 |
5605 | 5605 |
5606 UNIT_TEST_CASE(NewNativePort) { | 5606 UNIT_TEST_CASE(NewNativePort) { |
5607 // Create a port with a bogus handler. | 5607 // Create a port with a bogus handler. |
5608 Dart_Port error_port = Dart_NewNativePort("Foo", NULL, true); | 5608 Dart_Port error_port = Dart_NewNativePort("Foo", NULL, true); |
5609 EXPECT_EQ(kIllegalPort, error_port); | 5609 EXPECT_EQ(ILLEGAL_PORT, error_port); |
5610 | 5610 |
5611 // Create the port w/o a current isolate, just to make sure that works. | 5611 // Create the port w/o a current isolate, just to make sure that works. |
5612 Dart_Port port_id1 = | 5612 Dart_Port port_id1 = |
5613 Dart_NewNativePort("Port123", NewNativePort_send123, true); | 5613 Dart_NewNativePort("Port123", NewNativePort_send123, true); |
5614 | 5614 |
5615 TestIsolateScope __test_isolate__; | 5615 TestIsolateScope __test_isolate__; |
5616 const char* kScriptChars = | 5616 const char* kScriptChars = |
5617 "#import('dart:isolate');\n" | 5617 "#import('dart:isolate');\n" |
5618 "void callPort(SendPort port) {\n" | 5618 "void callPort(SendPort port) {\n" |
5619 " port.call(null).then((message) {\n" | 5619 " port.call(null).then((message) {\n" |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6219 EXPECT_VALID(result); | 6219 EXPECT_VALID(result); |
6220 EXPECT(Dart_IsInteger(result)); | 6220 EXPECT(Dart_IsInteger(result)); |
6221 int64_t value = 0; | 6221 int64_t value = 0; |
6222 EXPECT_VALID(Dart_IntegerToInt64(result, &value)); | 6222 EXPECT_VALID(Dart_IntegerToInt64(result, &value)); |
6223 EXPECT_EQ(0, value); | 6223 EXPECT_EQ(0, value); |
6224 } | 6224 } |
6225 | 6225 |
6226 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 6226 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
6227 | 6227 |
6228 } // namespace dart | 6228 } // namespace dart |
OLD | NEW |