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

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

Issue 27694005: Fix issue 13942 - Dart_Error function invokes OS::VSNPrint with the "format" string containing data… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 2 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') | no next file » | 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 test->RunTest(); 46 test->RunTest();
47 test = test->next_; 47 test = test->next_;
48 } 48 }
49 } 49 }
50 50
51 51
52 static Dart_Handle LibraryTagHandler(Dart_LibraryTag tag, 52 static Dart_Handle LibraryTagHandler(Dart_LibraryTag tag,
53 Dart_Handle library, 53 Dart_Handle library,
54 Dart_Handle url) { 54 Dart_Handle url) {
55 if (!Dart_IsLibrary(library)) { 55 if (!Dart_IsLibrary(library)) {
56 return Dart_Error("not a library"); 56 return Dart_NewApiError("not a library");
57 } 57 }
58 if (!Dart_IsString(url)) { 58 if (!Dart_IsString(url)) {
59 return Dart_Error("url is not a string"); 59 return Dart_NewApiError("url is not a string");
60 } 60 }
61 const char* url_chars = NULL; 61 const char* url_chars = NULL;
62 Dart_Handle result = Dart_StringToCString(url, &url_chars); 62 Dart_Handle result = Dart_StringToCString(url, &url_chars);
63 if (Dart_IsError(result)) { 63 if (Dart_IsError(result)) {
64 return Dart_Error("accessing url characters failed"); 64 return Dart_NewApiError("accessing url characters failed");
65 } 65 }
66 Dart_Handle library_url = Dart_LibraryUrl(library); 66 Dart_Handle library_url = Dart_LibraryUrl(library);
67 const char* library_url_string = NULL; 67 const char* library_url_string = NULL;
68 result = Dart_StringToCString(library_url, &library_url_string); 68 result = Dart_StringToCString(library_url, &library_url_string);
69 if (Dart_IsError(result)) { 69 if (Dart_IsError(result)) {
70 return result; 70 return result;
71 } 71 }
72 72
73 bool is_dart_scheme_url = DartUtils::IsDartSchemeURL(url_chars); 73 bool is_dart_scheme_url = DartUtils::IsDartSchemeURL(url_chars);
74 bool is_io_library = DartUtils::IsDartIOLibURL(library_url_string); 74 bool is_io_library = DartUtils::IsDartIOLibURL(library_url_string);
75 if (tag == Dart_kCanonicalizeUrl) { 75 if (tag == Dart_kCanonicalizeUrl) {
76 // If this is a Dart Scheme URL then it is not modified as it will be 76 // If this is a Dart Scheme URL then it is not modified as it will be
77 // handled by the VM internally. 77 // handled by the VM internally.
78 if (is_dart_scheme_url || is_io_library) { 78 if (is_dart_scheme_url || is_io_library) {
79 return url; 79 return url;
80 } 80 }
81 Dart_Handle builtin_lib = 81 Dart_Handle builtin_lib =
82 Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary); 82 Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary);
83 DART_CHECK_VALID(builtin_lib); 83 DART_CHECK_VALID(builtin_lib);
84 return DartUtils::CanonicalizeURL(NULL, library, url_chars); 84 return DartUtils::CanonicalizeURL(NULL, library, url_chars);
85 } 85 }
86 if (is_dart_scheme_url) { 86 if (is_dart_scheme_url) {
87 ASSERT(tag == Dart_kImportTag); 87 ASSERT(tag == Dart_kImportTag);
88 // Handle imports of other built-in libraries present in the SDK. 88 // Handle imports of other built-in libraries present in the SDK.
89 if (DartUtils::IsDartIOLibURL(url_chars)) { 89 if (DartUtils::IsDartIOLibURL(url_chars)) {
90 return Builtin::LoadAndCheckLibrary(Builtin::kIOLibrary); 90 return Builtin::LoadAndCheckLibrary(Builtin::kIOLibrary);
91 } else if (DartUtils::IsDartBuiltinLibURL(url_chars)) { 91 } else if (DartUtils::IsDartBuiltinLibURL(url_chars)) {
92 return Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary); 92 return Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary);
93 } else { 93 } else {
94 return Dart_Error("Do not know how to load '%s'", url_chars); 94 return DartUtils::NewError("Do not know how to load '%s'", url_chars);
95 } 95 }
96 } 96 }
97 if (is_io_library) { 97 if (is_io_library) {
98 ASSERT(tag == Dart_kSourceTag); 98 ASSERT(tag == Dart_kSourceTag);
99 return Dart_LoadSource(library, 99 return Dart_LoadSource(library,
100 url, 100 url,
101 Builtin::PartSource(Builtin::kIOLibrary, 101 Builtin::PartSource(Builtin::kIOLibrary,
102 url_chars)); 102 url_chars));
103 } 103 }
104 return DartUtils::LoadSource(NULL, 104 return DartUtils::LoadSource(NULL,
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 225
226 bool CompilerTest::TestCompileFunction(const Function& function) { 226 bool CompilerTest::TestCompileFunction(const Function& function) {
227 Isolate* isolate = Isolate::Current(); 227 Isolate* isolate = Isolate::Current();
228 ASSERT(isolate != NULL); 228 ASSERT(isolate != NULL);
229 ASSERT(ClassFinalizer::AllClassesFinalized()); 229 ASSERT(ClassFinalizer::AllClassesFinalized());
230 const Error& error = Error::Handle(Compiler::CompileFunction(function)); 230 const Error& error = Error::Handle(Compiler::CompileFunction(function));
231 return error.IsNull(); 231 return error.IsNull();
232 } 232 }
233 233
234 } // namespace dart 234 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698