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

Unified Diff: pkg/analyzer/test/generated/all_the_rest_test.dart

Issue 2242883003: Fix resolveRelativeUri() to handle correctly empty contained Uri(s). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/generated/utilities_dart.dart ('k') | pkg/analyzer/test/src/summary/linker_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/generated/all_the_rest_test.dart
diff --git a/pkg/analyzer/test/generated/all_the_rest_test.dart b/pkg/analyzer/test/generated/all_the_rest_test.dart
index 63fdd854befdd57270075e8583cf841e8a7fd6b8..2af8f66863a6b326314c5944e2a42a05d2b32894 100644
--- a/pkg/analyzer/test/generated/all_the_rest_test.dart
+++ b/pkg/analyzer/test/generated/all_the_rest_test.dart
@@ -4402,68 +4402,53 @@ class FileBasedSourceTest {
@reflectiveTest
class ResolveRelativeUriTest {
void test_resolveRelative_dart_dartUri() {
- Uri uri = parseUriWithException('dart:foo');
- Uri relative = resolveRelativeUri(uri, parseUriWithException('dart:bar'));
- expect(relative, isNotNull);
- expect(relative.toString(), 'dart:bar');
+ _assertResolve('dart:foo', 'dart:bar', 'dart:bar');
}
void test_resolveRelative_dart_fileName() {
- Uri uri = parseUriWithException("dart:test");
- Uri relative = resolveRelativeUri(uri, parseUriWithException("lib.dart"));
- expect(relative, isNotNull);
- expect(relative.toString(), "dart:test/lib.dart");
+ _assertResolve('dart:test', 'lib.dart', 'dart:test/lib.dart');
}
void test_resolveRelative_dart_filePath() {
- Uri uri = parseUriWithException("dart:test");
- Uri relative = resolveRelativeUri(uri, parseUriWithException("c/lib.dart"));
- expect(relative, isNotNull);
- expect(relative.toString(), "dart:test/c/lib.dart");
+ _assertResolve('dart:test', 'c/lib.dart', 'dart:test/c/lib.dart');
}
void test_resolveRelative_dart_filePathWithParent() {
- Uri uri = parseUriWithException("dart:test/b/test.dart");
- Uri relative =
- resolveRelativeUri(uri, parseUriWithException("../c/lib.dart"));
- expect(relative, isNotNull);
- expect(relative.toString(), "dart:test/c/lib.dart");
+ _assertResolve(
+ 'dart:test/b/test.dart', '../c/lib.dart', 'dart:test/c/lib.dart');
}
void test_resolveRelative_package_dartUri() {
- Uri uri = parseUriWithException('package:foo/bar.dart');
- Uri relative = resolveRelativeUri(uri, parseUriWithException('dart:test'));
- expect(relative, isNotNull);
- expect(relative.toString(), 'dart:test');
+ _assertResolve('package:foo/bar.dart', 'dart:test', 'dart:test');
+ }
+
+ void test_resolveRelative_package_emptyPath() {
+ _assertResolve('package:foo/bar.dart', '', 'package:foo/bar.dart');
}
void test_resolveRelative_package_fileName() {
- Uri uri = parseUriWithException("package:b/test.dart");
- Uri relative = resolveRelativeUri(uri, parseUriWithException("lib.dart"));
- expect(relative, isNotNull);
- expect(relative.toString(), "package:b/lib.dart");
+ _assertResolve('package:b/test.dart', 'lib.dart', 'package:b/lib.dart');
}
void test_resolveRelative_package_fileNameWithoutPackageName() {
- Uri uri = parseUriWithException("package:test.dart");
- Uri relative = resolveRelativeUri(uri, parseUriWithException("lib.dart"));
- expect(relative, isNotNull);
- expect(relative.toString(), "package:lib.dart");
+ _assertResolve('package:test.dart', 'lib.dart', 'package:lib.dart');
}
void test_resolveRelative_package_filePath() {
- Uri uri = parseUriWithException("package:b/test.dart");
- Uri relative = resolveRelativeUri(uri, parseUriWithException("c/lib.dart"));
- expect(relative, isNotNull);
- expect(relative.toString(), "package:b/c/lib.dart");
+ _assertResolve('package:b/test.dart', 'c/lib.dart', 'package:b/c/lib.dart');
}
void test_resolveRelative_package_filePathWithParent() {
- Uri uri = parseUriWithException("package:a/b/test.dart");
- Uri relative =
- resolveRelativeUri(uri, parseUriWithException("../c/lib.dart"));
- expect(relative, isNotNull);
- expect(relative.toString(), "package:a/c/lib.dart");
+ _assertResolve(
+ 'package:a/b/test.dart', '../c/lib.dart', 'package:a/c/lib.dart');
+ }
+
+ void _assertResolve(String baseStr, String containedStr, String expectedStr) {
+ Uri base = Uri.parse(baseStr);
Paul Berry 2016/08/12 17:51:18 I'm curious what the motivation was for using Uri.
scheglov 2016/08/12 17:58:06 To allow parsing empty Uri.
+ Uri contained = Uri.parse(containedStr);
+ Uri result = resolveRelativeUri(base, contained);
+ expect(result, isNotNull);
+ expect(result.toString(), expectedStr);
}
}
« no previous file with comments | « pkg/analyzer/lib/src/generated/utilities_dart.dart ('k') | pkg/analyzer/test/src/summary/linker_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698