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

Side by Side Diff: vm/unit_test.cc

Issue 9359009: Implement support for specifying string interopolation style variable substitution in the import ... (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: '' Created 8 years, 10 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 | « vm/unit_test.h ('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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/ast_printer.h" 10 #include "vm/ast_printer.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) {
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");
62 } 63 }
63 static const char* kDartScheme = "dart:"; 64 static const char* kDartScheme = "dart:";
64 static const intptr_t kDartSchemeLen = strlen(kDartScheme); 65 static const intptr_t kDartSchemeLen = strlen(kDartScheme);
65 // If the URL starts with "dart:" then it is not modified as it will be 66 // If the URL starts with "dart:" then it is not modified as it will be
66 // handled by the VM internally. 67 // handled by the VM internally.
67 if (strncmp(url_chars, kDartScheme, kDartSchemeLen) == 0) { 68 if (strncmp(url_chars, kDartScheme, kDartSchemeLen) == 0) {
68 if (tag == kCanonicalizeUrl) { 69 if (tag == kCanonicalizeUrl) {
69 return url; 70 return url;
70 } 71 }
71 return Dart_Error("unexpected tag encountered %d", tag); 72 return Dart_Error("unexpected tag encountered %d", tag);
72 } 73 }
73 return Dart_Error("unsupported url encountered %s", url_chars); 74 return Dart_Error("unsupported url encountered %s", url_chars);
74 } 75 }
75 76
76 77
77 Dart_Handle TestCase::LoadTestScript(const char* script, 78 Dart_Handle TestCase::LoadTestScript(const char* script,
78 Dart_NativeEntryResolver resolver) { 79 Dart_NativeEntryResolver resolver) {
79 Dart_Handle url = Dart_NewString(TestCase::url()); 80 Dart_Handle url = Dart_NewString(TestCase::url());
80 Dart_Handle source = Dart_NewString(script); 81 Dart_Handle source = Dart_NewString(script);
81 Dart_Handle lib = Dart_LoadScript(url, source, LibraryTagHandler); 82 Dart_Handle import_map = Dart_NewList(0);
83 Dart_Handle lib = Dart_LoadScript(url, source, LibraryTagHandler, import_map);
82 DART_CHECK_VALID(lib); 84 DART_CHECK_VALID(lib);
83 Dart_Handle result = Dart_SetNativeResolver(lib, resolver); 85 Dart_Handle result = Dart_SetNativeResolver(lib, resolver);
84 DART_CHECK_VALID(result); 86 DART_CHECK_VALID(result);
85 return lib; 87 return lib;
86 } 88 }
87 89
88 90
89 Dart_Handle TestCase::lib() { 91 Dart_Handle TestCase::lib() {
90 Dart_Handle url = Dart_NewString(TestCase::url()); 92 Dart_Handle url = Dart_NewString(TestCase::url());
91 Dart_Handle lib = Dart_LookupLibrary(url); 93 Dart_Handle lib = Dart_LookupLibrary(url);
92 DART_CHECK_VALID(lib); 94 DART_CHECK_VALID(lib);
93 ASSERT(Dart_IsLibrary(lib)); 95 ASSERT(Dart_IsLibrary(lib));
94 return lib; 96 return lib;
95 } 97 }
96 98
97 99
98 Dart_Handle TestCase::library_handler(Dart_LibraryTag tag, 100 Dart_Handle TestCase::library_handler(Dart_LibraryTag tag,
99 Dart_Handle library, 101 Dart_Handle library,
100 Dart_Handle url) { 102 Dart_Handle url,
103 Dart_Handle import_map) {
101 if (tag == kCanonicalizeUrl) { 104 if (tag == kCanonicalizeUrl) {
102 return url; 105 return url;
103 } 106 }
104 return Api::Success(); 107 return Api::Success();
105 } 108 }
106 109
107 110
108 uword AssemblerTest::Assemble() { 111 uword AssemblerTest::Assemble() {
109 const Code& code = Code::Handle(Code::FinalizeCode(name_, assembler_)); 112 const Code& code = Code::Handle(Code::FinalizeCode(name_, assembler_));
110 if (FLAG_disassemble) { 113 if (FLAG_disassemble) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 195
193 196
194 bool CompilerTest::TestCompileFunction(const Function& function) { 197 bool CompilerTest::TestCompileFunction(const Function& function) {
195 Isolate* isolate = Isolate::Current(); 198 Isolate* isolate = Isolate::Current();
196 ASSERT(isolate != NULL); 199 ASSERT(isolate != NULL);
197 const Error& error = Error::Handle(Compiler::CompileFunction(function)); 200 const Error& error = Error::Handle(Compiler::CompileFunction(function));
198 return error.IsNull(); 201 return error.IsNull();
199 } 202 }
200 203
201 } // namespace dart 204 } // namespace dart
OLDNEW
« no previous file with comments | « vm/unit_test.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698