Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(246)

Side by Side Diff: tests/compiler/dart2js/mirrors_test.dart

Issue 11238035: Make isEmpty a getter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update status file with co19 issue number. Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/compiler/dart2js/link_test.dart ('k') | tests/compiler/dart2js/mock_compiler.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 #import("../../../pkg/dartdoc/lib/mirrors.dart"); 5 #import("../../../pkg/dartdoc/lib/mirrors.dart");
6 #import("../../../pkg/dartdoc/lib/mirrors_util.dart"); 6 #import("../../../pkg/dartdoc/lib/mirrors_util.dart");
7 7
8 #import('dart:io'); 8 #import('dart:io');
9 9
10 int count(Iterable iterable) { 10 int count(Iterable iterable) {
(...skipping 28 matching lines...) Expand all
39 var libPath = dirPath.join(new Path.fromNative('../../../')); 39 var libPath = dirPath.join(new Path.fromNative('../../../'));
40 var inputPath = dirPath.join(new Path.fromNative('mirrors_helper.dart')); 40 var inputPath = dirPath.join(new Path.fromNative('mirrors_helper.dart'));
41 var compilation = new Compilation.library([inputPath], libPath); 41 var compilation = new Compilation.library([inputPath], libPath);
42 Expect.isNotNull(compilation, "No compilation created"); 42 Expect.isNotNull(compilation, "No compilation created");
43 43
44 var mirrors = compilation.mirrors; 44 var mirrors = compilation.mirrors;
45 Expect.isNotNull(mirrors, "No mirror system returned from compilation"); 45 Expect.isNotNull(mirrors, "No mirror system returned from compilation");
46 46
47 var libraries = mirrors.libraries; 47 var libraries = mirrors.libraries;
48 Expect.isNotNull(libraries, "No libraries map returned"); 48 Expect.isNotNull(libraries, "No libraries map returned");
49 Expect.isFalse(libraries.isEmpty(), "Empty libraries map returned"); 49 Expect.isFalse(libraries.isEmpty, "Empty libraries map returned");
50 50
51 var helperLibrary = libraries["mirrors_helper"]; 51 var helperLibrary = libraries["mirrors_helper"];
52 Expect.isNotNull(helperLibrary, "Library 'mirrors_helper' not found"); 52 Expect.isNotNull(helperLibrary, "Library 'mirrors_helper' not found");
53 Expect.stringEquals("mirrors_helper", helperLibrary.simpleName, 53 Expect.stringEquals("mirrors_helper", helperLibrary.simpleName,
54 "Unexpected library simple name"); 54 "Unexpected library simple name");
55 Expect.stringEquals("mirrors_helper", helperLibrary.qualifiedName, 55 Expect.stringEquals("mirrors_helper", helperLibrary.qualifiedName,
56 "Unexpected library qualified name"); 56 "Unexpected library qualified name");
57 57
58 var types = helperLibrary.types; 58 var types = helperLibrary.types;
59 Expect.isNotNull(types, "No types map returned"); 59 Expect.isNotNull(types, "No types map returned");
60 Expect.isFalse(types.isEmpty(), "Empty types map returned"); 60 Expect.isFalse(types.isEmpty, "Empty types map returned");
61 61
62 testFoo(mirrors, helperLibrary, types); 62 testFoo(mirrors, helperLibrary, types);
63 testBar(mirrors, helperLibrary, types); 63 testBar(mirrors, helperLibrary, types);
64 testBaz(mirrors, helperLibrary, types); 64 testBaz(mirrors, helperLibrary, types);
65 // TODO(johnniwinther): Add test of class [Boz] and typedef [Func]. 65 // TODO(johnniwinther): Add test of class [Boz] and typedef [Func].
66 // TODO(johnniwinther): Add tests of type argument substitution, which 66 // TODO(johnniwinther): Add tests of type argument substitution, which
67 // is not currently implemented in dart2js. 67 // is not currently implemented in dart2js.
68 // TODO(johnniwinther): Add tests of Location and Source. 68 // TODO(johnniwinther): Add tests of Location and Source.
69 testPrivate(mirrors, helperLibrary, types); 69 testPrivate(mirrors, helperLibrary, types);
70 } 70 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 var objectType = fooClass.superclass; 106 var objectType = fooClass.superclass;
107 Expect.isNotNull(objectType, "Superclass is null"); 107 Expect.isNotNull(objectType, "Superclass is null");
108 Expect.isTrue(objectType.isObject, "Object is not Object"); 108 Expect.isTrue(objectType.isObject, "Object is not Object");
109 Expect.isFalse(objectType.isDeclaration, "Object type is declaration"); 109 Expect.isFalse(objectType.isDeclaration, "Object type is declaration");
110 Expect.isTrue(containsType(fooClass, 110 Expect.isTrue(containsType(fooClass,
111 computeSubdeclarations(objectType)), 111 computeSubdeclarations(objectType)),
112 "Class is not subclass of superclass"); 112 "Class is not subclass of superclass");
113 113
114 var fooInterfaces = fooClass.interfaces; 114 var fooInterfaces = fooClass.interfaces;
115 Expect.isNotNull(fooInterfaces, "Interfaces map is null"); 115 Expect.isNotNull(fooInterfaces, "Interfaces map is null");
116 Expect.isTrue(fooInterfaces.isEmpty(), "Interfaces map is not empty"); 116 Expect.isTrue(fooInterfaces.isEmpty, "Interfaces map is not empty");
117 117
118 var fooSubdeclarations = computeSubdeclarations(fooClass); 118 var fooSubdeclarations = computeSubdeclarations(fooClass);
119 Expect.equals(1, count(fooSubdeclarations), "Unexpected subtype count"); 119 Expect.equals(1, count(fooSubdeclarations), "Unexpected subtype count");
120 for (var fooSubdeclaration in fooSubdeclarations) { 120 for (var fooSubdeclaration in fooSubdeclarations) {
121 Expect.equals(fooClass, fooSubdeclaration.superclass.declaration, 121 Expect.equals(fooClass, fooSubdeclaration.superclass.declaration,
122 "Class is not superclass of subclass"); 122 "Class is not superclass of subclass");
123 } 123 }
124 124
125 Expect.throws(() => fooClass.typeArguments, 125 Expect.throws(() => fooClass.typeArguments,
126 (exception) => true, 126 (exception) => true,
127 "Class has type arguments"); 127 "Class has type arguments");
128 var fooClassTypeVariables = fooClass.typeVariables; 128 var fooClassTypeVariables = fooClass.typeVariables;
129 Expect.isNotNull(fooClassTypeVariables, "Type variable list is null"); 129 Expect.isNotNull(fooClassTypeVariables, "Type variable list is null");
130 Expect.isTrue(fooClassTypeVariables.isEmpty(), 130 Expect.isTrue(fooClassTypeVariables.isEmpty,
131 "Type variable list is not empty"); 131 "Type variable list is not empty");
132 132
133 Expect.isNull(fooClass.defaultType, "Class has default type"); 133 Expect.isNull(fooClass.defaultType, "Class has default type");
134 134
135 var fooClassMembers = fooClass.declaredMembers; 135 var fooClassMembers = fooClass.declaredMembers;
136 Expect.isNotNull(fooClassMembers, "Declared members map is null"); 136 Expect.isNotNull(fooClassMembers, "Declared members map is null");
137 Expect.isTrue(fooClassMembers.isEmpty(), "Declared members map is unempty"); 137 Expect.isTrue(fooClassMembers.isEmpty, "Declared members map is unempty");
138 138
139 var fooClassConstructors = fooClass.constructors; 139 var fooClassConstructors = fooClass.constructors;
140 Expect.isNotNull(fooClassConstructors, "Constructors map is null"); 140 Expect.isNotNull(fooClassConstructors, "Constructors map is null");
141 Expect.isTrue(fooClassConstructors.isEmpty(), 141 Expect.isTrue(fooClassConstructors.isEmpty,
142 "Constructors map is unempty"); 142 "Constructors map is unempty");
143 } 143 }
144 144
145 // Testing interface Bar: 145 // Testing interface Bar:
146 // 146 //
147 // interface Bar<E> { 147 // interface Bar<E> {
148 // 148 //
149 // } 149 // }
150 void testBar(MirrorSystem system, LibraryMirror helperLibrary, 150 void testBar(MirrorSystem system, LibraryMirror helperLibrary,
151 Map<String,TypeMirror> types) { 151 Map<String,TypeMirror> types) {
(...skipping 27 matching lines...) Expand all
179 var objectType = barInterface.superclass; 179 var objectType = barInterface.superclass;
180 Expect.isNotNull(objectType, "Superclass is null"); 180 Expect.isNotNull(objectType, "Superclass is null");
181 Expect.isTrue(objectType.isObject, "Object is not Object"); 181 Expect.isTrue(objectType.isObject, "Object is not Object");
182 Expect.isFalse(objectType.isDeclaration, "Object type is declaration"); 182 Expect.isFalse(objectType.isDeclaration, "Object type is declaration");
183 Expect.isTrue(containsType(barInterface, 183 Expect.isTrue(containsType(barInterface,
184 computeSubdeclarations(objectType)), 184 computeSubdeclarations(objectType)),
185 "Class is not subclass of superclass"); 185 "Class is not subclass of superclass");
186 186
187 var barInterfaces = barInterface.interfaces; 187 var barInterfaces = barInterface.interfaces;
188 Expect.isNotNull(barInterfaces, "Interfaces map is null"); 188 Expect.isNotNull(barInterfaces, "Interfaces map is null");
189 Expect.isTrue(barInterfaces.isEmpty(), "Interfaces map is not empty"); 189 Expect.isTrue(barInterfaces.isEmpty, "Interfaces map is not empty");
190 190
191 var barSubdeclarations = computeSubdeclarations(barInterface); 191 var barSubdeclarations = computeSubdeclarations(barInterface);
192 Expect.equals(1, count(barSubdeclarations), "Unexpected subtype count"); 192 Expect.equals(1, count(barSubdeclarations), "Unexpected subtype count");
193 for (var barSubdeclaration in barSubdeclarations) { 193 for (var barSubdeclaration in barSubdeclarations) {
194 Expect.isTrue(containsType(barInterface, 194 Expect.isTrue(containsType(barInterface,
195 barSubdeclaration.interfaces), 195 barSubdeclaration.interfaces),
196 "Interface is not superinterface of subclass"); 196 "Interface is not superinterface of subclass");
197 } 197 }
198 198
199 Expect.throws(() => barInterface.typeArguments, 199 Expect.throws(() => barInterface.typeArguments,
200 (exception) => true, 200 (exception) => true,
201 "Interface has type arguments"); 201 "Interface has type arguments");
202 var barInterfaceTypeVariables = barInterface.typeVariables; 202 var barInterfaceTypeVariables = barInterface.typeVariables;
203 Expect.isNotNull(barInterfaceTypeVariables, "Type variable list is null"); 203 Expect.isNotNull(barInterfaceTypeVariables, "Type variable list is null");
204 Expect.isFalse(barInterfaceTypeVariables.isEmpty(), 204 Expect.isFalse(barInterfaceTypeVariables.isEmpty,
205 "Type variable list is empty"); 205 "Type variable list is empty");
206 Expect.equals(barInterfaceTypeVariables.length, 1, 206 Expect.equals(barInterfaceTypeVariables.length, 1,
207 "Unexpected number of type variables"); 207 "Unexpected number of type variables");
208 208
209 var barE = barInterfaceTypeVariables[0]; 209 var barE = barInterfaceTypeVariables[0];
210 Expect.isNotNull(barE, "Type variable is null"); 210 Expect.isNotNull(barE, "Type variable is null");
211 Expect.isTrue(barE.isTypeVariable, "Type variable is not type variable"); 211 Expect.isTrue(barE.isTypeVariable, "Type variable is not type variable");
212 212
213 Expect.isNull(barInterface.defaultType, "Interface has default type"); 213 Expect.isNull(barInterface.defaultType, "Interface has default type");
214 214
215 var barInterfaceMembers = barInterface.declaredMembers; 215 var barInterfaceMembers = barInterface.declaredMembers;
216 Expect.isNotNull(barInterfaceMembers, "Declared members map is null"); 216 Expect.isNotNull(barInterfaceMembers, "Declared members map is null");
217 Expect.isTrue(barInterfaceMembers.isEmpty(), 217 Expect.isTrue(barInterfaceMembers.isEmpty,
218 "Declared members map is unempty"); 218 "Declared members map is unempty");
219 219
220 var barInterfaceConstructors = barInterface.constructors; 220 var barInterfaceConstructors = barInterface.constructors;
221 Expect.isNotNull(barInterfaceConstructors, "Constructors map is null"); 221 Expect.isNotNull(barInterfaceConstructors, "Constructors map is null");
222 Expect.isTrue(barInterfaceConstructors.isEmpty(), 222 Expect.isTrue(barInterfaceConstructors.isEmpty,
223 "Constructors map is unempty"); 223 "Constructors map is unempty");
224 } 224 }
225 225
226 // Testing class Baz: 226 // Testing class Baz:
227 // 227 //
228 // class Baz<E,F extends Foo> implements Bar<E> { 228 // class Baz<E,F extends Foo> implements Bar<E> {
229 // Baz(); 229 // Baz();
230 // const Baz.named(); 230 // const Baz.named();
231 // factory Baz.factory() => new Baz<E,F>(); 231 // factory Baz.factory() => new Baz<E,F>();
232 // 232 //
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 var objectType = bazClass.superclass; 269 var objectType = bazClass.superclass;
270 Expect.isNotNull(objectType, "Superclass is null"); 270 Expect.isNotNull(objectType, "Superclass is null");
271 Expect.isTrue(objectType.isObject, "Object is not Object"); 271 Expect.isTrue(objectType.isObject, "Object is not Object");
272 Expect.isFalse(objectType.isDeclaration, "Object type is declaration"); 272 Expect.isFalse(objectType.isDeclaration, "Object type is declaration");
273 Expect.isTrue(containsType(bazClass, 273 Expect.isTrue(containsType(bazClass,
274 computeSubdeclarations(objectType)), 274 computeSubdeclarations(objectType)),
275 "Class is not subclass of superclass"); 275 "Class is not subclass of superclass");
276 276
277 var bazInterfaces = bazClass.interfaces; 277 var bazInterfaces = bazClass.interfaces;
278 Expect.isNotNull(bazInterfaces, "Interfaces map is null"); 278 Expect.isNotNull(bazInterfaces, "Interfaces map is null");
279 Expect.isTrue(!bazInterfaces.isEmpty(), "Interfaces map is empty"); 279 Expect.isTrue(!bazInterfaces.isEmpty, "Interfaces map is empty");
280 for (var bazInterface in bazInterfaces) { 280 for (var bazInterface in bazInterfaces) {
281 Expect.isTrue(containsType(bazClass, 281 Expect.isTrue(containsType(bazClass,
282 computeSubdeclarations(objectType)), 282 computeSubdeclarations(objectType)),
283 "Class is not subclass of superinterface"); 283 "Class is not subclass of superinterface");
284 } 284 }
285 285
286 var bazSubdeclarations = computeSubdeclarations(bazClass); 286 var bazSubdeclarations = computeSubdeclarations(bazClass);
287 Expect.equals(0, count(bazSubdeclarations), "Unexpected subtype count"); 287 Expect.equals(0, count(bazSubdeclarations), "Unexpected subtype count");
288 288
289 var barInterface = findMirror(bazInterfaces, "Bar"); 289 var barInterface = findMirror(bazInterfaces, "Bar");
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 Expect.isFalse(funcTypedef.isVoid, "Typedef is void"); 537 Expect.isFalse(funcTypedef.isVoid, "Typedef is void");
538 Expect.isFalse(funcTypedef.isTypeVariable, "Typedef is a type variable"); 538 Expect.isFalse(funcTypedef.isTypeVariable, "Typedef is a type variable");
539 Expect.isTrue(funcTypedef.isTypedef, "Typedef is not a typedef"); 539 Expect.isTrue(funcTypedef.isTypedef, "Typedef is not a typedef");
540 Expect.isFalse(funcTypedef.isFunction, "Typedef is a function"); 540 Expect.isFalse(funcTypedef.isFunction, "Typedef is a function");
541 541
542 Expect.equals(helperLibrary, funcTypedef.library, 542 Expect.equals(helperLibrary, funcTypedef.library,
543 "Unexpected typedef library"); 543 "Unexpected typedef library");
544 Expect.isNull(funcTypedef.superclass, "Non-null superclass on typedef"); 544 Expect.isNull(funcTypedef.superclass, "Non-null superclass on typedef");
545 Expect.isNotNull(funcTypedef.interfaces, 545 Expect.isNotNull(funcTypedef.interfaces,
546 "Null interfaces map on typedef"); 546 "Null interfaces map on typedef");
547 Expect.isTrue(funcTypedef.interfaces.isEmpty(), 547 Expect.isTrue(funcTypedef.interfaces.isEmpty,
548 "Non-empty interfaces map on typedef"); 548 "Non-empty interfaces map on typedef");
549 Expect.isNotNull(funcTypedef.declaredMembers, 549 Expect.isNotNull(funcTypedef.declaredMembers,
550 "Declared members map is null on type def"); 550 "Declared members map is null on type def");
551 Expect.isTrue(funcTypedef.declaredMembers.isEmpty(), 551 Expect.isTrue(funcTypedef.declaredMembers.isEmpty,
552 "Non-empty declared members map on typedef"); 552 "Non-empty declared members map on typedef");
553 553
554 // TODO(johnniwinther): Returned typedef should not be the declaration: 554 // TODO(johnniwinther): Returned typedef should not be the declaration:
555 Expect.isTrue(funcTypedef.isDeclaration, "Typedef is not declaration"); 555 Expect.isTrue(funcTypedef.isDeclaration, "Typedef is not declaration");
556 Expect.isFalse(funcTypedef.isClass, "Typedef is class"); 556 Expect.isFalse(funcTypedef.isClass, "Typedef is class");
557 Expect.isFalse(funcTypedef.isInterface, "Typedef is interface"); 557 Expect.isFalse(funcTypedef.isInterface, "Typedef is interface");
558 Expect.isFalse(funcTypedef.isPrivate, "Typedef is private"); 558 Expect.isFalse(funcTypedef.isPrivate, "Typedef is private");
559 Expect.isNull(funcTypedef.defaultType, 559 Expect.isNull(funcTypedef.defaultType,
560 "Typedef default type is non-null"); 560 "Typedef default type is non-null");
561 // TODO(johnniwinther): Should not throw an exception since the type should 561 // TODO(johnniwinther): Should not throw an exception since the type should
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 Expect.isTrue(privateConstructor.isConstructor); 732 Expect.isTrue(privateConstructor.isConstructor);
733 Expect.isTrue(privateConstructor.isPrivate); 733 Expect.isTrue(privateConstructor.isPrivate);
734 734
735 var privateFactoryConstructor = 735 var privateFactoryConstructor =
736 privateClass.declaredMembers['_PrivateClass._privateFactoryConstructor']; 736 privateClass.declaredMembers['_PrivateClass._privateFactoryConstructor'];
737 Expect.isNotNull(privateFactoryConstructor); 737 Expect.isNotNull(privateFactoryConstructor);
738 Expect.isTrue(privateFactoryConstructor is MethodMirror); 738 Expect.isTrue(privateFactoryConstructor is MethodMirror);
739 Expect.isTrue(privateFactoryConstructor.isFactory); 739 Expect.isTrue(privateFactoryConstructor.isFactory);
740 Expect.isTrue(privateFactoryConstructor.isPrivate); 740 Expect.isTrue(privateFactoryConstructor.isPrivate);
741 } 741 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/link_test.dart ('k') | tests/compiler/dart2js/mock_compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698