| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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.generated.all_the_rest_test; | 5 library analyzer.test.generated.all_the_rest_test; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/ast/token.dart'; | 8 import 'package:analyzer/dart/ast/token.dart'; |
| 9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
| 10 import 'package:analyzer/dart/element/type.dart'; | 10 import 'package:analyzer/dart/element/type.dart'; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 @reflectiveTest | 113 @reflectiveTest |
| 114 class CustomUriResolverTest { | 114 class CustomUriResolverTest { |
| 115 void test_creation() { | 115 void test_creation() { |
| 116 expect(new CustomUriResolver({}), isNotNull); | 116 expect(new CustomUriResolver({}), isNotNull); |
| 117 } | 117 } |
| 118 | 118 |
| 119 void test_resolve_unknown_uri() { | 119 void test_resolve_unknown_uri() { |
| 120 UriResolver resolver = new CustomUriResolver({ | 120 UriResolver resolver = new CustomUriResolver({ |
| 121 'custom:library': '/path/to/library.dart', | 121 'custom:library': '/path/to/library.dart', |
| 122 }); | 122 }); |
| 123 Source result = | 123 Source result = resolver.resolveAbsolute(Uri.parse("custom:non_library")); |
| 124 resolver.resolveAbsolute(parseUriWithException("custom:non_library")); | |
| 125 expect(result, isNull); | 124 expect(result, isNull); |
| 126 } | 125 } |
| 127 | 126 |
| 128 void test_resolve_uri() { | 127 void test_resolve_uri() { |
| 129 String path = | 128 String path = |
| 130 FileUtilities2.createFile("/path/to/library.dart").getAbsolutePath(); | 129 FileUtilities2.createFile("/path/to/library.dart").getAbsolutePath(); |
| 131 UriResolver resolver = new CustomUriResolver({ | 130 UriResolver resolver = new CustomUriResolver({ |
| 132 'custom:library': path, | 131 'custom:library': path, |
| 133 }); | 132 }); |
| 134 Source result = | 133 Source result = resolver.resolveAbsolute(Uri.parse("custom:library")); |
| 135 resolver.resolveAbsolute(parseUriWithException("custom:library")); | |
| 136 expect(result, isNotNull); | 134 expect(result, isNotNull); |
| 137 expect(result.fullName, path); | 135 expect(result.fullName, path); |
| 138 } | 136 } |
| 139 } | 137 } |
| 140 | 138 |
| 141 @reflectiveTest | 139 @reflectiveTest |
| 142 class DartUriResolverTest { | 140 class DartUriResolverTest { |
| 143 void test_creation() { | 141 void test_creation() { |
| 144 DartSdk sdk = _createSdk(); | 142 DartSdk sdk = _createSdk(); |
| 145 expect(new DartUriResolver(sdk), isNotNull); | 143 expect(new DartUriResolver(sdk), isNotNull); |
| 146 } | 144 } |
| 147 | 145 |
| 148 void test_isDartUri_null_scheme() { | 146 void test_isDartUri_null_scheme() { |
| 149 Uri uri = parseUriWithException("foo.dart"); | 147 Uri uri = Uri.parse("foo.dart"); |
| 150 expect('', uri.scheme); | 148 expect('', uri.scheme); |
| 151 expect(DartUriResolver.isDartUri(uri), isFalse); | 149 expect(DartUriResolver.isDartUri(uri), isFalse); |
| 152 } | 150 } |
| 153 | 151 |
| 154 void test_resolve_dart() { | 152 void test_resolve_dart() { |
| 155 DartSdk sdk = _createSdk(); | 153 DartSdk sdk = _createSdk(); |
| 156 UriResolver resolver = new DartUriResolver(sdk); | 154 UriResolver resolver = new DartUriResolver(sdk); |
| 157 Source result = | 155 Source result = resolver.resolveAbsolute(Uri.parse("dart:core")); |
| 158 resolver.resolveAbsolute(parseUriWithException("dart:core")); | |
| 159 expect(result, isNotNull); | 156 expect(result, isNotNull); |
| 160 } | 157 } |
| 161 | 158 |
| 162 void test_resolve_dart_nonExistingLibrary() { | 159 void test_resolve_dart_nonExistingLibrary() { |
| 163 DartSdk sdk = _createSdk(); | 160 DartSdk sdk = _createSdk(); |
| 164 UriResolver resolver = new DartUriResolver(sdk); | 161 UriResolver resolver = new DartUriResolver(sdk); |
| 165 Source result = resolver.resolveAbsolute(parseUriWithException("dart:cor")); | 162 Source result = resolver.resolveAbsolute(Uri.parse("dart:cor")); |
| 166 expect(result, isNull); | 163 expect(result, isNull); |
| 167 } | 164 } |
| 168 | 165 |
| 169 void test_resolve_nonDart() { | 166 void test_resolve_nonDart() { |
| 170 DartSdk sdk = _createSdk(); | 167 DartSdk sdk = _createSdk(); |
| 171 UriResolver resolver = new DartUriResolver(sdk); | 168 UriResolver resolver = new DartUriResolver(sdk); |
| 172 Source result = resolver | 169 Source result = |
| 173 .resolveAbsolute(parseUriWithException("package:some/file.dart")); | 170 resolver.resolveAbsolute(Uri.parse("package:some/file.dart")); |
| 174 expect(result, isNull); | 171 expect(result, isNull); |
| 175 } | 172 } |
| 176 } | 173 } |
| 177 | 174 |
| 178 @deprecated | 175 @deprecated |
| 179 @reflectiveTest | 176 @reflectiveTest |
| 180 class DirectoryBasedDartSdkTest { | 177 class DirectoryBasedDartSdkTest { |
| 181 void fail_getDocFileFor() { | 178 void fail_getDocFileFor() { |
| 182 DirectoryBasedDartSdk sdk = _createDartSdk(); | 179 DirectoryBasedDartSdk sdk = _createDartSdk(); |
| 183 JavaFile docFile = sdk.getDocFileFor("html"); | 180 JavaFile docFile = sdk.getDocFileFor("html"); |
| (...skipping 4150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4334 FileBasedSource source1 = new FileBasedSource(file1); | 4331 FileBasedSource source1 = new FileBasedSource(file1); |
| 4335 FileBasedSource source2 = new FileBasedSource(file2); | 4332 FileBasedSource source2 = new FileBasedSource(file2); |
| 4336 expect(source2.hashCode, source1.hashCode); | 4333 expect(source2.hashCode, source1.hashCode); |
| 4337 } | 4334 } |
| 4338 | 4335 |
| 4339 void test_isInSystemLibrary_contagious() { | 4336 void test_isInSystemLibrary_contagious() { |
| 4340 DartSdk sdk = _createSdk(); | 4337 DartSdk sdk = _createSdk(); |
| 4341 UriResolver resolver = new DartUriResolver(sdk); | 4338 UriResolver resolver = new DartUriResolver(sdk); |
| 4342 SourceFactory factory = new SourceFactory([resolver]); | 4339 SourceFactory factory = new SourceFactory([resolver]); |
| 4343 // resolve dart:core | 4340 // resolve dart:core |
| 4344 Source result = | 4341 Source result = resolver.resolveAbsolute(Uri.parse("dart:core")); |
| 4345 resolver.resolveAbsolute(parseUriWithException("dart:core")); | |
| 4346 expect(result, isNotNull); | 4342 expect(result, isNotNull); |
| 4347 expect(result.isInSystemLibrary, isTrue); | 4343 expect(result.isInSystemLibrary, isTrue); |
| 4348 // system libraries reference only other system libraries | 4344 // system libraries reference only other system libraries |
| 4349 Source partSource = factory.resolveUri(result, "num.dart"); | 4345 Source partSource = factory.resolveUri(result, "num.dart"); |
| 4350 expect(partSource, isNotNull); | 4346 expect(partSource, isNotNull); |
| 4351 expect(partSource.isInSystemLibrary, isTrue); | 4347 expect(partSource.isInSystemLibrary, isTrue); |
| 4352 } | 4348 } |
| 4353 | 4349 |
| 4354 void test_isInSystemLibrary_false() { | 4350 void test_isInSystemLibrary_false() { |
| 4355 JavaFile file = FileUtilities2.createFile("/does/not/exist.dart"); | 4351 JavaFile file = FileUtilities2.createFile("/does/not/exist.dart"); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 4370 void test_resolveRelative_file_fileName() { | 4366 void test_resolveRelative_file_fileName() { |
| 4371 if (OSUtilities.isWindows()) { | 4367 if (OSUtilities.isWindows()) { |
| 4372 // On Windows, the URI that is produced includes a drive letter, | 4368 // On Windows, the URI that is produced includes a drive letter, |
| 4373 // which I believe is not consistent across all machines that might run | 4369 // which I believe is not consistent across all machines that might run |
| 4374 // this test. | 4370 // this test. |
| 4375 return; | 4371 return; |
| 4376 } | 4372 } |
| 4377 JavaFile file = FileUtilities2.createFile("/a/b/test.dart"); | 4373 JavaFile file = FileUtilities2.createFile("/a/b/test.dart"); |
| 4378 FileBasedSource source = new FileBasedSource(file); | 4374 FileBasedSource source = new FileBasedSource(file); |
| 4379 expect(source, isNotNull); | 4375 expect(source, isNotNull); |
| 4380 Uri relative = | 4376 Uri relative = resolveRelativeUri(source.uri, Uri.parse("lib.dart")); |
| 4381 resolveRelativeUri(source.uri, parseUriWithException("lib.dart")); | |
| 4382 expect(relative, isNotNull); | 4377 expect(relative, isNotNull); |
| 4383 expect(relative.toString(), "file:///a/b/lib.dart"); | 4378 expect(relative.toString(), "file:///a/b/lib.dart"); |
| 4384 } | 4379 } |
| 4385 | 4380 |
| 4386 void test_resolveRelative_file_filePath() { | 4381 void test_resolveRelative_file_filePath() { |
| 4387 if (OSUtilities.isWindows()) { | 4382 if (OSUtilities.isWindows()) { |
| 4388 // On Windows, the URI that is produced includes a drive letter, | 4383 // On Windows, the URI that is produced includes a drive letter, |
| 4389 // which I believe is not consistent across all machines that might run | 4384 // which I believe is not consistent across all machines that might run |
| 4390 // this test. | 4385 // this test. |
| 4391 return; | 4386 return; |
| 4392 } | 4387 } |
| 4393 JavaFile file = FileUtilities2.createFile("/a/b/test.dart"); | 4388 JavaFile file = FileUtilities2.createFile("/a/b/test.dart"); |
| 4394 FileBasedSource source = new FileBasedSource(file); | 4389 FileBasedSource source = new FileBasedSource(file); |
| 4395 expect(source, isNotNull); | 4390 expect(source, isNotNull); |
| 4396 Uri relative = | 4391 Uri relative = resolveRelativeUri(source.uri, Uri.parse("c/lib.dart")); |
| 4397 resolveRelativeUri(source.uri, parseUriWithException("c/lib.dart")); | |
| 4398 expect(relative, isNotNull); | 4392 expect(relative, isNotNull); |
| 4399 expect(relative.toString(), "file:///a/b/c/lib.dart"); | 4393 expect(relative.toString(), "file:///a/b/c/lib.dart"); |
| 4400 } | 4394 } |
| 4401 | 4395 |
| 4402 void test_resolveRelative_file_filePathWithParent() { | 4396 void test_resolveRelative_file_filePathWithParent() { |
| 4403 if (OSUtilities.isWindows()) { | 4397 if (OSUtilities.isWindows()) { |
| 4404 // On Windows, the URI that is produced includes a drive letter, which I | 4398 // On Windows, the URI that is produced includes a drive letter, which I |
| 4405 // believe is not consistent across all machines that might run this test. | 4399 // believe is not consistent across all machines that might run this test. |
| 4406 return; | 4400 return; |
| 4407 } | 4401 } |
| 4408 JavaFile file = FileUtilities2.createFile("/a/b/test.dart"); | 4402 JavaFile file = FileUtilities2.createFile("/a/b/test.dart"); |
| 4409 FileBasedSource source = new FileBasedSource(file); | 4403 FileBasedSource source = new FileBasedSource(file); |
| 4410 expect(source, isNotNull); | 4404 expect(source, isNotNull); |
| 4411 Uri relative = | 4405 Uri relative = resolveRelativeUri(source.uri, Uri.parse("../c/lib.dart")); |
| 4412 resolveRelativeUri(source.uri, parseUriWithException("../c/lib.dart")); | |
| 4413 expect(relative, isNotNull); | 4406 expect(relative, isNotNull); |
| 4414 expect(relative.toString(), "file:///a/c/lib.dart"); | 4407 expect(relative.toString(), "file:///a/c/lib.dart"); |
| 4415 } | 4408 } |
| 4416 | 4409 |
| 4417 void test_system() { | 4410 void test_system() { |
| 4418 JavaFile file = FileUtilities2.createFile("/does/not/exist.dart"); | 4411 JavaFile file = FileUtilities2.createFile("/does/not/exist.dart"); |
| 4419 FileBasedSource source = | 4412 FileBasedSource source = new FileBasedSource(file, Uri.parse("dart:core")); |
| 4420 new FileBasedSource(file, parseUriWithException("dart:core")); | |
| 4421 expect(source, isNotNull); | 4413 expect(source, isNotNull); |
| 4422 expect(source.fullName, file.getAbsolutePath()); | 4414 expect(source.fullName, file.getAbsolutePath()); |
| 4423 expect(source.isInSystemLibrary, isTrue); | 4415 expect(source.isInSystemLibrary, isTrue); |
| 4424 } | 4416 } |
| 4425 } | 4417 } |
| 4426 | 4418 |
| 4427 @reflectiveTest | 4419 @reflectiveTest |
| 4428 class ResolveRelativeUriTest { | 4420 class ResolveRelativeUriTest { |
| 4429 void test_resolveRelative_dart_dartUri() { | 4421 void test_resolveRelative_dart_dartUri() { |
| 4430 _assertResolve('dart:foo', 'dart:bar', 'dart:bar'); | 4422 _assertResolve('dart:foo', 'dart:bar', 'dart:bar'); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4561 expect(UriKind.fromEncoding(0x70), same(UriKind.PACKAGE_URI)); | 4553 expect(UriKind.fromEncoding(0x70), same(UriKind.PACKAGE_URI)); |
| 4562 expect(UriKind.fromEncoding(0x58), same(null)); | 4554 expect(UriKind.fromEncoding(0x58), same(null)); |
| 4563 } | 4555 } |
| 4564 | 4556 |
| 4565 void test_getEncoding() { | 4557 void test_getEncoding() { |
| 4566 expect(UriKind.DART_URI.encoding, 0x64); | 4558 expect(UriKind.DART_URI.encoding, 0x64); |
| 4567 expect(UriKind.FILE_URI.encoding, 0x66); | 4559 expect(UriKind.FILE_URI.encoding, 0x66); |
| 4568 expect(UriKind.PACKAGE_URI.encoding, 0x70); | 4560 expect(UriKind.PACKAGE_URI.encoding, 0x70); |
| 4569 } | 4561 } |
| 4570 } | 4562 } |
| OLD | NEW |