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

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

Issue 10837070: Remove old isolate API and update all code in the repository to use (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. Created 8 years, 4 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_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 "platform/assert.h" 5 #include "platform/assert.h"
6 #include "vm/globals.h" 6 #include "vm/globals.h"
7 #include "vm/isolate.h" 7 #include "vm/isolate.h"
8 #include "vm/unit_test.h" 8 #include "vm/unit_test.h"
9 9
10 namespace dart { 10 namespace dart {
11 11
12 UNIT_TEST_CASE(IsolateCurrent) { 12 UNIT_TEST_CASE(IsolateCurrent) {
13 Isolate* isolate = Isolate::Init(NULL); 13 Isolate* isolate = Isolate::Init(NULL);
14 EXPECT_EQ(isolate, Isolate::Current()); 14 EXPECT_EQ(isolate, Isolate::Current());
15 isolate->Shutdown(); 15 isolate->Shutdown();
16 EXPECT_EQ(reinterpret_cast<Isolate*>(NULL), Isolate::Current()); 16 EXPECT_EQ(reinterpret_cast<Isolate*>(NULL), Isolate::Current());
17 delete isolate; 17 delete isolate;
18 } 18 }
19 19
20
21 // Only ia32 and x64 can run dart execution tests. 20 // Only ia32 and x64 can run dart execution tests.
22 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) 21 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64)
23 // Unit test case to verify error during isolate spawning (application classes 22 // Test to ensure that an exception is thrown if no isolate creation
24 // not loaded into the isolate). 23 // callback has been set by the embedder when an isolate is spawned.
25 TEST_CASE(IsolateSpawn) { 24 TEST_CASE(IsolateSpawn) {
26 const char* kScriptChars = 25 const char* kScriptChars =
27 "#import('dart:isolate');\n" 26 "#import('dart:isolate');\n"
28 "class SpawnNewIsolate extends Isolate {\n" 27 "void entry() {}\n"
29 " SpawnNewIsolate() : super() { }\n"
30 " void main() {\n"
31 " }\n"
32 "}\n"
33 "int testMain() {\n" 28 "int testMain() {\n"
34 " try {\n" 29 " try {\n"
35 " new SpawnNewIsolate().spawn().then(function(SendPort port) {\n" 30 " spawnFunction(entry);\n"
36 " });\n"
37 " } catch (var e) {\n" 31 " } catch (var e) {\n"
38 " throw;\n" 32 " throw;\n"
39 " }\n" 33 " }\n"
40 " return 0;\n" 34 " return 0;\n"
41 "}\n"; 35 "}\n";
42 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); 36 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
43 Dart_Handle result = Dart_Invoke(lib, Dart_NewString("testMain"), 0, NULL); 37 Dart_Handle result = Dart_Invoke(lib, Dart_NewString("testMain"), 0, NULL);
44 EXPECT(Dart_IsError(result)); 38 EXPECT_ERROR(result, "Null callback specified for isolate creation");
45 EXPECT(Dart_ErrorHasException(result)); 39 EXPECT(Dart_ErrorHasException(result));
46 Dart_Handle exception_result = Dart_ErrorGetException(result); 40 Dart_Handle exception_result = Dart_ErrorGetException(result);
47 EXPECT_VALID(exception_result); 41 EXPECT_VALID(exception_result);
48 } 42 }
49 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). 43 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
50 44
51 } // namespace dart 45 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl_test.cc ('k') | runtime/vm/snapshot_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698