| OLD | NEW |
| 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("../../../lib/dartdoc/mirrors/mirrors.dart"); | 5 #import("../../../lib/dartdoc/mirrors/mirrors.dart"); |
| 6 #import("../../../lib/dartdoc/mirrors/mirrors_util.dart"); | 6 #import("../../../lib/dartdoc/mirrors/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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 | 92 |
| 93 Expect.isTrue(fooClass.isClass, "Class is not class"); | 93 Expect.isTrue(fooClass.isClass, "Class is not class"); |
| 94 Expect.isFalse(fooClass.isInterface, "Class is interface"); | 94 Expect.isFalse(fooClass.isInterface, "Class is interface"); |
| 95 Expect.isFalse(fooClass.isPrivate, "Class is private"); | 95 Expect.isFalse(fooClass.isPrivate, "Class is private"); |
| 96 | 96 |
| 97 var objectType = fooClass.superclass(); | 97 var objectType = fooClass.superclass(); |
| 98 Expect.isNotNull(objectType, "Superclass is null"); | 98 Expect.isNotNull(objectType, "Superclass is null"); |
| 99 Expect.isTrue(objectType.isObject, "Object is not Object"); | 99 Expect.isTrue(objectType.isObject, "Object is not Object"); |
| 100 Expect.isFalse(objectType.isDeclaration, "Object type is declaration"); | 100 Expect.isFalse(objectType.isDeclaration, "Object type is declaration"); |
| 101 Expect.isTrue(containsType(fooClass, | 101 Expect.isTrue(containsType(fooClass, |
| 102 computeSubdeclarations(system, objectType)), | 102 computeSubdeclarations(objectType)), |
| 103 "Class is not subclass of superclass"); | 103 "Class is not subclass of superclass"); |
| 104 | 104 |
| 105 var fooInterfaces = fooClass.interfaces(); | 105 var fooInterfaces = fooClass.interfaces(); |
| 106 Expect.isNotNull(fooInterfaces, "Interfaces map is null"); | 106 Expect.isNotNull(fooInterfaces, "Interfaces map is null"); |
| 107 Expect.isTrue(fooInterfaces.isEmpty(), "Interfaces map is not empty"); | 107 Expect.isTrue(fooInterfaces.isEmpty(), "Interfaces map is not empty"); |
| 108 | 108 |
| 109 var fooSubdeclarations = computeSubdeclarations(system, fooClass); | 109 var fooSubdeclarations = computeSubdeclarations(fooClass); |
| 110 Expect.equals(1, count(fooSubdeclarations), "Unexpected subtype count"); | 110 Expect.equals(1, count(fooSubdeclarations), "Unexpected subtype count"); |
| 111 for (var fooSubdeclaration in fooSubdeclarations) { | 111 for (var fooSubdeclaration in fooSubdeclarations) { |
| 112 Expect.equals(fooClass, fooSubdeclaration.superclass().declaration, | 112 Expect.equals(fooClass, fooSubdeclaration.superclass().declaration, |
| 113 "Class is not superclass of subclass"); | 113 "Class is not superclass of subclass"); |
| 114 } | 114 } |
| 115 | 115 |
| 116 Expect.throws(() => fooClass.typeArguments(), | 116 Expect.throws(() => fooClass.typeArguments(), |
| 117 (exception) => true, | 117 (exception) => true, |
| 118 "Class has type arguments"); | 118 "Class has type arguments"); |
| 119 var fooClassTypeVariables = fooClass.typeVariables(); | 119 var fooClassTypeVariables = fooClass.typeVariables(); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 | 165 |
| 166 Expect.isFalse(barInterface.isClass, "Interface is class"); | 166 Expect.isFalse(barInterface.isClass, "Interface is class"); |
| 167 Expect.isTrue(barInterface.isInterface, "Interface is not interface"); | 167 Expect.isTrue(barInterface.isInterface, "Interface is not interface"); |
| 168 Expect.isFalse(barInterface.isPrivate, "Interface is private"); | 168 Expect.isFalse(barInterface.isPrivate, "Interface is private"); |
| 169 | 169 |
| 170 var objectType = barInterface.superclass(); | 170 var objectType = barInterface.superclass(); |
| 171 Expect.isNotNull(objectType, "Superclass is null"); | 171 Expect.isNotNull(objectType, "Superclass is null"); |
| 172 Expect.isTrue(objectType.isObject, "Object is not Object"); | 172 Expect.isTrue(objectType.isObject, "Object is not Object"); |
| 173 Expect.isFalse(objectType.isDeclaration, "Object type is declaration"); | 173 Expect.isFalse(objectType.isDeclaration, "Object type is declaration"); |
| 174 Expect.isTrue(containsType(barInterface, | 174 Expect.isTrue(containsType(barInterface, |
| 175 computeSubdeclarations(system, objectType)), | 175 computeSubdeclarations(objectType)), |
| 176 "Class is not subclass of superclass"); | 176 "Class is not subclass of superclass"); |
| 177 | 177 |
| 178 var barInterfaces = barInterface.interfaces(); | 178 var barInterfaces = barInterface.interfaces(); |
| 179 Expect.isNotNull(barInterfaces, "Interfaces map is null"); | 179 Expect.isNotNull(barInterfaces, "Interfaces map is null"); |
| 180 Expect.isTrue(barInterfaces.isEmpty(), "Interfaces map is not empty"); | 180 Expect.isTrue(barInterfaces.isEmpty(), "Interfaces map is not empty"); |
| 181 | 181 |
| 182 var barSubdeclarations = computeSubdeclarations(system, barInterface); | 182 var barSubdeclarations = computeSubdeclarations(barInterface); |
| 183 Expect.equals(1, count(barSubdeclarations), "Unexpected subtype count"); | 183 Expect.equals(1, count(barSubdeclarations), "Unexpected subtype count"); |
| 184 for (var barSubdeclaration in barSubdeclarations) { | 184 for (var barSubdeclaration in barSubdeclarations) { |
| 185 Expect.isTrue(containsType(barInterface, | 185 Expect.isTrue(containsType(barInterface, |
| 186 barSubdeclaration.interfaces().getValues()), | 186 barSubdeclaration.interfaces().getValues()), |
| 187 "Interface is not superinterface of subclass"); | 187 "Interface is not superinterface of subclass"); |
| 188 } | 188 } |
| 189 | 189 |
| 190 Expect.throws(() => barInterface.typeArguments(), | 190 Expect.throws(() => barInterface.typeArguments(), |
| 191 (exception) => true, | 191 (exception) => true, |
| 192 "Interface has type arguments"); | 192 "Interface has type arguments"); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 | 255 |
| 256 Expect.isTrue(bazClass.isClass, "Class is not class"); | 256 Expect.isTrue(bazClass.isClass, "Class is not class"); |
| 257 Expect.isFalse(bazClass.isInterface, "Class is interface"); | 257 Expect.isFalse(bazClass.isInterface, "Class is interface"); |
| 258 Expect.isFalse(bazClass.isPrivate, "Class is private"); | 258 Expect.isFalse(bazClass.isPrivate, "Class is private"); |
| 259 | 259 |
| 260 var objectType = bazClass.superclass(); | 260 var objectType = bazClass.superclass(); |
| 261 Expect.isNotNull(objectType, "Superclass is null"); | 261 Expect.isNotNull(objectType, "Superclass is null"); |
| 262 Expect.isTrue(objectType.isObject, "Object is not Object"); | 262 Expect.isTrue(objectType.isObject, "Object is not Object"); |
| 263 Expect.isFalse(objectType.isDeclaration, "Object type is declaration"); | 263 Expect.isFalse(objectType.isDeclaration, "Object type is declaration"); |
| 264 Expect.isTrue(containsType(bazClass, | 264 Expect.isTrue(containsType(bazClass, |
| 265 computeSubdeclarations(system, objectType)), | 265 computeSubdeclarations(objectType)), |
| 266 "Class is not subclass of superclass"); | 266 "Class is not subclass of superclass"); |
| 267 | 267 |
| 268 var bazInterfaces = bazClass.interfaces(); | 268 var bazInterfaces = bazClass.interfaces(); |
| 269 Expect.isNotNull(bazInterfaces, "Interfaces map is null"); | 269 Expect.isNotNull(bazInterfaces, "Interfaces map is null"); |
| 270 Expect.isTrue(!bazInterfaces.isEmpty(), "Interfaces map is empty"); | 270 Expect.isTrue(!bazInterfaces.isEmpty(), "Interfaces map is empty"); |
| 271 for (var bazInterface in bazInterfaces.getValues()) { | 271 for (var bazInterface in bazInterfaces.getValues()) { |
| 272 Expect.isTrue(containsType(bazClass, | 272 Expect.isTrue(containsType(bazClass, |
| 273 computeSubdeclarations(system, objectType)), | 273 computeSubdeclarations(objectType)), |
| 274 "Class is not subclass of superinterface"); | 274 "Class is not subclass of superinterface"); |
| 275 } | 275 } |
| 276 | 276 |
| 277 var bazSubdeclarations = computeSubdeclarations(system, bazClass); | 277 var bazSubdeclarations = computeSubdeclarations(bazClass); |
| 278 Expect.equals(0, count(bazSubdeclarations), "Unexpected subtype count"); | 278 Expect.equals(0, count(bazSubdeclarations), "Unexpected subtype count"); |
| 279 | 279 |
| 280 var barInterface = findMirror(bazInterfaces, "Bar"); | 280 var barInterface = findMirror(bazInterfaces, "Bar"); |
| 281 Expect.isNotNull(barInterface, "Interface bar is missing"); | 281 Expect.isNotNull(barInterface, "Interface bar is missing"); |
| 282 Expect.isFalse(barInterface.isDeclaration, "Interface type is declaration"); | 282 Expect.isFalse(barInterface.isDeclaration, "Interface type is declaration"); |
| 283 var barInterfaceTypeArguments = barInterface.typeArguments(); | 283 var barInterfaceTypeArguments = barInterface.typeArguments(); |
| 284 Expect.isNotNull(barInterfaceTypeArguments, "Type arguments are missing"); | 284 Expect.isNotNull(barInterfaceTypeArguments, "Type arguments are missing"); |
| 285 // TODO(johnniwinther): Ensure type arguments on supertypes. Expected result | 285 // TODO(johnniwinther): Ensure type arguments on supertypes. Expected result |
| 286 // should have been 1: | 286 // should have been 1: |
| 287 Expect.equals(0, barInterfaceTypeArguments.length, | 287 Expect.equals(0, barInterfaceTypeArguments.length, |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 Expect.stringEquals('negate', operator_negate.operatorName, | 614 Expect.stringEquals('negate', operator_negate.operatorName, |
| 615 "Unexpected operatorName"); | 615 "Unexpected operatorName"); |
| 616 | 616 |
| 617 | 617 |
| 618 var bazClassConstructors = bazClass.constructors(); | 618 var bazClassConstructors = bazClass.constructors(); |
| 619 Expect.isNotNull(bazClassConstructors, "Constructors map is null"); | 619 Expect.isNotNull(bazClassConstructors, "Constructors map is null"); |
| 620 Expect.equals(3, bazClassConstructors.length, | 620 Expect.equals(3, bazClassConstructors.length, |
| 621 "Unexpected number of constructors"); | 621 "Unexpected number of constructors"); |
| 622 // TODO(johnniwinther): Add tests of constructors. | 622 // TODO(johnniwinther): Add tests of constructors. |
| 623 } | 623 } |
| OLD | NEW |