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

Unified Diff: vm/unit_test.cc

Issue 8537023: Implement automatic loading of dart:core_native_fields library (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: '' Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « vm/parser.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vm/unit_test.cc
===================================================================
--- vm/unit_test.cc (revision 1624)
+++ vm/unit_test.cc (working copy)
@@ -48,11 +48,39 @@
}
+static Dart_Handle LibraryTagHandler(Dart_LibraryTag tag,
+ Dart_Handle library,
+ Dart_Handle url) {
+ if (!Dart_IsLibrary(library)) {
+ return Dart_Error("not a library");
+ }
+ if (!Dart_IsString8(url)) {
+ return Dart_Error("url is not a string");
+ }
+ const char* url_chars = NULL;
+ Dart_Handle result = Dart_StringToCString(url, &url_chars);
+ if (Dart_IsError(result)) {
+ return Dart_Error("accessing url characters failed");
+ }
+ static const char* kDartScheme = "dart:";
+ static const intptr_t kDartSchemeLen = strlen(kDartScheme);
+ // If the URL starts with "dart:" then it is not modified as it will be
+ // handled by the VM internally.
+ if (strncmp(url_chars, kDartScheme, kDartSchemeLen) == 0) {
+ if (tag == kCanonicalizeUrl) {
+ return url;
+ }
+ return Dart_Error("unexpected tag encountered %d", tag);
+ }
+ return Dart_Error("unsupported url encountered %s", url_chars);
+}
+
+
Dart_Handle TestCase::LoadTestScript(const char* script,
Dart_NativeEntryResolver resolver) {
Dart_Handle url = Dart_NewString(TestCase::url());
Dart_Handle source = Dart_NewString(script);
- Dart_Handle lib = Dart_LoadScript(url, source, NULL);
+ Dart_Handle lib = Dart_LoadScript(url, source, LibraryTagHandler);
ASSERT(!Dart_IsError(lib));
Dart_Handle result = Dart_SetNativeResolver(lib, resolver);
ASSERT(!Dart_IsError(result));
« no previous file with comments | « vm/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698