Chromium Code Reviews| 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 4041 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4052 FileBasedSource source = new FileBasedSource( | 4052 FileBasedSource source = new FileBasedSource( |
| 4053 FileUtilities2.createFile("/some/packages/foo:bar.dart")); | 4053 FileUtilities2.createFile("/some/packages/foo:bar.dart")); |
| 4054 expect(source, isNotNull); | 4054 expect(source, isNotNull); |
| 4055 expect(source.exists(), isFalse); | 4055 expect(source.exists(), isFalse); |
| 4056 } | 4056 } |
| 4057 | 4057 |
| 4058 void test_resolveRelative_dart_fileName() { | 4058 void test_resolveRelative_dart_fileName() { |
| 4059 JavaFile file = FileUtilities2.createFile("/a/b/test.dart"); | 4059 JavaFile file = FileUtilities2.createFile("/a/b/test.dart"); |
| 4060 FileBasedSource source = | 4060 FileBasedSource source = |
| 4061 new FileBasedSource(file, parseUriWithException("dart:test")); | 4061 new FileBasedSource(file, parseUriWithException("dart:test")); |
| 4062 expect(source, isNotNull); | 4062 expect(source, isNotNull); |
|
scheglov
2016/03/25 14:02:44
Do we need to use Source here at all?
Maybe we cou
Paul Berry
2016/03/25 17:37:53
Done.
| |
| 4063 Uri relative = source.resolveRelativeUri(parseUriWithException("lib.dart")); | 4063 Uri relative = |
| 4064 resolveRelativeUri(source.uri, parseUriWithException("lib.dart")); | |
|
scheglov
2016/03/25 14:02:44
Maybe this should be moved to a separate test, bec
Paul Berry
2016/03/25 17:37:53
Done.
| |
| 4064 expect(relative, isNotNull); | 4065 expect(relative, isNotNull); |
| 4065 expect(relative.toString(), "dart:test/lib.dart"); | 4066 expect(relative.toString(), "dart:test/lib.dart"); |
| 4066 } | 4067 } |
| 4067 | 4068 |
| 4068 void test_resolveRelative_dart_filePath() { | 4069 void test_resolveRelative_dart_filePath() { |
| 4069 JavaFile file = FileUtilities2.createFile("/a/b/test.dart"); | 4070 JavaFile file = FileUtilities2.createFile("/a/b/test.dart"); |
| 4070 FileBasedSource source = | 4071 FileBasedSource source = |
| 4071 new FileBasedSource(file, parseUriWithException("dart:test")); | 4072 new FileBasedSource(file, parseUriWithException("dart:test")); |
| 4072 expect(source, isNotNull); | 4073 expect(source, isNotNull); |
| 4073 Uri relative = | 4074 Uri relative = |
| 4074 source.resolveRelativeUri(parseUriWithException("c/lib.dart")); | 4075 resolveRelativeUri(source.uri, parseUriWithException("c/lib.dart")); |
| 4075 expect(relative, isNotNull); | 4076 expect(relative, isNotNull); |
| 4076 expect(relative.toString(), "dart:test/c/lib.dart"); | 4077 expect(relative.toString(), "dart:test/c/lib.dart"); |
| 4077 } | 4078 } |
| 4078 | 4079 |
| 4079 void test_resolveRelative_dart_filePathWithParent() { | 4080 void test_resolveRelative_dart_filePathWithParent() { |
| 4080 JavaFile file = FileUtilities2.createFile("/a/b/test.dart"); | 4081 JavaFile file = FileUtilities2.createFile("/a/b/test.dart"); |
| 4081 FileBasedSource source = new FileBasedSource( | 4082 FileBasedSource source = new FileBasedSource( |
| 4082 file, parseUriWithException("dart:test/b/test.dart")); | 4083 file, parseUriWithException("dart:test/b/test.dart")); |
| 4083 expect(source, isNotNull); | 4084 expect(source, isNotNull); |
| 4084 Uri relative = | 4085 Uri relative = |
| 4085 source.resolveRelativeUri(parseUriWithException("../c/lib.dart")); | 4086 resolveRelativeUri(source.uri, parseUriWithException("../c/lib.dart")); |
| 4086 expect(relative, isNotNull); | 4087 expect(relative, isNotNull); |
| 4087 expect(relative.toString(), "dart:test/c/lib.dart"); | 4088 expect(relative.toString(), "dart:test/c/lib.dart"); |
| 4088 } | 4089 } |
| 4089 | 4090 |
| 4090 void test_resolveRelative_file_fileName() { | 4091 void test_resolveRelative_file_fileName() { |
| 4091 if (OSUtilities.isWindows()) { | 4092 if (OSUtilities.isWindows()) { |
| 4092 // On Windows, the URI that is produced includes a drive letter, | 4093 // On Windows, the URI that is produced includes a drive letter, |
| 4093 // which I believe is not consistent across all machines that might run | 4094 // which I believe is not consistent across all machines that might run |
| 4094 // this test. | 4095 // this test. |
| 4095 return; | 4096 return; |
| 4096 } | 4097 } |
| 4097 JavaFile file = FileUtilities2.createFile("/a/b/test.dart"); | 4098 JavaFile file = FileUtilities2.createFile("/a/b/test.dart"); |
| 4098 FileBasedSource source = new FileBasedSource(file); | 4099 FileBasedSource source = new FileBasedSource(file); |
| 4099 expect(source, isNotNull); | 4100 expect(source, isNotNull); |
| 4100 Uri relative = source.resolveRelativeUri(parseUriWithException("lib.dart")); | 4101 Uri relative = |
| 4102 resolveRelativeUri(source.uri, parseUriWithException("lib.dart")); | |
| 4101 expect(relative, isNotNull); | 4103 expect(relative, isNotNull); |
| 4102 expect(relative.toString(), "file:///a/b/lib.dart"); | 4104 expect(relative.toString(), "file:///a/b/lib.dart"); |
| 4103 } | 4105 } |
| 4104 | 4106 |
| 4105 void test_resolveRelative_file_filePath() { | 4107 void test_resolveRelative_file_filePath() { |
| 4106 if (OSUtilities.isWindows()) { | 4108 if (OSUtilities.isWindows()) { |
| 4107 // On Windows, the URI that is produced includes a drive letter, | 4109 // On Windows, the URI that is produced includes a drive letter, |
| 4108 // which I believe is not consistent across all machines that might run | 4110 // which I believe is not consistent across all machines that might run |
| 4109 // this test. | 4111 // this test. |
| 4110 return; | 4112 return; |
| 4111 } | 4113 } |
| 4112 JavaFile file = FileUtilities2.createFile("/a/b/test.dart"); | 4114 JavaFile file = FileUtilities2.createFile("/a/b/test.dart"); |
| 4113 FileBasedSource source = new FileBasedSource(file); | 4115 FileBasedSource source = new FileBasedSource(file); |
| 4114 expect(source, isNotNull); | 4116 expect(source, isNotNull); |
| 4115 Uri relative = | 4117 Uri relative = |
| 4116 source.resolveRelativeUri(parseUriWithException("c/lib.dart")); | 4118 resolveRelativeUri(source.uri, parseUriWithException("c/lib.dart")); |
| 4117 expect(relative, isNotNull); | 4119 expect(relative, isNotNull); |
| 4118 expect(relative.toString(), "file:///a/b/c/lib.dart"); | 4120 expect(relative.toString(), "file:///a/b/c/lib.dart"); |
| 4119 } | 4121 } |
| 4120 | 4122 |
| 4121 void test_resolveRelative_file_filePathWithParent() { | 4123 void test_resolveRelative_file_filePathWithParent() { |
| 4122 if (OSUtilities.isWindows()) { | 4124 if (OSUtilities.isWindows()) { |
| 4123 // On Windows, the URI that is produced includes a drive letter, which I | 4125 // On Windows, the URI that is produced includes a drive letter, which I |
| 4124 // believe is not consistent across all machines that might run this test. | 4126 // believe is not consistent across all machines that might run this test. |
| 4125 return; | 4127 return; |
| 4126 } | 4128 } |
| 4127 JavaFile file = FileUtilities2.createFile("/a/b/test.dart"); | 4129 JavaFile file = FileUtilities2.createFile("/a/b/test.dart"); |
| 4128 FileBasedSource source = new FileBasedSource(file); | 4130 FileBasedSource source = new FileBasedSource(file); |
| 4129 expect(source, isNotNull); | 4131 expect(source, isNotNull); |
| 4130 Uri relative = | 4132 Uri relative = |
| 4131 source.resolveRelativeUri(parseUriWithException("../c/lib.dart")); | 4133 resolveRelativeUri(source.uri, parseUriWithException("../c/lib.dart")); |
| 4132 expect(relative, isNotNull); | 4134 expect(relative, isNotNull); |
| 4133 expect(relative.toString(), "file:///a/c/lib.dart"); | 4135 expect(relative.toString(), "file:///a/c/lib.dart"); |
| 4134 } | 4136 } |
| 4135 | 4137 |
| 4136 void test_resolveRelative_package_fileName() { | 4138 void test_resolveRelative_package_fileName() { |
| 4137 JavaFile file = FileUtilities2.createFile("/a/b/test.dart"); | 4139 JavaFile file = FileUtilities2.createFile("/a/b/test.dart"); |
| 4138 FileBasedSource source = | 4140 FileBasedSource source = |
| 4139 new FileBasedSource(file, parseUriWithException("package:b/test.dart")); | 4141 new FileBasedSource(file, parseUriWithException("package:b/test.dart")); |
| 4140 expect(source, isNotNull); | 4142 expect(source, isNotNull); |
| 4141 Uri relative = source.resolveRelativeUri(parseUriWithException("lib.dart")); | 4143 Uri relative = |
| 4144 resolveRelativeUri(source.uri, parseUriWithException("lib.dart")); | |
| 4142 expect(relative, isNotNull); | 4145 expect(relative, isNotNull); |
| 4143 expect(relative.toString(), "package:b/lib.dart"); | 4146 expect(relative.toString(), "package:b/lib.dart"); |
| 4144 } | 4147 } |
| 4145 | 4148 |
| 4146 void test_resolveRelative_package_fileNameWithoutPackageName() { | 4149 void test_resolveRelative_package_fileNameWithoutPackageName() { |
| 4147 JavaFile file = FileUtilities2.createFile("/a/b/test.dart"); | 4150 JavaFile file = FileUtilities2.createFile("/a/b/test.dart"); |
| 4148 FileBasedSource source = | 4151 FileBasedSource source = |
| 4149 new FileBasedSource(file, parseUriWithException("package:test.dart")); | 4152 new FileBasedSource(file, parseUriWithException("package:test.dart")); |
| 4150 expect(source, isNotNull); | 4153 expect(source, isNotNull); |
| 4151 Uri relative = source.resolveRelativeUri(parseUriWithException("lib.dart")); | 4154 Uri relative = |
| 4155 resolveRelativeUri(source.uri, parseUriWithException("lib.dart")); | |
| 4152 expect(relative, isNotNull); | 4156 expect(relative, isNotNull); |
| 4153 expect(relative.toString(), "package:lib.dart"); | 4157 expect(relative.toString(), "package:lib.dart"); |
| 4154 } | 4158 } |
| 4155 | 4159 |
| 4156 void test_resolveRelative_package_filePath() { | 4160 void test_resolveRelative_package_filePath() { |
| 4157 JavaFile file = FileUtilities2.createFile("/a/b/test.dart"); | 4161 JavaFile file = FileUtilities2.createFile("/a/b/test.dart"); |
| 4158 FileBasedSource source = | 4162 FileBasedSource source = |
| 4159 new FileBasedSource(file, parseUriWithException("package:b/test.dart")); | 4163 new FileBasedSource(file, parseUriWithException("package:b/test.dart")); |
| 4160 expect(source, isNotNull); | 4164 expect(source, isNotNull); |
| 4161 Uri relative = | 4165 Uri relative = |
| 4162 source.resolveRelativeUri(parseUriWithException("c/lib.dart")); | 4166 resolveRelativeUri(source.uri, parseUriWithException("c/lib.dart")); |
| 4163 expect(relative, isNotNull); | 4167 expect(relative, isNotNull); |
| 4164 expect(relative.toString(), "package:b/c/lib.dart"); | 4168 expect(relative.toString(), "package:b/c/lib.dart"); |
| 4165 } | 4169 } |
| 4166 | 4170 |
| 4167 void test_resolveRelative_package_filePathWithParent() { | 4171 void test_resolveRelative_package_filePathWithParent() { |
| 4168 JavaFile file = FileUtilities2.createFile("/a/b/test.dart"); | 4172 JavaFile file = FileUtilities2.createFile("/a/b/test.dart"); |
| 4169 FileBasedSource source = new FileBasedSource( | 4173 FileBasedSource source = new FileBasedSource( |
| 4170 file, parseUriWithException("package:a/b/test.dart")); | 4174 file, parseUriWithException("package:a/b/test.dart")); |
| 4171 expect(source, isNotNull); | 4175 expect(source, isNotNull); |
| 4172 Uri relative = | 4176 Uri relative = |
| 4173 source.resolveRelativeUri(parseUriWithException("../c/lib.dart")); | 4177 resolveRelativeUri(source.uri, parseUriWithException("../c/lib.dart")); |
| 4174 expect(relative, isNotNull); | 4178 expect(relative, isNotNull); |
| 4175 expect(relative.toString(), "package:a/c/lib.dart"); | 4179 expect(relative.toString(), "package:a/c/lib.dart"); |
| 4176 } | 4180 } |
| 4177 | 4181 |
| 4178 void test_system() { | 4182 void test_system() { |
| 4179 JavaFile file = FileUtilities2.createFile("/does/not/exist.dart"); | 4183 JavaFile file = FileUtilities2.createFile("/does/not/exist.dart"); |
| 4180 FileBasedSource source = | 4184 FileBasedSource source = |
| 4181 new FileBasedSource(file, parseUriWithException("dart:core")); | 4185 new FileBasedSource(file, parseUriWithException("dart:core")); |
| 4182 expect(source, isNotNull); | 4186 expect(source, isNotNull); |
| 4183 expect(source.fullName, file.getAbsolutePath()); | 4187 expect(source.fullName, file.getAbsolutePath()); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4303 expect(UriKind.fromEncoding(0x70), same(UriKind.PACKAGE_URI)); | 4307 expect(UriKind.fromEncoding(0x70), same(UriKind.PACKAGE_URI)); |
| 4304 expect(UriKind.fromEncoding(0x58), same(null)); | 4308 expect(UriKind.fromEncoding(0x58), same(null)); |
| 4305 } | 4309 } |
| 4306 | 4310 |
| 4307 void test_getEncoding() { | 4311 void test_getEncoding() { |
| 4308 expect(UriKind.DART_URI.encoding, 0x64); | 4312 expect(UriKind.DART_URI.encoding, 0x64); |
| 4309 expect(UriKind.FILE_URI.encoding, 0x66); | 4313 expect(UriKind.FILE_URI.encoding, 0x66); |
| 4310 expect(UriKind.PACKAGE_URI.encoding, 0x70); | 4314 expect(UriKind.PACKAGE_URI.encoding, 0x70); |
| 4311 } | 4315 } |
| 4312 } | 4316 } |
| OLD | NEW |