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

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

Issue 9422019: isolates refactor: this change introduces 'dart:isolate' as a library. This is a (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/dart_api_impl.cc ('k') | runtime/vm/dart_entry.cc » ('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 3407 matching lines...) Expand 10 before | Expand all | Expand 10 after
3418 // Create a port with a bogus handler. 3418 // Create a port with a bogus handler.
3419 Dart_Port error_port = Dart_NewNativePort("Foo", NULL, true); 3419 Dart_Port error_port = Dart_NewNativePort("Foo", NULL, true);
3420 EXPECT_EQ(kIllegalPort, error_port); 3420 EXPECT_EQ(kIllegalPort, error_port);
3421 3421
3422 // Create the port w/o a current isolate, just to make sure that works. 3422 // Create the port w/o a current isolate, just to make sure that works.
3423 Dart_Port port_id1 = 3423 Dart_Port port_id1 =
3424 Dart_NewNativePort("Port123", NewNativePort_send123, true); 3424 Dart_NewNativePort("Port123", NewNativePort_send123, true);
3425 3425
3426 TestIsolateScope __test_isolate__; 3426 TestIsolateScope __test_isolate__;
3427 const char* kScriptChars = 3427 const char* kScriptChars =
3428 "#import('dart:isolate');\n"
3428 "void callPort(SendPort port) {\n" 3429 "void callPort(SendPort port) {\n"
3429 " port.call(null).receive((message, replyTo) {\n" 3430 " port.call(null).receive((message, replyTo) {\n"
3430 " throw new Exception(message);\n" 3431 " throw new Exception(message);\n"
3431 " });\n" 3432 " });\n"
3432 "}\n"; 3433 "}\n";
3433 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); 3434 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
3434 Dart_EnterScope(); 3435 Dart_EnterScope();
3435 3436
3436 // Create a port w/ a current isolate, to make sure that works too. 3437 // Create a port w/ a current isolate, to make sure that works too.
3437 Dart_Port port_id2 = 3438 Dart_Port port_id2 =
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
3474 // Delete the native ports. 3475 // Delete the native ports.
3475 EXPECT(Dart_CloseNativePort(port_id1)); 3476 EXPECT(Dart_CloseNativePort(port_id1));
3476 EXPECT(Dart_CloseNativePort(port_id2)); 3477 EXPECT(Dart_CloseNativePort(port_id2));
3477 } 3478 }
3478 3479
3479 3480
3480 static bool RunLoopTestCallback(const char* name_prefix, 3481 static bool RunLoopTestCallback(const char* name_prefix,
3481 void* data, char** error) { 3482 void* data, char** error) {
3482 const char* kScriptChars = 3483 const char* kScriptChars =
3483 "#import('builtin');\n" 3484 "#import('builtin');\n"
3485 "#import('dart:isolate');\n"
3484 "class MyIsolate extends Isolate {\n" 3486 "class MyIsolate extends Isolate {\n"
3485 " MyIsolate() : super() { }\n" 3487 " MyIsolate() : super() { }\n"
3486 " void main() {\n" 3488 " void main() {\n"
3487 " port.receive((message, replyTo) {\n" 3489 " port.receive((message, replyTo) {\n"
3488 " if (message) {\n" 3490 " if (message) {\n"
3489 " throw new Exception('MakeChildExit');\n" 3491 " throw new Exception('MakeChildExit');\n"
3490 " } else {\n" 3492 " } else {\n"
3491 " replyTo.call('hello');\n" 3493 " replyTo.call('hello');\n"
3492 " port.close();\n" 3494 " port.close();\n"
3493 " }\n" 3495 " }\n"
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
3733 // We should have received the expected number of interrupts. 3735 // We should have received the expected number of interrupts.
3734 EXPECT_EQ(kInterruptCount, interrupt_count); 3736 EXPECT_EQ(kInterruptCount, interrupt_count);
3735 3737
3736 // Give the spawned thread enough time to properly exit. 3738 // Give the spawned thread enough time to properly exit.
3737 Isolate::SetInterruptCallback(saved); 3739 Isolate::SetInterruptCallback(saved);
3738 } 3740 }
3739 3741
3740 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). 3742 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
3741 3743
3742 } // namespace dart 3744 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/dart_entry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698