OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
7 | 7 |
8 library analyzer.test.generated.source_factory; | 8 library analyzer.test.generated.source_factory; |
9 | 9 |
10 import 'package:analyzer/file_system/file_system.dart'; | 10 import 'package:analyzer/file_system/file_system.dart'; |
(...skipping 13 matching lines...) Expand all Loading... |
24 main() { | 24 main() { |
25 groupSep = ' | '; | 25 groupSep = ' | '; |
26 runReflectiveTests(SourceFactoryTest); | 26 runReflectiveTests(SourceFactoryTest); |
27 } | 27 } |
28 | 28 |
29 @reflectiveTest | 29 @reflectiveTest |
30 class SourceFactoryTest { | 30 class SourceFactoryTest { |
31 void test_creation() { | 31 void test_creation() { |
32 expect(new SourceFactory([]), isNotNull); | 32 expect(new SourceFactory([]), isNotNull); |
33 } | 33 } |
| 34 |
34 void test_fromEncoding_invalidUri() { | 35 void test_fromEncoding_invalidUri() { |
35 SourceFactory factory = new SourceFactory([]); | 36 SourceFactory factory = new SourceFactory([]); |
36 try { | 37 expect(() => factory.fromEncoding("<:&%>"), |
37 factory.fromEncoding("<:&%>"); | 38 throwsA(new isInstanceOf<IllegalArgumentException>())); |
38 fail("Expected IllegalArgumentException"); | |
39 } on IllegalArgumentException {} | |
40 } | 39 } |
| 40 |
41 void test_fromEncoding_noResolver() { | 41 void test_fromEncoding_noResolver() { |
42 SourceFactory factory = new SourceFactory([]); | 42 SourceFactory factory = new SourceFactory([]); |
43 try { | 43 expect(() => factory.fromEncoding("foo:/does/not/exist.dart"), |
44 factory.fromEncoding("foo:/does/not/exist.dart"); | 44 throwsA(new isInstanceOf<IllegalArgumentException>())); |
45 fail("Expected IllegalArgumentException"); | |
46 } on IllegalArgumentException {} | |
47 } | 45 } |
| 46 |
48 void test_fromEncoding_valid() { | 47 void test_fromEncoding_valid() { |
49 String encoding = "file:///does/not/exist.dart"; | 48 String encoding = "file:///does/not/exist.dart"; |
50 SourceFactory factory = new SourceFactory( | 49 SourceFactory factory = new SourceFactory( |
51 [new UriResolver_SourceFactoryTest_test_fromEncoding_valid(encoding)]); | 50 [new UriResolver_SourceFactoryTest_test_fromEncoding_valid(encoding)]); |
52 expect(factory.fromEncoding(encoding), isNotNull); | 51 expect(factory.fromEncoding(encoding), isNotNull); |
53 } | 52 } |
| 53 |
54 void test_resolveUri_absolute() { | 54 void test_resolveUri_absolute() { |
55 UriResolver_absolute resolver = new UriResolver_absolute(); | 55 UriResolver_absolute resolver = new UriResolver_absolute(); |
56 SourceFactory factory = new SourceFactory([resolver]); | 56 SourceFactory factory = new SourceFactory([resolver]); |
57 factory.resolveUri(null, "dart:core"); | 57 factory.resolveUri(null, "dart:core"); |
58 expect(resolver.invoked, isTrue); | 58 expect(resolver.invoked, isTrue); |
59 } | 59 } |
| 60 |
60 void test_resolveUri_nonAbsolute_absolute() { | 61 void test_resolveUri_nonAbsolute_absolute() { |
61 SourceFactory factory = | 62 SourceFactory factory = |
62 new SourceFactory([new UriResolver_nonAbsolute_absolute()]); | 63 new SourceFactory([new UriResolver_nonAbsolute_absolute()]); |
63 String absolutePath = "/does/not/matter.dart"; | 64 String absolutePath = "/does/not/matter.dart"; |
64 Source containingSource = | 65 Source containingSource = |
65 new FileBasedSource(FileUtilities2.createFile("/does/not/exist.dart")); | 66 new FileBasedSource(FileUtilities2.createFile("/does/not/exist.dart")); |
66 Source result = factory.resolveUri(containingSource, absolutePath); | 67 Source result = factory.resolveUri(containingSource, absolutePath); |
67 expect(result.fullName, | 68 expect(result.fullName, |
68 FileUtilities2.createFile(absolutePath).getAbsolutePath()); | 69 FileUtilities2.createFile(absolutePath).getAbsolutePath()); |
69 } | 70 } |
| 71 |
70 void test_resolveUri_nonAbsolute_relative() { | 72 void test_resolveUri_nonAbsolute_relative() { |
71 SourceFactory factory = | 73 SourceFactory factory = |
72 new SourceFactory([new UriResolver_nonAbsolute_relative()]); | 74 new SourceFactory([new UriResolver_nonAbsolute_relative()]); |
73 Source containingSource = | 75 Source containingSource = |
74 new FileBasedSource(FileUtilities2.createFile("/does/not/have.dart")); | 76 new FileBasedSource(FileUtilities2.createFile("/does/not/have.dart")); |
75 Source result = factory.resolveUri(containingSource, "exist.dart"); | 77 Source result = factory.resolveUri(containingSource, "exist.dart"); |
76 expect(result.fullName, | 78 expect(result.fullName, |
77 FileUtilities2.createFile("/does/not/exist.dart").getAbsolutePath()); | 79 FileUtilities2.createFile("/does/not/exist.dart").getAbsolutePath()); |
78 } | 80 } |
79 | 81 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 | 141 |
140 class UriResolver_nonAbsolute_relative extends UriResolver { | 142 class UriResolver_nonAbsolute_relative extends UriResolver { |
141 @override | 143 @override |
142 Source resolveAbsolute(Uri uri) { | 144 Source resolveAbsolute(Uri uri) { |
143 return new FileBasedSource(new JavaFile.fromUri(uri), uri); | 145 return new FileBasedSource(new JavaFile.fromUri(uri), uri); |
144 } | 146 } |
145 } | 147 } |
146 | 148 |
147 class UriResolver_restoreUri extends UriResolver { | 149 class UriResolver_restoreUri extends UriResolver { |
148 Source source1; | 150 Source source1; |
149 | |
150 Uri expected1; | 151 Uri expected1; |
151 | |
152 UriResolver_restoreUri(this.source1, this.expected1); | 152 UriResolver_restoreUri(this.source1, this.expected1); |
153 | 153 |
154 @override | 154 @override |
155 Source resolveAbsolute(Uri uri) => null; | 155 Source resolveAbsolute(Uri uri) => null; |
156 | 156 |
157 @override | 157 @override |
158 Uri restoreAbsolute(Source source) { | 158 Uri restoreAbsolute(Source source) { |
159 if (identical(source, source1)) { | 159 if (identical(source, source1)) { |
160 return expected1; | 160 return expected1; |
161 } | 161 } |
162 return null; | 162 return null; |
163 } | 163 } |
164 } | 164 } |
165 | 165 |
166 class UriResolver_SourceFactoryTest_test_fromEncoding_valid | 166 class UriResolver_SourceFactoryTest_test_fromEncoding_valid |
167 extends UriResolver { | 167 extends UriResolver { |
168 String encoding; | 168 String encoding; |
169 | |
170 UriResolver_SourceFactoryTest_test_fromEncoding_valid(this.encoding); | 169 UriResolver_SourceFactoryTest_test_fromEncoding_valid(this.encoding); |
171 | 170 |
172 @override | 171 @override |
173 Source resolveAbsolute(Uri uri) { | 172 Source resolveAbsolute(Uri uri) { |
174 if (uri.toString() == encoding) { | 173 if (uri.toString() == encoding) { |
175 return new TestSource(); | 174 return new TestSource(); |
176 } | 175 } |
177 return null; | 176 return null; |
178 } | 177 } |
179 } | 178 } |
OLD | NEW |