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

Side by Side Diff: pkg/analyzer/test/src/source/source_resource_test.dart

Issue 2321263003: Remove parseUriWithException() and URISyntaxException. (Closed)
Patch Set: Created 4 years, 3 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
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 library analyzer.test.src.source.source_resource_test; 5 library analyzer.test.src.source.source_resource_test;
6 6
7 import 'package:analyzer/file_system/file_system.dart'; 7 import 'package:analyzer/file_system/file_system.dart';
8 import 'package:analyzer/file_system/memory_file_system.dart'; 8 import 'package:analyzer/file_system/memory_file_system.dart';
9 import 'package:analyzer/file_system/physical_file_system.dart'; 9 import 'package:analyzer/file_system/physical_file_system.dart';
10 import 'package:analyzer/src/generated/java_core.dart';
11 import 'package:analyzer/src/generated/java_engine_io.dart'; 10 import 'package:analyzer/src/generated/java_engine_io.dart';
12 import 'package:analyzer/src/generated/sdk.dart'; 11 import 'package:analyzer/src/generated/sdk.dart';
13 import 'package:analyzer/src/generated/source.dart'; 12 import 'package:analyzer/src/generated/source.dart';
14 import 'package:analyzer/src/generated/utilities_dart.dart'; 13 import 'package:analyzer/src/generated/utilities_dart.dart';
15 import 'package:analyzer/src/source/source_resource.dart'; 14 import 'package:analyzer/src/source/source_resource.dart';
16 import 'package:test_reflective_loader/test_reflective_loader.dart'; 15 import 'package:test_reflective_loader/test_reflective_loader.dart';
17 import 'package:unittest/unittest.dart'; 16 import 'package:unittest/unittest.dart';
18 17
19 import '../../utils.dart'; 18 import '../../utils.dart';
20 import '../context/mock_sdk.dart'; 19 import '../context/mock_sdk.dart';
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 FileSource source1 = new FileSource(file1); 118 FileSource source1 = new FileSource(file1);
120 FileSource source2 = new FileSource(file2); 119 FileSource source2 = new FileSource(file2);
121 expect(source2.hashCode, source1.hashCode); 120 expect(source2.hashCode, source1.hashCode);
122 } 121 }
123 122
124 void test_isInSystemLibrary_contagious() { 123 void test_isInSystemLibrary_contagious() {
125 DartSdk sdk = _createSdk(); 124 DartSdk sdk = _createSdk();
126 UriResolver resolver = new DartUriResolver(sdk); 125 UriResolver resolver = new DartUriResolver(sdk);
127 SourceFactory factory = new SourceFactory([resolver]); 126 SourceFactory factory = new SourceFactory([resolver]);
128 // resolve dart:core 127 // resolve dart:core
129 Source result = 128 Source result = resolver.resolveAbsolute(Uri.parse("dart:async"));
130 resolver.resolveAbsolute(parseUriWithException("dart:async"));
131 expect(result, isNotNull); 129 expect(result, isNotNull);
132 expect(result.isInSystemLibrary, isTrue); 130 expect(result.isInSystemLibrary, isTrue);
133 // system libraries reference only other system libraries 131 // system libraries reference only other system libraries
134 Source partSource = factory.resolveUri(result, "stream.dart"); 132 Source partSource = factory.resolveUri(result, "stream.dart");
135 expect(partSource, isNotNull); 133 expect(partSource, isNotNull);
136 expect(partSource.isInSystemLibrary, isTrue); 134 expect(partSource.isInSystemLibrary, isTrue);
137 } 135 }
138 136
139 void test_isInSystemLibrary_false() { 137 void test_isInSystemLibrary_false() {
140 File file = resourceProvider.getFile("/does/not/exist.dart"); 138 File file = resourceProvider.getFile("/does/not/exist.dart");
(...skipping 14 matching lines...) Expand all
155 void test_resolveRelative_file_fileName() { 153 void test_resolveRelative_file_fileName() {
156 if (OSUtilities.isWindows()) { 154 if (OSUtilities.isWindows()) {
157 // On Windows, the URI that is produced includes a drive letter, 155 // On Windows, the URI that is produced includes a drive letter,
158 // which I believe is not consistent across all machines that might run 156 // which I believe is not consistent across all machines that might run
159 // this test. 157 // this test.
160 return; 158 return;
161 } 159 }
162 File file = resourceProvider.getFile("/a/b/test.dart"); 160 File file = resourceProvider.getFile("/a/b/test.dart");
163 FileSource source = new FileSource(file); 161 FileSource source = new FileSource(file);
164 expect(source, isNotNull); 162 expect(source, isNotNull);
165 Uri relative = 163 Uri relative = resolveRelativeUri(source.uri, Uri.parse("lib.dart"));
166 resolveRelativeUri(source.uri, parseUriWithException("lib.dart"));
167 expect(relative, isNotNull); 164 expect(relative, isNotNull);
168 expect(relative.toString(), "file:///a/b/lib.dart"); 165 expect(relative.toString(), "file:///a/b/lib.dart");
169 } 166 }
170 167
171 void test_resolveRelative_file_filePath() { 168 void test_resolveRelative_file_filePath() {
172 if (OSUtilities.isWindows()) { 169 if (OSUtilities.isWindows()) {
173 // On Windows, the URI that is produced includes a drive letter, 170 // On Windows, the URI that is produced includes a drive letter,
174 // which I believe is not consistent across all machines that might run 171 // which I believe is not consistent across all machines that might run
175 // this test. 172 // this test.
176 return; 173 return;
177 } 174 }
178 File file = resourceProvider.getFile("/a/b/test.dart"); 175 File file = resourceProvider.getFile("/a/b/test.dart");
179 FileSource source = new FileSource(file); 176 FileSource source = new FileSource(file);
180 expect(source, isNotNull); 177 expect(source, isNotNull);
181 Uri relative = 178 Uri relative = resolveRelativeUri(source.uri, Uri.parse("c/lib.dart"));
182 resolveRelativeUri(source.uri, parseUriWithException("c/lib.dart"));
183 expect(relative, isNotNull); 179 expect(relative, isNotNull);
184 expect(relative.toString(), "file:///a/b/c/lib.dart"); 180 expect(relative.toString(), "file:///a/b/c/lib.dart");
185 } 181 }
186 182
187 void test_resolveRelative_file_filePathWithParent() { 183 void test_resolveRelative_file_filePathWithParent() {
188 if (OSUtilities.isWindows()) { 184 if (OSUtilities.isWindows()) {
189 // On Windows, the URI that is produced includes a drive letter, which I 185 // On Windows, the URI that is produced includes a drive letter, which I
190 // believe is not consistent across all machines that might run this test. 186 // believe is not consistent across all machines that might run this test.
191 return; 187 return;
192 } 188 }
193 File file = resourceProvider.getFile("/a/b/test.dart"); 189 File file = resourceProvider.getFile("/a/b/test.dart");
194 FileSource source = new FileSource(file); 190 FileSource source = new FileSource(file);
195 expect(source, isNotNull); 191 expect(source, isNotNull);
196 Uri relative = 192 Uri relative = resolveRelativeUri(source.uri, Uri.parse("../c/lib.dart"));
197 resolveRelativeUri(source.uri, parseUriWithException("../c/lib.dart"));
198 expect(relative, isNotNull); 193 expect(relative, isNotNull);
199 expect(relative.toString(), "file:///a/c/lib.dart"); 194 expect(relative.toString(), "file:///a/c/lib.dart");
200 } 195 }
201 196
202 void test_system() { 197 void test_system() {
203 File file = resourceProvider.getFile("/does/not/exist.dart"); 198 File file = resourceProvider.getFile("/does/not/exist.dart");
204 FileSource source = 199 FileSource source = new FileSource(file, Uri.parse("dart:core"));
205 new FileSource(file, parseUriWithException("dart:core"));
206 expect(source, isNotNull); 200 expect(source, isNotNull);
207 expect(source.fullName, file.path); 201 expect(source.fullName, file.path);
208 expect(source.isInSystemLibrary, isTrue); 202 expect(source.isInSystemLibrary, isTrue);
209 } 203 }
210 204
211 DartSdk _createSdk() { 205 DartSdk _createSdk() {
212 return new MockSdk(resourceProvider: resourceProvider); 206 return new MockSdk(resourceProvider: resourceProvider);
213 } 207 }
214 } 208 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698