Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: runtime/vm/dart_api_impl_test.cc

Issue 9652001: SendPort + ReceivePort changes: (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/custom_isolate_test.cc ('k') | runtime/vm/snapshot_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/utils.h" 7 #include "platform/utils.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/dart_api_state.h" 10 #include "vm/dart_api_state.h"
(...skipping 4182 matching lines...) Expand 10 before | Expand all | Expand 10 after
4193 EXPECT_EQ(kIllegalPort, error_port); 4193 EXPECT_EQ(kIllegalPort, error_port);
4194 4194
4195 // Create the port w/o a current isolate, just to make sure that works. 4195 // Create the port w/o a current isolate, just to make sure that works.
4196 Dart_Port port_id1 = 4196 Dart_Port port_id1 =
4197 Dart_NewNativePort("Port123", NewNativePort_send123, true); 4197 Dart_NewNativePort("Port123", NewNativePort_send123, true);
4198 4198
4199 TestIsolateScope __test_isolate__; 4199 TestIsolateScope __test_isolate__;
4200 const char* kScriptChars = 4200 const char* kScriptChars =
4201 "#import('dart:isolate');\n" 4201 "#import('dart:isolate');\n"
4202 "void callPort(SendPort port) {\n" 4202 "void callPort(SendPort port) {\n"
4203 " port.call(null).receive((message, replyTo) {\n" 4203 " port.call(null).then((message) {\n"
4204 " throw new Exception(message);\n" 4204 " throw new Exception(message);\n"
4205 " });\n" 4205 " });\n"
4206 "}\n"; 4206 "}\n";
4207 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); 4207 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
4208 Dart_EnterScope(); 4208 Dart_EnterScope();
4209 4209
4210 // Create a port w/ a current isolate, to make sure that works too. 4210 // Create a port w/ a current isolate, to make sure that works too.
4211 Dart_Port port_id2 = 4211 Dart_Port port_id2 =
4212 Dart_NewNativePort("Port321", NewNativePort_send321, true); 4212 Dart_NewNativePort("Port321", NewNativePort_send321, true);
4213 4213
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
4265 " } else {\n" 4265 " } else {\n"
4266 " replyTo.call('hello');\n" 4266 " replyTo.call('hello');\n"
4267 " port.close();\n" 4267 " port.close();\n"
4268 " }\n" 4268 " }\n"
4269 " });\n" 4269 " });\n"
4270 " }\n" 4270 " }\n"
4271 "}\n" 4271 "}\n"
4272 "\n" 4272 "\n"
4273 "void main(exc_child, exc_parent) {\n" 4273 "void main(exc_child, exc_parent) {\n"
4274 " new MyIsolate().spawn().then((port) {\n" 4274 " new MyIsolate().spawn().then((port) {\n"
4275 " port.call(exc_child).receive((message, replyTo) {\n" 4275 " port.call(exc_child).then((message) {\n"
4276 " if (message != 'hello') throw new Exception('ShouldNotHappen');\n" 4276 " if (message != 'hello') throw new Exception('ShouldNotHappen');\n"
4277 " if (exc_parent) throw new Exception('MakeParentExit');\n" 4277 " if (exc_parent) throw new Exception('MakeParentExit');\n"
4278 " });\n" 4278 " });\n"
4279 " });\n" 4279 " });\n"
4280 "}\n"; 4280 "}\n";
4281 4281
4282 if (Dart_CurrentIsolate() != NULL) { 4282 if (Dart_CurrentIsolate() != NULL) {
4283 Dart_ExitIsolate(); 4283 Dart_ExitIsolate();
4284 } 4284 }
4285 Dart_Isolate isolate = TestCase::CreateTestIsolate(); 4285 Dart_Isolate isolate = TestCase::CreateTestIsolate();
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
4502 // We should have received the expected number of interrupts. 4502 // We should have received the expected number of interrupts.
4503 EXPECT_EQ(kInterruptCount, interrupt_count); 4503 EXPECT_EQ(kInterruptCount, interrupt_count);
4504 4504
4505 // Give the spawned thread enough time to properly exit. 4505 // Give the spawned thread enough time to properly exit.
4506 Isolate::SetInterruptCallback(saved); 4506 Isolate::SetInterruptCallback(saved);
4507 } 4507 }
4508 4508
4509 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). 4509 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
4510 4510
4511 } // namespace dart 4511 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/custom_isolate_test.cc ('k') | runtime/vm/snapshot_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698