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

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

Issue 10386107: Implement spawnUri from dart:isolate. This function allows us to (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 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) 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 <stdio.h> 5 #include <stdio.h>
6 6
7 #include "vm/unit_test.h" 7 #include "vm/unit_test.h"
8 8
9 #include "bin/builtin.h" 9 #include "bin/builtin.h"
10 #include "bin/dartutils.h" 10 #include "bin/dartutils.h"
(...skipping 30 matching lines...) Expand all
41 TestCaseBase* test = first_; 41 TestCaseBase* test = first_;
42 while (test != NULL) { 42 while (test != NULL) {
43 test->RunTest(); 43 test->RunTest();
44 test = test->next_; 44 test = test->next_;
45 } 45 }
46 } 46 }
47 47
48 48
49 static Dart_Handle LibraryTagHandler(Dart_LibraryTag tag, 49 static Dart_Handle LibraryTagHandler(Dart_LibraryTag tag,
50 Dart_Handle library, 50 Dart_Handle library,
51 Dart_Handle url, 51 Dart_Handle url) {
52 Dart_Handle import_map) {
53 if (!Dart_IsLibrary(library)) { 52 if (!Dart_IsLibrary(library)) {
54 return Dart_Error("not a library"); 53 return Dart_Error("not a library");
55 } 54 }
56 if (!Dart_IsString8(url)) { 55 if (!Dart_IsString8(url)) {
57 return Dart_Error("url is not a string"); 56 return Dart_Error("url is not a string");
58 } 57 }
59 const char* url_chars = NULL; 58 const char* url_chars = NULL;
60 Dart_Handle result = Dart_StringToCString(url, &url_chars); 59 Dart_Handle result = Dart_StringToCString(url, &url_chars);
61 if (Dart_IsError(result)) { 60 if (Dart_IsError(result)) {
62 return Dart_Error("accessing url characters failed"); 61 return Dart_Error("accessing url characters failed");
(...skipping 21 matching lines...) Expand all
84 } else if (DartUtils::IsDartUtfLibURL(url_chars)) { 83 } else if (DartUtils::IsDartUtfLibURL(url_chars)) {
85 return Builtin::LoadLibrary(Builtin::kUtfLibrary); 84 return Builtin::LoadLibrary(Builtin::kUtfLibrary);
86 } else { 85 } else {
87 return Dart_Error("Do not know how to load '%s'", url_chars); 86 return Dart_Error("Do not know how to load '%s'", url_chars);
88 } 87 }
89 } 88 }
90 result = DartUtils::LoadSource(NULL, 89 result = DartUtils::LoadSource(NULL,
91 library, 90 library,
92 url, 91 url,
93 tag, 92 tag,
94 url_chars, 93 url_chars);
95 import_map);
96 if (!Dart_IsError(result) && (tag == kImportTag)) { 94 if (!Dart_IsError(result) && (tag == kImportTag)) {
97 Builtin::ImportLibrary(result, Builtin::kBuiltinLibrary); 95 Builtin::ImportLibrary(result, Builtin::kBuiltinLibrary);
98 } 96 }
99 return result; 97 return result;
100 } 98 }
101 99
102 100
103 Dart_Handle TestCase::LoadTestScript(const char* script, 101 Dart_Handle TestCase::LoadTestScript(const char* script,
104 Dart_NativeEntryResolver resolver, 102 Dart_NativeEntryResolver resolver,
105 Dart_Handle import_map) { 103 Dart_Handle import_map) {
106 Dart_Handle url = Dart_NewString(TestCase::url()); 104 Dart_Handle url = Dart_NewString(TestCase::url());
107 Dart_Handle source = Dart_NewString(script); 105 Dart_Handle source = Dart_NewString(script);
108 Dart_Handle result = Dart_SetLibraryTagHandler(LibraryTagHandler); 106 Dart_Handle result = Dart_SetLibraryTagHandler(LibraryTagHandler);
109 EXPECT_VALID(result); 107 EXPECT_VALID(result);
110 Dart_Handle lib = Dart_LoadScript(url, source, import_map); 108 result = Dart_SetImportMap(import_map);
109 EXPECT_VALID(result);
110 Dart_Handle lib = Dart_LoadScript(url, source);
111 DART_CHECK_VALID(lib); 111 DART_CHECK_VALID(lib);
112 result = Dart_SetNativeResolver(lib, resolver); 112 result = Dart_SetNativeResolver(lib, resolver);
113 DART_CHECK_VALID(result); 113 DART_CHECK_VALID(result);
114 return lib; 114 return lib;
115 } 115 }
116 116
117 117
118 Dart_Handle TestCase::lib() { 118 Dart_Handle TestCase::lib() {
119 Dart_Handle url = Dart_NewString(TestCase::url()); 119 Dart_Handle url = Dart_NewString(TestCase::url());
120 Dart_Handle lib = Dart_LookupLibrary(url); 120 Dart_Handle lib = Dart_LookupLibrary(url);
121 DART_CHECK_VALID(lib); 121 DART_CHECK_VALID(lib);
122 ASSERT(Dart_IsLibrary(lib)); 122 ASSERT(Dart_IsLibrary(lib));
123 return lib; 123 return lib;
124 } 124 }
125 125
126 126
127 Dart_Handle TestCase::library_handler(Dart_LibraryTag tag, 127 Dart_Handle TestCase::library_handler(Dart_LibraryTag tag,
128 Dart_Handle library, 128 Dart_Handle library,
129 Dart_Handle url, 129 Dart_Handle url) {
130 Dart_Handle import_map) {
131 if (tag == kCanonicalizeUrl) { 130 if (tag == kCanonicalizeUrl) {
132 return url; 131 return url;
133 } 132 }
134 return Api::Success(Isolate::Current()); 133 return Api::Success(Isolate::Current());
135 } 134 }
136 135
137 136
138 uword AssemblerTest::Assemble() { 137 uword AssemblerTest::Assemble() {
139 const String& function_name = String::ZoneHandle(String::NewSymbol(name_)); 138 const String& function_name = String::ZoneHandle(String::NewSymbol(name_));
140 Function& function = Function::ZoneHandle( 139 Function& function = Function::ZoneHandle(
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 201
203 bool CompilerTest::TestCompileFunction(const Function& function) { 202 bool CompilerTest::TestCompileFunction(const Function& function) {
204 Isolate* isolate = Isolate::Current(); 203 Isolate* isolate = Isolate::Current();
205 ASSERT(isolate != NULL); 204 ASSERT(isolate != NULL);
206 ASSERT(ClassFinalizer::AllClassesFinalized()); 205 ASSERT(ClassFinalizer::AllClassesFinalized());
207 const Error& error = Error::Handle(Compiler::CompileFunction(function)); 206 const Error& error = Error::Handle(Compiler::CompileFunction(function));
208 return error.IsNull(); 207 return error.IsNull();
209 } 208 }
210 209
211 } // namespace dart 210 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698