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