| 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_debugger_api.h" | 7 #include "include/dart_debugger_api.h" |
| 8 #include "include/dart_mirrors_api.h" | 8 #include "include/dart_mirrors_api.h" |
| 9 #include "include/dart_native_api.h" | 9 #include "include/dart_native_api.h" |
| 10 #include "platform/assert.h" | 10 #include "platform/assert.h" |
| (...skipping 7123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7134 // Post integer value. | 7134 // Post integer value. |
| 7135 Dart_CObject* response = | 7135 Dart_CObject* response = |
| 7136 reinterpret_cast<Dart_CObject*>(Dart_ScopeAllocate(sizeof(Dart_CObject))); | 7136 reinterpret_cast<Dart_CObject*>(Dart_ScopeAllocate(sizeof(Dart_CObject))); |
| 7137 response->type = Dart_CObject_kInt32; | 7137 response->type = Dart_CObject_kInt32; |
| 7138 response->value.as_int32 = 321; | 7138 response->value.as_int32 = 321; |
| 7139 Dart_PostCObject( | 7139 Dart_PostCObject( |
| 7140 message->value.as_array.values[0]->value.as_send_port.id, response); | 7140 message->value.as_array.values[0]->value.as_send_port.id, response); |
| 7141 } | 7141 } |
| 7142 | 7142 |
| 7143 | 7143 |
| 7144 TEST_CASE(IllegalNewSendPort) { |
| 7145 Dart_Handle error = Dart_NewSendPort(ILLEGAL_PORT); |
| 7146 EXPECT(Dart_IsError(error)); |
| 7147 EXPECT(Dart_IsApiError(error)); |
| 7148 } |
| 7149 |
| 7150 |
| 7151 TEST_CASE(IllegalPost) { |
| 7152 Dart_Handle message = Dart_True(); |
| 7153 bool success = Dart_Post(ILLEGAL_PORT, message); |
| 7154 EXPECT(!success); |
| 7155 } |
| 7156 |
| 7157 |
| 7144 UNIT_TEST_CASE(NewNativePort) { | 7158 UNIT_TEST_CASE(NewNativePort) { |
| 7145 // Create a port with a bogus handler. | 7159 // Create a port with a bogus handler. |
| 7146 Dart_Port error_port = Dart_NewNativePort("Foo", NULL, true); | 7160 Dart_Port error_port = Dart_NewNativePort("Foo", NULL, true); |
| 7147 EXPECT_EQ(ILLEGAL_PORT, error_port); | 7161 EXPECT_EQ(ILLEGAL_PORT, error_port); |
| 7148 | 7162 |
| 7149 // Create the port w/o a current isolate, just to make sure that works. | 7163 // Create the port w/o a current isolate, just to make sure that works. |
| 7150 Dart_Port port_id1 = | 7164 Dart_Port port_id1 = |
| 7151 Dart_NewNativePort("Port123", NewNativePort_send123, true); | 7165 Dart_NewNativePort("Port123", NewNativePort_send123, true); |
| 7152 | 7166 |
| 7153 TestIsolateScope __test_isolate__; | 7167 TestIsolateScope __test_isolate__; |
| (...skipping 1768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8922 result = Dart_Invoke(lib, | 8936 result = Dart_Invoke(lib, |
| 8923 NewString("testView16"), | 8937 NewString("testView16"), |
| 8924 1, | 8938 1, |
| 8925 dart_args); | 8939 dart_args); |
| 8926 EXPECT_VALID(result); | 8940 EXPECT_VALID(result); |
| 8927 EXPECT(Dart_IsString(result)); | 8941 EXPECT(Dart_IsString(result)); |
| 8928 } | 8942 } |
| 8929 } | 8943 } |
| 8930 | 8944 |
| 8931 } // namespace dart | 8945 } // namespace dart |
| OLD | NEW |