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 "vm/compiler.h" | 6 #include "vm/compiler.h" |
7 #include "include/dart_api.h" | 7 #include "include/dart_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 "include/dart_tools_api.h" | 10 #include "include/dart_tools_api.h" |
(...skipping 7132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7143 url = NewString("lib.dart"); | 7143 url = NewString("lib.dart"); |
7144 source = NewString(kLibraryChars); | 7144 source = NewString(kLibraryChars); |
7145 Dart_LoadLibrary(url, Dart_Null(), source, 0, 0); | 7145 Dart_LoadLibrary(url, Dart_Null(), source, 0, 0); |
7146 Dart_FinalizeLoading(false); | 7146 Dart_FinalizeLoading(false); |
7147 | 7147 |
7148 result = Dart_Invoke(result, NewString("main"), 0, NULL); | 7148 result = Dart_Invoke(result, NewString("main"), 0, NULL); |
7149 EXPECT_VALID(result); | 7149 EXPECT_VALID(result); |
7150 } | 7150 } |
7151 | 7151 |
7152 | 7152 |
7153 void NewNativePort_send123(Dart_Port dest_port_id, Dart_CObject* message) { | 7153 void NewNativePort_send123(Dart_Port dest_port_id, |
| 7154 Dart_CObject* message, |
| 7155 void* peer) { |
7154 // Gets a send port message. | 7156 // Gets a send port message. |
7155 EXPECT_NOTNULL(message); | 7157 EXPECT_NOTNULL(message); |
7156 EXPECT_EQ(Dart_CObject_kArray, message->type); | 7158 EXPECT_EQ(Dart_CObject_kArray, message->type); |
7157 EXPECT_EQ(Dart_CObject_kSendPort, message->value.as_array.values[0]->type); | 7159 EXPECT_EQ(Dart_CObject_kSendPort, message->value.as_array.values[0]->type); |
7158 | 7160 |
| 7161 // Check peer validity. |
| 7162 EXPECT_NOTNULL(peer); |
| 7163 EXPECT_EQ(0xDEADBEEF, *static_cast<intptr_t*>(peer)); |
| 7164 *static_cast<intptr_t*>(peer) = 123; |
| 7165 |
7159 // Post integer value. | 7166 // Post integer value. |
7160 Dart_CObject* response = | 7167 Dart_CObject* response = |
7161 reinterpret_cast<Dart_CObject*>(Dart_ScopeAllocate(sizeof(Dart_CObject))); | 7168 reinterpret_cast<Dart_CObject*>(Dart_ScopeAllocate(sizeof(Dart_CObject))); |
7162 response->type = Dart_CObject_kInt32; | 7169 response->type = Dart_CObject_kInt32; |
7163 response->value.as_int32 = 123; | 7170 response->value.as_int32 = 123; |
7164 Dart_PostCObject(message->value.as_array.values[0]->value.as_send_port.id, | 7171 Dart_PostCObject(message->value.as_array.values[0]->value.as_send_port.id, |
7165 response); | 7172 response); |
7166 } | 7173 } |
7167 | 7174 |
7168 | 7175 |
7169 void NewNativePort_send321(Dart_Port dest_port_id, Dart_CObject* message) { | 7176 void NewNativePort_send321(Dart_Port dest_port_id, |
| 7177 Dart_CObject* message, |
| 7178 void* peer) { |
7170 // Gets a null message. | 7179 // Gets a null message. |
7171 EXPECT_NOTNULL(message); | 7180 EXPECT_NOTNULL(message); |
7172 EXPECT_EQ(Dart_CObject_kArray, message->type); | 7181 EXPECT_EQ(Dart_CObject_kArray, message->type); |
7173 EXPECT_EQ(Dart_CObject_kSendPort, message->value.as_array.values[0]->type); | 7182 EXPECT_EQ(Dart_CObject_kSendPort, message->value.as_array.values[0]->type); |
7174 | 7183 |
| 7184 // Check peer validity. |
| 7185 EXPECT_NOTNULL(peer); |
| 7186 EXPECT_EQ(0xDEADBEEF, *static_cast<intptr_t*>(peer)); |
| 7187 *static_cast<intptr_t*>(peer) = 321; |
| 7188 |
7175 // Post integer value. | 7189 // Post integer value. |
7176 Dart_CObject* response = | 7190 Dart_CObject* response = |
7177 reinterpret_cast<Dart_CObject*>(Dart_ScopeAllocate(sizeof(Dart_CObject))); | 7191 reinterpret_cast<Dart_CObject*>(Dart_ScopeAllocate(sizeof(Dart_CObject))); |
7178 response->type = Dart_CObject_kInt32; | 7192 response->type = Dart_CObject_kInt32; |
7179 response->value.as_int32 = 321; | 7193 response->value.as_int32 = 321; |
7180 Dart_PostCObject(message->value.as_array.values[0]->value.as_send_port.id, | 7194 Dart_PostCObject(message->value.as_array.values[0]->value.as_send_port.id, |
7181 response); | 7195 response); |
7182 } | 7196 } |
7183 | 7197 |
7184 | 7198 |
7185 TEST_CASE(IllegalNewSendPort) { | 7199 TEST_CASE(IllegalNewSendPort) { |
7186 Dart_Handle error = Dart_NewSendPort(ILLEGAL_PORT); | 7200 Dart_Handle error = Dart_NewSendPort(ILLEGAL_PORT); |
7187 EXPECT(Dart_IsError(error)); | 7201 EXPECT(Dart_IsError(error)); |
7188 EXPECT(Dart_IsApiError(error)); | 7202 EXPECT(Dart_IsApiError(error)); |
7189 } | 7203 } |
7190 | 7204 |
7191 | 7205 |
7192 TEST_CASE(IllegalPost) { | 7206 TEST_CASE(IllegalPost) { |
7193 Dart_Handle message = Dart_True(); | 7207 Dart_Handle message = Dart_True(); |
7194 bool success = Dart_Post(ILLEGAL_PORT, message); | 7208 bool success = Dart_Post(ILLEGAL_PORT, message); |
7195 EXPECT(!success); | 7209 EXPECT(!success); |
7196 } | 7210 } |
7197 | 7211 |
7198 | 7212 |
7199 UNIT_TEST_CASE(NewNativePort) { | 7213 UNIT_TEST_CASE(NewNativePort) { |
7200 // Create a port with a bogus handler. | 7214 // Create a port with a bogus handler. |
7201 Dart_Port error_port = Dart_NewNativePort("Foo", NULL, true); | 7215 Dart_Port error_port = Dart_NewNativePort("Foo", NULL, true, NULL); |
7202 EXPECT_EQ(ILLEGAL_PORT, error_port); | 7216 EXPECT_EQ(ILLEGAL_PORT, error_port); |
7203 | 7217 |
| 7218 intptr_t peer1 = 0xDEADBEEF; |
7204 // Create the port w/o a current isolate, just to make sure that works. | 7219 // Create the port w/o a current isolate, just to make sure that works. |
7205 Dart_Port port_id1 = | 7220 Dart_Port port_id1 = |
7206 Dart_NewNativePort("Port123", NewNativePort_send123, true); | 7221 Dart_NewNativePort("Port123", NewNativePort_send123, true, &peer1); |
7207 | 7222 |
7208 TestIsolateScope __test_isolate__; | 7223 TestIsolateScope __test_isolate__; |
7209 const char* kScriptChars = | 7224 const char* kScriptChars = |
7210 "import 'dart:isolate';\n" | 7225 "import 'dart:isolate';\n" |
7211 "void callPort(SendPort port) {\n" | 7226 "void callPort(SendPort port) {\n" |
7212 " var receivePort = new RawReceivePort();\n" | 7227 " var receivePort = new RawReceivePort();\n" |
7213 " var replyPort = receivePort.sendPort;\n" | 7228 " var replyPort = receivePort.sendPort;\n" |
7214 " port.send([replyPort]);\n" | 7229 " port.send([replyPort]);\n" |
7215 " receivePort.handler = (message) {\n" | 7230 " receivePort.handler = (message) {\n" |
7216 " receivePort.close();\n" | 7231 " receivePort.close();\n" |
7217 " throw new Exception(message);\n" | 7232 " throw new Exception(message);\n" |
7218 " };\n" | 7233 " };\n" |
7219 "}\n"; | 7234 "}\n"; |
7220 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); | 7235 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
7221 Dart_EnterScope(); | 7236 Dart_EnterScope(); |
7222 | 7237 |
7223 // Create a port w/ a current isolate, to make sure that works too. | 7238 // Create a port w/ a current isolate, to make sure that works too. |
| 7239 intptr_t peer2 = 0xDEADBEEF; |
7224 Dart_Port port_id2 = | 7240 Dart_Port port_id2 = |
7225 Dart_NewNativePort("Port321", NewNativePort_send321, true); | 7241 Dart_NewNativePort("Port321", NewNativePort_send321, true, &peer2); |
7226 | 7242 |
7227 Dart_Handle send_port1 = Dart_NewSendPort(port_id1); | 7243 Dart_Handle send_port1 = Dart_NewSendPort(port_id1); |
7228 EXPECT_VALID(send_port1); | 7244 EXPECT_VALID(send_port1); |
7229 Dart_Handle send_port2 = Dart_NewSendPort(port_id2); | 7245 Dart_Handle send_port2 = Dart_NewSendPort(port_id2); |
7230 EXPECT_VALID(send_port2); | 7246 EXPECT_VALID(send_port2); |
7231 | 7247 |
7232 // Test first port. | 7248 // Test first port. |
7233 Dart_Handle dart_args[1]; | 7249 Dart_Handle dart_args[1]; |
7234 dart_args[0] = send_port1; | 7250 dart_args[0] = send_port1; |
7235 Dart_Handle result = Dart_Invoke(lib, NewString("callPort"), 1, dart_args); | 7251 Dart_Handle result = Dart_Invoke(lib, NewString("callPort"), 1, dart_args); |
7236 EXPECT_VALID(result); | 7252 EXPECT_VALID(result); |
7237 result = Dart_RunLoop(); | 7253 result = Dart_RunLoop(); |
7238 EXPECT(Dart_IsError(result)); | 7254 EXPECT(Dart_IsError(result)); |
7239 EXPECT(Dart_ErrorHasException(result)); | 7255 EXPECT(Dart_ErrorHasException(result)); |
7240 EXPECT_SUBSTRING("Exception: 123\n", Dart_GetError(result)); | 7256 EXPECT_SUBSTRING("Exception: 123\n", Dart_GetError(result)); |
| 7257 EXPECT_EQ(123, peer1); |
7241 | 7258 |
7242 // result second port. | 7259 // result second port. |
7243 dart_args[0] = send_port2; | 7260 dart_args[0] = send_port2; |
7244 result = Dart_Invoke(lib, NewString("callPort"), 1, dart_args); | 7261 result = Dart_Invoke(lib, NewString("callPort"), 1, dart_args); |
7245 EXPECT_VALID(result); | 7262 EXPECT_VALID(result); |
7246 result = Dart_RunLoop(); | 7263 result = Dart_RunLoop(); |
7247 EXPECT(Dart_IsError(result)); | 7264 EXPECT(Dart_IsError(result)); |
7248 EXPECT(Dart_ErrorHasException(result)); | 7265 EXPECT(Dart_ErrorHasException(result)); |
7249 EXPECT_SUBSTRING("Exception: 321\n", Dart_GetError(result)); | 7266 EXPECT_SUBSTRING("Exception: 321\n", Dart_GetError(result)); |
| 7267 EXPECT_EQ(321, peer2); |
7250 | 7268 |
7251 Dart_ExitScope(); | 7269 Dart_ExitScope(); |
7252 | 7270 |
7253 // Delete the native ports. | 7271 // Delete the native ports. |
7254 EXPECT(Dart_CloseNativePort(port_id1)); | 7272 EXPECT(Dart_CloseNativePort(port_id1)); |
7255 EXPECT(Dart_CloseNativePort(port_id2)); | 7273 EXPECT(Dart_CloseNativePort(port_id2)); |
7256 } | 7274 } |
7257 | 7275 |
7258 | 7276 |
7259 void NewNativePort_sendInteger123(Dart_Port dest_port_id, | 7277 void NewNativePort_sendInteger123(Dart_Port dest_port_id, |
7260 Dart_CObject* message) { | 7278 Dart_CObject* message, |
| 7279 void* peer) { |
7261 // Gets a send port message. | 7280 // Gets a send port message. |
7262 EXPECT_NOTNULL(message); | 7281 EXPECT_NOTNULL(message); |
7263 EXPECT_EQ(Dart_CObject_kArray, message->type); | 7282 EXPECT_EQ(Dart_CObject_kArray, message->type); |
7264 EXPECT_EQ(Dart_CObject_kSendPort, message->value.as_array.values[0]->type); | 7283 EXPECT_EQ(Dart_CObject_kSendPort, message->value.as_array.values[0]->type); |
7265 | 7284 |
7266 // Post integer value. | 7285 // Post integer value. |
7267 Dart_PostInteger(message->value.as_array.values[0]->value.as_send_port.id, | 7286 Dart_PostInteger(message->value.as_array.values[0]->value.as_send_port.id, |
7268 123); | 7287 123); |
7269 } | 7288 } |
7270 | 7289 |
7271 | 7290 |
7272 void NewNativePort_sendInteger321(Dart_Port dest_port_id, | 7291 void NewNativePort_sendInteger321(Dart_Port dest_port_id, |
7273 Dart_CObject* message) { | 7292 Dart_CObject* message, |
| 7293 void* peer) { |
7274 // Gets a null message. | 7294 // Gets a null message. |
7275 EXPECT_NOTNULL(message); | 7295 EXPECT_NOTNULL(message); |
7276 EXPECT_EQ(Dart_CObject_kArray, message->type); | 7296 EXPECT_EQ(Dart_CObject_kArray, message->type); |
7277 EXPECT_EQ(Dart_CObject_kSendPort, message->value.as_array.values[0]->type); | 7297 EXPECT_EQ(Dart_CObject_kSendPort, message->value.as_array.values[0]->type); |
7278 | 7298 |
7279 // Post integer value. | 7299 // Post integer value. |
7280 Dart_PostInteger(message->value.as_array.values[0]->value.as_send_port.id, | 7300 Dart_PostInteger(message->value.as_array.values[0]->value.as_send_port.id, |
7281 321); | 7301 321); |
7282 } | 7302 } |
7283 | 7303 |
7284 | 7304 |
7285 TEST_CASE(NativePortPostInteger) { | 7305 TEST_CASE(NativePortPostInteger) { |
7286 const char* kScriptChars = | 7306 const char* kScriptChars = |
7287 "import 'dart:isolate';\n" | 7307 "import 'dart:isolate';\n" |
7288 "void callPort(SendPort port) {\n" | 7308 "void callPort(SendPort port) {\n" |
7289 " var receivePort = new RawReceivePort();\n" | 7309 " var receivePort = new RawReceivePort();\n" |
7290 " var replyPort = receivePort.sendPort;\n" | 7310 " var replyPort = receivePort.sendPort;\n" |
7291 " port.send([replyPort]);\n" | 7311 " port.send([replyPort]);\n" |
7292 " receivePort.handler = (message) {\n" | 7312 " receivePort.handler = (message) {\n" |
7293 " receivePort.close();\n" | 7313 " receivePort.close();\n" |
7294 " throw new Exception(message);\n" | 7314 " throw new Exception(message);\n" |
7295 " };\n" | 7315 " };\n" |
7296 "}\n"; | 7316 "}\n"; |
7297 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); | 7317 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
7298 Dart_EnterScope(); | 7318 Dart_EnterScope(); |
7299 | 7319 |
7300 Dart_Port port_id1 = | 7320 Dart_Port port_id1 = |
7301 Dart_NewNativePort("Port123", NewNativePort_sendInteger123, true); | 7321 Dart_NewNativePort("Port123", NewNativePort_sendInteger123, true, NULL); |
7302 Dart_Port port_id2 = | 7322 Dart_Port port_id2 = |
7303 Dart_NewNativePort("Port321", NewNativePort_sendInteger321, true); | 7323 Dart_NewNativePort("Port321", NewNativePort_sendInteger321, true, NULL); |
7304 | 7324 |
7305 Dart_Handle send_port1 = Dart_NewSendPort(port_id1); | 7325 Dart_Handle send_port1 = Dart_NewSendPort(port_id1); |
7306 EXPECT_VALID(send_port1); | 7326 EXPECT_VALID(send_port1); |
7307 Dart_Handle send_port2 = Dart_NewSendPort(port_id2); | 7327 Dart_Handle send_port2 = Dart_NewSendPort(port_id2); |
7308 EXPECT_VALID(send_port2); | 7328 EXPECT_VALID(send_port2); |
7309 | 7329 |
7310 // Test first port. | 7330 // Test first port. |
7311 Dart_Handle dart_args[1]; | 7331 Dart_Handle dart_args[1]; |
7312 dart_args[0] = send_port1; | 7332 dart_args[0] = send_port1; |
7313 Dart_Handle result = Dart_Invoke(lib, NewString("callPort"), 1, dart_args); | 7333 Dart_Handle result = Dart_Invoke(lib, NewString("callPort"), 1, dart_args); |
(...skipping 14 matching lines...) Expand all Loading... |
7328 | 7348 |
7329 Dart_ExitScope(); | 7349 Dart_ExitScope(); |
7330 | 7350 |
7331 // Delete the native ports. | 7351 // Delete the native ports. |
7332 EXPECT(Dart_CloseNativePort(port_id1)); | 7352 EXPECT(Dart_CloseNativePort(port_id1)); |
7333 EXPECT(Dart_CloseNativePort(port_id2)); | 7353 EXPECT(Dart_CloseNativePort(port_id2)); |
7334 } | 7354 } |
7335 | 7355 |
7336 | 7356 |
7337 void NewNativePort_nativeReceiveNull(Dart_Port dest_port_id, | 7357 void NewNativePort_nativeReceiveNull(Dart_Port dest_port_id, |
7338 Dart_CObject* message) { | 7358 Dart_CObject* message, |
| 7359 void* peer) { |
7339 EXPECT_NOTNULL(message); | 7360 EXPECT_NOTNULL(message); |
7340 | 7361 |
7341 if ((message->type == Dart_CObject_kArray) && | 7362 if ((message->type == Dart_CObject_kArray) && |
7342 (message->value.as_array.values[0]->type == Dart_CObject_kSendPort)) { | 7363 (message->value.as_array.values[0]->type == Dart_CObject_kSendPort)) { |
7343 // Post integer value. | 7364 // Post integer value. |
7344 Dart_PostInteger(message->value.as_array.values[0]->value.as_send_port.id, | 7365 Dart_PostInteger(message->value.as_array.values[0]->value.as_send_port.id, |
7345 123); | 7366 123); |
7346 } else { | 7367 } else { |
7347 EXPECT_EQ(message->type, Dart_CObject_kNull); | 7368 EXPECT_EQ(message->type, Dart_CObject_kNull); |
7348 } | 7369 } |
7349 } | 7370 } |
7350 | 7371 |
7351 | 7372 |
7352 TEST_CASE(NativePortReceiveNull) { | 7373 TEST_CASE(NativePortReceiveNull) { |
7353 const char* kScriptChars = | 7374 const char* kScriptChars = |
7354 "import 'dart:isolate';\n" | 7375 "import 'dart:isolate';\n" |
7355 "void callPort(SendPort port) {\n" | 7376 "void callPort(SendPort port) {\n" |
7356 " var receivePort = new RawReceivePort();\n" | 7377 " var receivePort = new RawReceivePort();\n" |
7357 " var replyPort = receivePort.sendPort;\n" | 7378 " var replyPort = receivePort.sendPort;\n" |
7358 " port.send(null);\n" | 7379 " port.send(null);\n" |
7359 " port.send([replyPort]);\n" | 7380 " port.send([replyPort]);\n" |
7360 " receivePort.handler = (message) {\n" | 7381 " receivePort.handler = (message) {\n" |
7361 " receivePort.close();\n" | 7382 " receivePort.close();\n" |
7362 " throw new Exception(message);\n" | 7383 " throw new Exception(message);\n" |
7363 " };\n" | 7384 " };\n" |
7364 "}\n"; | 7385 "}\n"; |
7365 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); | 7386 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
7366 Dart_EnterScope(); | 7387 Dart_EnterScope(); |
7367 | 7388 |
7368 Dart_Port port_id1 = | 7389 Dart_Port port_id1 = Dart_NewNativePort( |
7369 Dart_NewNativePort("PortNull", NewNativePort_nativeReceiveNull, true); | 7390 "PortNull", NewNativePort_nativeReceiveNull, true, NULL); |
7370 Dart_Handle send_port1 = Dart_NewSendPort(port_id1); | 7391 Dart_Handle send_port1 = Dart_NewSendPort(port_id1); |
7371 EXPECT_VALID(send_port1); | 7392 EXPECT_VALID(send_port1); |
7372 | 7393 |
7373 // Test first port. | 7394 // Test first port. |
7374 Dart_Handle dart_args[1]; | 7395 Dart_Handle dart_args[1]; |
7375 dart_args[0] = send_port1; | 7396 dart_args[0] = send_port1; |
7376 Dart_Handle result = Dart_Invoke(lib, NewString("callPort"), 1, dart_args); | 7397 Dart_Handle result = Dart_Invoke(lib, NewString("callPort"), 1, dart_args); |
7377 EXPECT_VALID(result); | 7398 EXPECT_VALID(result); |
7378 result = Dart_RunLoop(); | 7399 result = Dart_RunLoop(); |
7379 EXPECT(Dart_IsError(result)); | 7400 EXPECT(Dart_IsError(result)); |
7380 EXPECT(Dart_ErrorHasException(result)); | 7401 EXPECT(Dart_ErrorHasException(result)); |
7381 EXPECT_SUBSTRING("Exception: 123\n", Dart_GetError(result)); | 7402 EXPECT_SUBSTRING("Exception: 123\n", Dart_GetError(result)); |
7382 | 7403 |
7383 Dart_ExitScope(); | 7404 Dart_ExitScope(); |
7384 | 7405 |
7385 // Delete the native ports. | 7406 // Delete the native ports. |
7386 EXPECT(Dart_CloseNativePort(port_id1)); | 7407 EXPECT(Dart_CloseNativePort(port_id1)); |
7387 } | 7408 } |
7388 | 7409 |
7389 | 7410 |
7390 void NewNativePort_nativeReceiveInteger(Dart_Port dest_port_id, | 7411 void NewNativePort_nativeReceiveInteger(Dart_Port dest_port_id, |
7391 Dart_CObject* message) { | 7412 Dart_CObject* message, |
| 7413 void* peer) { |
7392 EXPECT_NOTNULL(message); | 7414 EXPECT_NOTNULL(message); |
7393 | 7415 |
7394 if ((message->type == Dart_CObject_kArray) && | 7416 if ((message->type == Dart_CObject_kArray) && |
7395 (message->value.as_array.values[0]->type == Dart_CObject_kSendPort)) { | 7417 (message->value.as_array.values[0]->type == Dart_CObject_kSendPort)) { |
7396 // Post integer value. | 7418 // Post integer value. |
7397 Dart_PostInteger(message->value.as_array.values[0]->value.as_send_port.id, | 7419 Dart_PostInteger(message->value.as_array.values[0]->value.as_send_port.id, |
7398 123); | 7420 123); |
7399 } else { | 7421 } else { |
7400 EXPECT_EQ(message->type, Dart_CObject_kInt32); | 7422 EXPECT_EQ(message->type, Dart_CObject_kInt32); |
7401 EXPECT_EQ(message->value.as_int32, 321); | 7423 EXPECT_EQ(message->value.as_int32, 321); |
(...skipping 10 matching lines...) Expand all Loading... |
7412 " port.send(321);\n" | 7434 " port.send(321);\n" |
7413 " port.send([replyPort]);\n" | 7435 " port.send([replyPort]);\n" |
7414 " receivePort.handler = (message) {\n" | 7436 " receivePort.handler = (message) {\n" |
7415 " receivePort.close();\n" | 7437 " receivePort.close();\n" |
7416 " throw new Exception(message);\n" | 7438 " throw new Exception(message);\n" |
7417 " };\n" | 7439 " };\n" |
7418 "}\n"; | 7440 "}\n"; |
7419 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); | 7441 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
7420 Dart_EnterScope(); | 7442 Dart_EnterScope(); |
7421 | 7443 |
7422 Dart_Port port_id1 = | 7444 Dart_Port port_id1 = Dart_NewNativePort( |
7423 Dart_NewNativePort("PortNull", NewNativePort_nativeReceiveInteger, true); | 7445 "PortNull", NewNativePort_nativeReceiveInteger, true, NULL); |
7424 Dart_Handle send_port1 = Dart_NewSendPort(port_id1); | 7446 Dart_Handle send_port1 = Dart_NewSendPort(port_id1); |
7425 EXPECT_VALID(send_port1); | 7447 EXPECT_VALID(send_port1); |
7426 | 7448 |
7427 // Test first port. | 7449 // Test first port. |
7428 Dart_Handle dart_args[1]; | 7450 Dart_Handle dart_args[1]; |
7429 dart_args[0] = send_port1; | 7451 dart_args[0] = send_port1; |
7430 Dart_Handle result = Dart_Invoke(lib, NewString("callPort"), 1, dart_args); | 7452 Dart_Handle result = Dart_Invoke(lib, NewString("callPort"), 1, dart_args); |
7431 EXPECT_VALID(result); | 7453 EXPECT_VALID(result); |
7432 result = Dart_RunLoop(); | 7454 result = Dart_RunLoop(); |
7433 EXPECT(Dart_IsError(result)); | 7455 EXPECT(Dart_IsError(result)); |
(...skipping 2480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9914 EXPECT_VALID(result); | 9936 EXPECT_VALID(result); |
9915 result = Dart_FinalizeLoading(false); | 9937 result = Dart_FinalizeLoading(false); |
9916 EXPECT_VALID(result); | 9938 EXPECT_VALID(result); |
9917 result = Dart_Invoke(lib, NewString("foozoo"), 0, NULL); | 9939 result = Dart_Invoke(lib, NewString("foozoo"), 0, NULL); |
9918 EXPECT(Dart_IsError(result)); | 9940 EXPECT(Dart_IsError(result)); |
9919 } | 9941 } |
9920 | 9942 |
9921 #endif // !PRODUCT | 9943 #endif // !PRODUCT |
9922 | 9944 |
9923 } // namespace dart | 9945 } // namespace dart |
OLD | NEW |