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

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
« no previous file with comments | « runtime/vm/unit_test.h ('k') | tests/isolate/isolate.status » ('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 <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 23 matching lines...) Expand all
86 } else if (DartUtils::IsDartCryptoLibURL(url_chars)) { 85 } else if (DartUtils::IsDartCryptoLibURL(url_chars)) {
87 return Builtin::LoadLibrary(Builtin::kCryptoLibrary); 86 return Builtin::LoadLibrary(Builtin::kCryptoLibrary);
88 } else { 87 } else {
89 return Dart_Error("Do not know how to load '%s'", url_chars); 88 return Dart_Error("Do not know how to load '%s'", url_chars);
90 } 89 }
91 } 90 }
92 result = DartUtils::LoadSource(NULL, 91 result = DartUtils::LoadSource(NULL,
93 library, 92 library,
94 url, 93 url,
95 tag, 94 tag,
96 url_chars, 95 url_chars);
97 import_map);
98 if (!Dart_IsError(result) && (tag == kImportTag)) { 96 if (!Dart_IsError(result) && (tag == kImportTag)) {
99 Builtin::ImportLibrary(result, Builtin::kBuiltinLibrary); 97 Builtin::ImportLibrary(result, Builtin::kBuiltinLibrary);
100 } 98 }
101 return result; 99 return result;
102 } 100 }
103 101
104 102
105 Dart_Handle TestCase::LoadTestScript(const char* script, 103 Dart_Handle TestCase::LoadTestScript(const char* script,
106 Dart_NativeEntryResolver resolver, 104 Dart_NativeEntryResolver resolver,
107 Dart_Handle import_map) { 105 Dart_Handle import_map) {
108 Dart_Handle url = Dart_NewString(TestCase::url()); 106 Dart_Handle url = Dart_NewString(TestCase::url());
109 Dart_Handle source = Dart_NewString(script); 107 Dart_Handle source = Dart_NewString(script);
110 Dart_Handle result = Dart_SetLibraryTagHandler(LibraryTagHandler); 108 Dart_Handle result = Dart_SetLibraryTagHandler(LibraryTagHandler);
111 EXPECT_VALID(result); 109 EXPECT_VALID(result);
112 Dart_Handle lib = Dart_LoadScript(url, source, import_map); 110 result = Dart_SetImportMap(import_map);
111 EXPECT_VALID(result);
112 Dart_Handle lib = Dart_LoadScript(url, source);
113 DART_CHECK_VALID(lib); 113 DART_CHECK_VALID(lib);
114 result = Dart_SetNativeResolver(lib, resolver); 114 result = Dart_SetNativeResolver(lib, resolver);
115 DART_CHECK_VALID(result); 115 DART_CHECK_VALID(result);
116 return lib; 116 return lib;
117 } 117 }
118 118
119 119
120 Dart_Handle TestCase::lib() { 120 Dart_Handle TestCase::lib() {
121 Dart_Handle url = Dart_NewString(TestCase::url()); 121 Dart_Handle url = Dart_NewString(TestCase::url());
122 Dart_Handle lib = Dart_LookupLibrary(url); 122 Dart_Handle lib = Dart_LookupLibrary(url);
123 DART_CHECK_VALID(lib); 123 DART_CHECK_VALID(lib);
124 ASSERT(Dart_IsLibrary(lib)); 124 ASSERT(Dart_IsLibrary(lib));
125 return lib; 125 return lib;
126 } 126 }
127 127
128 128
129 Dart_Handle TestCase::library_handler(Dart_LibraryTag tag, 129 Dart_Handle TestCase::library_handler(Dart_LibraryTag tag,
130 Dart_Handle library, 130 Dart_Handle library,
131 Dart_Handle url, 131 Dart_Handle url) {
132 Dart_Handle import_map) {
133 if (tag == kCanonicalizeUrl) { 132 if (tag == kCanonicalizeUrl) {
134 return url; 133 return url;
135 } 134 }
136 return Api::Success(Isolate::Current()); 135 return Api::Success(Isolate::Current());
137 } 136 }
138 137
139 138
140 uword AssemblerTest::Assemble() { 139 uword AssemblerTest::Assemble() {
141 const String& function_name = String::ZoneHandle(String::NewSymbol(name_)); 140 const String& function_name = String::ZoneHandle(String::NewSymbol(name_));
142 Function& function = Function::ZoneHandle( 141 Function& function = Function::ZoneHandle(
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 216
218 bool CompilerTest::TestCompileFunction(const Function& function) { 217 bool CompilerTest::TestCompileFunction(const Function& function) {
219 Isolate* isolate = Isolate::Current(); 218 Isolate* isolate = Isolate::Current();
220 ASSERT(isolate != NULL); 219 ASSERT(isolate != NULL);
221 ASSERT(ClassFinalizer::AllClassesFinalized()); 220 ASSERT(ClassFinalizer::AllClassesFinalized());
222 const Error& error = Error::Handle(Compiler::CompileFunction(function)); 221 const Error& error = Error::Handle(Compiler::CompileFunction(function));
223 return error.IsNull(); 222 return error.IsNull();
224 } 223 }
225 224
226 } // namespace dart 225 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/unit_test.h ('k') | tests/isolate/isolate.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698