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

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

Issue 10868043: Move print to corelib. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Make it pass all tests. Created 8 years, 3 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
OLDNEW
1 // Copyright (c) 2011, 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 6
7 #include "vm/unit_test.h" 7 #include "vm/unit_test.h"
8 8
9 // Custom Isolate Test. 9 // Custom Isolate Test.
10 // 10 //
11 // This mid-size test uses the Dart Embedding Api to create a custom 11 // This mid-size test uses the Dart Embedding Api to create a custom
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 virtual void Process(); 160 virtual void Process();
161 private: 161 private:
162 const char* main_; 162 const char* main_;
163 }; 163 };
164 164
165 165
166 void StartEvent::Process() { 166 void StartEvent::Process() {
167 OS::Print(">> StartEvent with isolate(%p)--\n", isolate()); 167 OS::Print(">> StartEvent with isolate(%p)--\n", isolate());
168 Dart_EnterIsolate(isolate()); 168 Dart_EnterIsolate(isolate());
169 Dart_EnterScope(); 169 Dart_EnterScope();
170
170 Dart_Handle result; 171 Dart_Handle result;
171 172
172 // Reload all the test classes here. 173 // Reload all the test classes here.
173 // 174 //
174 // TODO(turnidge): Use the create isolate callback instead? 175 // TODO(turnidge): Use the create isolate callback instead?
175 Dart_Handle lib = TestCase::LoadTestScript(kCustomIsolateScriptChars, 176 Dart_Handle lib = TestCase::LoadTestScript(kCustomIsolateScriptChars,
176 NativeLookup); 177 NativeLookup);
177 EXPECT_VALID(lib); 178 EXPECT_VALID(lib);
178 EXPECT_VALID(Dart_CompileAll()); 179 EXPECT_VALID(Dart_CompileAll());
179 180
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 EXPECT_VALID(Dart_StringToCString(param, &isolate_main)); 276 EXPECT_VALID(Dart_StringToCString(param, &isolate_main));
276 isolate_main = strdup(isolate_main); 277 isolate_main = strdup(isolate_main);
277 278
278 // Save current isolate. 279 // Save current isolate.
279 Dart_Isolate saved_isolate = Dart_CurrentIsolate(); 280 Dart_Isolate saved_isolate = Dart_CurrentIsolate();
280 Dart_ExitIsolate(); 281 Dart_ExitIsolate();
281 282
282 // Create a new Dart_Isolate. 283 // Create a new Dart_Isolate.
283 Dart_Isolate new_isolate = TestCase::CreateTestIsolate(); 284 Dart_Isolate new_isolate = TestCase::CreateTestIsolate();
284 EXPECT(new_isolate != NULL); 285 EXPECT(new_isolate != NULL);
286
287 {
288 // Setup dummy builtin library for 'print'.
289 Dart_EnterScope();
290 const char* builtin_source =
291 "#library('dart:builtin');\n"
292 "void print(Object o) { }";
293 Dart_Handle coreimpl = Dart_LookupLibrary(Dart_NewString("dart:coreimpl"));
294 EXPECT_VALID(coreimpl);
295 Dart_Handle builtin = Dart_LoadLibrary(Dart_NewString("dart:builtin"),
296 Dart_NewString(builtin_source));
297 EXPECT_VALID(builtin);
298 Dart_Handle imported =
299 Dart_LibraryImportLibrary(coreimpl, builtin, Dart_NewString("builtin"));
300 EXPECT_VALID(imported);
301 Dart_ExitScope();
302 }
303
285 Dart_SetMessageNotifyCallback(&NotifyMessage); 304 Dart_SetMessageNotifyCallback(&NotifyMessage);
286 Dart_Port new_port = Dart_GetMainPortId(); 305 Dart_Port new_port = Dart_GetMainPortId();
287 306
288 OS::Print("-- Adding StartEvent to queue --\n"); 307 OS::Print("-- Adding StartEvent to queue --\n");
289 event_queue->Add(new StartEvent(new_isolate, isolate_main)); 308 event_queue->Add(new StartEvent(new_isolate, isolate_main));
290 309
291 // Restore the original isolate. 310 // Restore the original isolate.
292 Dart_ExitIsolate(); 311 Dart_ExitIsolate();
293 Dart_EnterIsolate(saved_isolate); 312 Dart_EnterIsolate(saved_isolate);
294 Dart_EnterScope(); 313 Dart_EnterScope();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 OS::Print("-- Finished event loop --\n"); 356 OS::Print("-- Finished event loop --\n");
338 EXPECT_STREQ("Received: 43", saved_echo); 357 EXPECT_STREQ("Received: 43", saved_echo);
339 free(const_cast<char*>(saved_echo)); 358 free(const_cast<char*>(saved_echo));
340 359
341 delete event_queue; 360 delete event_queue;
342 } 361 }
343 362
344 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). 363 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
345 364
346 } // namespace dart 365 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698