| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library analyzer.test.generated.utilities_dart_test; |
| 6 |
| 7 import 'package:analyzer/src/generated/utilities_dart.dart'; |
| 8 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 9 import 'package:unittest/unittest.dart'; |
| 10 |
| 11 import '../utils.dart'; |
| 12 |
| 13 main() { |
| 14 initializeTestEnvironment(); |
| 15 defineReflectiveTests(ResolveRelativeUriTest); |
| 16 } |
| 17 |
| 18 @reflectiveTest |
| 19 class ResolveRelativeUriTest { |
| 20 void test_absolute() { |
| 21 _validate('dart:core', 'dart:async', 'dart:async'); |
| 22 _validate('package:foo/foo.dart', 'dart:async', 'dart:async'); |
| 23 _validate('package:a/a.dart', 'package:b/b.dart', 'package:b/b.dart'); |
| 24 _validate('foo.dart', 'dart:async', 'dart:async'); |
| 25 } |
| 26 |
| 27 void test_absoluteDart_relative() { |
| 28 _validate('dart:core', 'int.dart', 'dart:core/int.dart'); |
| 29 } |
| 30 |
| 31 void test_absolutePackage_relative() { |
| 32 _validate('package:a/b.dart', 'c.dart', 'package:a/c.dart'); |
| 33 _validate('package:a/b/c.dart', 'd.dart', 'package:a/b/d.dart'); |
| 34 _validate('package:a/b/c.dart', '../d.dart', 'package:a/d.dart'); |
| 35 } |
| 36 |
| 37 void test_relative_relative() { |
| 38 _validate('a/b.dart', 'c.dart', 'a/c.dart'); |
| 39 _validate('a/b.dart', '../c.dart', 'c.dart'); |
| 40 _validate('a.dart', '../b.dart', '../b.dart'); |
| 41 _validate('a.dart', '../../b.dart', '../../b.dart'); |
| 42 // TODO(scheglov) After https://github.com/dart-lang/sdk/issues/27447 |
| 43 // TODO(scheglov) include also this, currently failing test. |
| 44 // _validate('a/b.dart', '../../c.dart', '../c.dart'); |
| 45 } |
| 46 |
| 47 void _validate(String base, String contained, String expected) { |
| 48 Uri actual = resolveRelativeUri(Uri.parse(base), Uri.parse(contained)); |
| 49 expect(actual.toString(), expected); |
| 50 } |
| 51 } |
| OLD | NEW |