import '../lib/import_table.dart';

main() {
  List<String> paths = new List<String>();
  paths.add("file://");
  paths.add("file:///a");
  paths.add("file:///a/b");
  paths.add("file:///a/b/c");

  int end = paths.length;
  for (int i = 0; i < end; i++) {
    paths.add(paths[i] + "/d.dart");
    paths.add(paths[i] + "/e.dart");
    paths.add(paths[i] + "/");
  }
  paths[0] = "file:///";
  paths.sort();
  for (int i = 0; i < paths.length; i++) {
    for (int j = 0; j < paths.length; j++) {
      check(paths[i], paths[j]);
    }
  }
  check("", "");
}

void check(String target, String ref) {
  Uri uriTarget = Uri.parse(target);
  Uri uriRef = Uri.parse(ref);
  String relative = relativeUriPath(uriTarget, uriRef);
  if (Uri.base.resolveUri(uriTarget) !=
      Uri.base.resolveUri(uriRef).resolve(relative)) {
    throw "Failure on '$target' and '$ref': Got '$relative' which resolves to "
        "${uriRef.resolve(relative)}";
  }
}

import 'package:kernel/import_table.dart';

main() {
  List<String> paths = new List<String>();
  paths.add("file://");
  paths.add("file:///a");
  paths.add("file:///a/b");
  paths.add("file:///a/b/c");

  int end = paths.length;
  for (int i = 0; i < end; i++) {
    paths.add(paths[i] + "/d.dart");
    paths.add(paths[i] + "/e.dart");
    paths.add(paths[i] + "/");
  }
  paths[0] = "file:///";
  paths.sort();
  for (int i = 0; i < paths.length; i++) {
    for (int j = 0; j < paths.length; j++) {
      check(paths[i], paths[j]);
    }
  }
  check("", "");
}

void check(String target, String ref) {
  Uri uriTarget = Uri.parse(target);
  Uri uriRef = Uri.parse(ref);
  String relative = relativeUriPath(uriTarget, uriRef);
  if (Uri.base.resolveUri(uriTarget) !=
      Uri.base.resolveUri(uriRef).resolve(relative)) {
    throw "Failure on '$target' and '$ref': Got '$relative' which resolves to "
        "${uriRef.resolve(relative)}";
  }
}

Fix relative import from pkg/kernel/test to pkg/kernel/lib.
Fix relative import from pkg/kernel/test to pkg/kernel/lib.

This doesn't work due to the file organization used in google3.

Change-Id: I814a087bd9c6e10fc7738c782af6f54fde3cf000
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99181
Auto-Submit: Paul Berry <72d414e3a99fb120308437779d51667bcc0984eb@google.com>
Commit-Queue: Jens Johansen <05223a3c6bdf76af6f84755eae231abeebcf4530@google.com>
Reviewed-by: Jens Johansen <05223a3c6bdf76af6f84755eae231abeebcf4530@google.com>
