OLD | NEW |
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 Loading... |
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) { |
52 if (!Dart_IsLibrary(library)) { | 53 if (!Dart_IsLibrary(library)) { |
53 return Dart_Error("not a library"); | 54 return Dart_Error("not a library"); |
54 } | 55 } |
55 if (!Dart_IsString8(url)) { | 56 if (!Dart_IsString8(url)) { |
56 return Dart_Error("url is not a string"); | 57 return Dart_Error("url is not a string"); |
57 } | 58 } |
58 const char* url_chars = NULL; | 59 const char* url_chars = NULL; |
59 Dart_Handle result = Dart_StringToCString(url, &url_chars); | 60 Dart_Handle result = Dart_StringToCString(url, &url_chars); |
60 if (Dart_IsError(result)) { | 61 if (Dart_IsError(result)) { |
61 return Dart_Error("accessing url characters failed"); | 62 return Dart_Error("accessing url characters failed"); |
(...skipping 23 matching lines...) Expand all Loading... |
85 } else if (DartUtils::IsDartCryptoLibURL(url_chars)) { | 86 } else if (DartUtils::IsDartCryptoLibURL(url_chars)) { |
86 return Builtin::LoadLibrary(Builtin::kCryptoLibrary); | 87 return Builtin::LoadLibrary(Builtin::kCryptoLibrary); |
87 } else { | 88 } else { |
88 return Dart_Error("Do not know how to load '%s'", url_chars); | 89 return Dart_Error("Do not know how to load '%s'", url_chars); |
89 } | 90 } |
90 } | 91 } |
91 result = DartUtils::LoadSource(NULL, | 92 result = DartUtils::LoadSource(NULL, |
92 library, | 93 library, |
93 url, | 94 url, |
94 tag, | 95 tag, |
95 url_chars); | 96 url_chars, |
| 97 import_map); |
96 if (!Dart_IsError(result) && (tag == kImportTag)) { | 98 if (!Dart_IsError(result) && (tag == kImportTag)) { |
97 Builtin::ImportLibrary(result, Builtin::kBuiltinLibrary); | 99 Builtin::ImportLibrary(result, Builtin::kBuiltinLibrary); |
98 } | 100 } |
99 return result; | 101 return result; |
100 } | 102 } |
101 | 103 |
102 | 104 |
103 Dart_Handle TestCase::LoadTestScript(const char* script, | 105 Dart_Handle TestCase::LoadTestScript(const char* script, |
104 Dart_NativeEntryResolver resolver, | 106 Dart_NativeEntryResolver resolver, |
105 Dart_Handle import_map) { | 107 Dart_Handle import_map) { |
106 Dart_Handle url = Dart_NewString(TestCase::url()); | 108 Dart_Handle url = Dart_NewString(TestCase::url()); |
107 Dart_Handle source = Dart_NewString(script); | 109 Dart_Handle source = Dart_NewString(script); |
108 Dart_Handle result = Dart_SetLibraryTagHandler(LibraryTagHandler); | 110 Dart_Handle result = Dart_SetLibraryTagHandler(LibraryTagHandler); |
109 EXPECT_VALID(result); | 111 EXPECT_VALID(result); |
110 result = Dart_SetImportMap(import_map); | 112 Dart_Handle lib = Dart_LoadScript(url, source, 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) { |
132 if (tag == kCanonicalizeUrl) { | 133 if (tag == kCanonicalizeUrl) { |
133 return url; | 134 return url; |
134 } | 135 } |
135 return Api::Success(Isolate::Current()); | 136 return Api::Success(Isolate::Current()); |
136 } | 137 } |
137 | 138 |
138 | 139 |
139 uword AssemblerTest::Assemble() { | 140 uword AssemblerTest::Assemble() { |
140 const String& function_name = String::ZoneHandle(String::NewSymbol(name_)); | 141 const String& function_name = String::ZoneHandle(String::NewSymbol(name_)); |
141 Function& function = Function::ZoneHandle( | 142 Function& function = Function::ZoneHandle( |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 | 217 |
217 bool CompilerTest::TestCompileFunction(const Function& function) { | 218 bool CompilerTest::TestCompileFunction(const Function& function) { |
218 Isolate* isolate = Isolate::Current(); | 219 Isolate* isolate = Isolate::Current(); |
219 ASSERT(isolate != NULL); | 220 ASSERT(isolate != NULL); |
220 ASSERT(ClassFinalizer::AllClassesFinalized()); | 221 ASSERT(ClassFinalizer::AllClassesFinalized()); |
221 const Error& error = Error::Handle(Compiler::CompileFunction(function)); | 222 const Error& error = Error::Handle(Compiler::CompileFunction(function)); |
222 return error.IsNull(); | 223 return error.IsNull(); |
223 } | 224 } |
224 | 225 |
225 } // namespace dart | 226 } // namespace dart |
OLD | NEW |