Index: tests/compiler/dart2js/mirrors_test.dart |
diff --git a/tests/compiler/dart2js/mirrors_test.dart b/tests/compiler/dart2js/mirrors_test.dart |
index 3536683675f625c3e7e199b06c22f56d8b1cb3e1..d7b02c7ce1c96c056588880fc3a74f9ec2eca01d 100644 |
--- a/tests/compiler/dart2js/mirrors_test.dart |
+++ b/tests/compiler/dart2js/mirrors_test.dart |
@@ -4,9 +4,9 @@ |
import "package:expect/expect.dart"; |
import "package:async_helper/async_helper.dart"; |
-import '../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors.dart'; |
+import '../../../sdk/lib/_internal/compiler/implementation/mirrors/source_mirrors.dart'; |
import '../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util.dart'; |
-import '../../../sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirror.dart'; |
+import '../../../sdk/lib/_internal/compiler/implementation/mirrors/analyze.dart'; |
import '../../../sdk/lib/_internal/compiler/implementation/filenames.dart' |
show currentDirectory; |
import '../../../sdk/lib/_internal/compiler/implementation/source_file_provider.dart'; |
@@ -32,7 +32,7 @@ bool containsType(TypeMirror expected, Iterable<TypeMirror> iterable) { |
return false; |
} |
-DeclarationMirror findMirror(Iterable<DeclarationMirror> list, String name) { |
+DeclarationMirror findMirror(Iterable<DeclarationMirror> list, Symbol name) { |
for (DeclarationMirror mirror in list) { |
if (mirror.simpleName == name) { |
return mirror; |
@@ -64,13 +64,13 @@ void test(MirrorSystem mirrors) { |
Expect.isNotNull(libraries, "No libraries map returned"); |
Expect.isFalse(libraries.isEmpty, "Empty libraries map returned"); |
- var helperLibrary = findMirror(libraries.values, "mirrors_helper"); |
+ var helperLibrary = findMirror(libraries.values, #mirrors_helper); |
Expect.isNotNull(helperLibrary, "Library 'mirrors_helper' not found"); |
- Expect.stringEquals("mirrors_helper", helperLibrary.simpleName, |
+ Expect.equals(#mirrors_helper, helperLibrary.simpleName, |
"Unexpected library simple name"); |
- Expect.stringEquals("mirrors_helper", helperLibrary.qualifiedName, |
+ Expect.equals(#mirrors_helper, helperLibrary.qualifiedName, |
"Unexpected library qualified name"); |
- Expect.equals(helperLibrary, mirrors.findLibrary('mirrors_helper')); |
+ Expect.equals(helperLibrary, mirrors.findLibrary(#mirrors_helper)); |
var helperLibraryLocation = helperLibrary.location; |
Expect.isNotNull(helperLibraryLocation); |
@@ -80,26 +80,18 @@ void test(MirrorSystem mirrors) { |
Expect.equals(1, helperLibraryLocation.column, "Unexpected column"); |
- var classes = helperLibrary.classes; |
- Expect.isNotNull(classes, "No classes map returned"); |
- Expect.isFalse(classes.isEmpty, "Empty classes map returned"); |
+ var declarations = helperLibrary.declarations; |
+ Expect.isNotNull(declarations, "No declarations map returned"); |
+ Expect.isFalse(declarations.isEmpty, "Empty declarations map returned"); |
- testFoo(mirrors, helperLibrary, classes); |
- testBar(mirrors, helperLibrary, classes); |
- testBaz(mirrors, helperLibrary, classes); |
+ testFoo(mirrors, helperLibrary, declarations); |
+ testBar(mirrors, helperLibrary, declarations); |
+ testBaz(mirrors, helperLibrary, declarations); |
// TODO(johnniwinther): Add test of class [Boz] and typedef [Func]. |
// TODO(johnniwinther): Add tests of type argument substitution, which |
// is not currently implemented in dart2js. |
// TODO(johnniwinther): Add tests of Location and Source. |
- testPrivate(mirrors, helperLibrary, classes); |
- // TODO(johnniwinther): Add thorough tests of [LibraryMirror.functions], |
- // [LibraryMirror.getters], [LibraryMirror.setters], [LibraryMirror.members], |
- // and [LibraryMirror.variable]. |
- Expect.isNotNull(helperLibrary.functions); |
- Expect.isNotNull(helperLibrary.members); |
- Expect.isNotNull(helperLibrary.getters); |
- Expect.isNotNull(helperLibrary.setters); |
- Expect.isNotNull(helperLibrary.variables); |
+ testPrivate(mirrors, helperLibrary, declarations); |
} |
// Testing class Foo: |
@@ -108,77 +100,61 @@ void test(MirrorSystem mirrors) { |
// |
// } |
void testFoo(MirrorSystem system, LibraryMirror helperLibrary, |
- Map<String,TypeMirror> classes) { |
- var fooClass = classes["Foo"]; |
+ Map<Symbol, DeclarationMirror> declarations) { |
+ var fooClass = declarations[#Foo]; |
Expect.isNotNull(fooClass, "Type 'Foo' not found"); |
Expect.isTrue(fooClass is ClassMirror, |
"Unexpected mirror type returned"); |
- Expect.stringEquals("Foo", fooClass.simpleName, |
+ Expect.equals(#Foo, fooClass.simpleName, |
"Unexpected type simple name"); |
- Expect.stringEquals("mirrors_helper.Foo", fooClass.qualifiedName, |
+ Expect.equals(#mirrors_helper.Foo, fooClass.qualifiedName, |
"Unexpected type qualified name"); |
- Expect.equals(helperLibrary, fooClass.library, |
+ Expect.equals(helperLibrary, getLibrary(fooClass), |
"Unexpected library returned from type"); |
- Expect.isFalse(fooClass.isObject, "Class is Object"); |
+ Expect.isFalse(isObject(fooClass), "Class is Object"); |
Expect.isFalse(fooClass.isDynamic, "Class is dynamic"); |
Expect.isFalse(fooClass.isVoid, "Class is void"); |
- Expect.isFalse(fooClass.isTypeVariable, "Class is a type variable"); |
- Expect.isFalse(fooClass.isTypedef, "Class is a typedef"); |
- Expect.isFalse(fooClass.isFunction, "Class is a function"); |
+ Expect.isFalse(fooClass is TypeVariableMirror, "Class is a type variable"); |
+ Expect.isFalse(fooClass is TypedefMirror, "Class is a typedef"); |
+ Expect.isFalse(fooClass is FunctionTypeMirror, "Class is a function"); |
Expect.isTrue(fooClass.isOriginalDeclaration); |
Expect.equals(fooClass, fooClass.originalDeclaration); |
- Expect.isTrue(fooClass.isClass, "Class is not class"); |
+ Expect.isTrue(fooClass is ClassMirror, "Class is not class"); |
Expect.isFalse(fooClass.isAbstract); |
Expect.isFalse(fooClass.isPrivate, "Class is private"); |
var objectType = fooClass.superclass; |
Expect.isNotNull(objectType, "Superclass is null"); |
- Expect.isTrue(objectType.isObject, "Object is not Object"); |
- Expect.isFalse(objectType.isOriginalDeclaration); |
+ Expect.isTrue(isObject(objectType), "Object is not Object"); |
+ Expect.isTrue(objectType.isOriginalDeclaration); |
Expect.isTrue(containsType(fooClass, |
- computeSubdeclarations(objectType)), |
+ computeSubdeclarations(system, objectType)), |
"Class is not subclass of superclass"); |
var fooInterfaces = fooClass.superinterfaces; |
Expect.isNotNull(fooInterfaces, "Interfaces map is null"); |
Expect.isTrue(fooInterfaces.isEmpty, "Interfaces map is not empty"); |
- var fooSubdeclarations = computeSubdeclarations(fooClass); |
+ var fooSubdeclarations = computeSubdeclarations(system, fooClass); |
Expect.equals(1, count(fooSubdeclarations), "Unexpected subtype count"); |
for (var fooSubdeclaration in fooSubdeclarations) { |
Expect.equals(fooClass, fooSubdeclaration.superclass.originalDeclaration); |
} |
- Expect.throws(() => fooClass.typeArguments, |
- (exception) => true, |
- "Class has type arguments"); |
+ Expect.isTrue(fooClass.typeArguments.isEmpty); |
var fooClassTypeVariables = fooClass.typeVariables; |
Expect.isNotNull(fooClassTypeVariables, "Type variable list is null"); |
Expect.isTrue(fooClassTypeVariables.isEmpty, |
"Type variable list is not empty"); |
- var fooClassMembers = fooClass.members; |
+ var fooClassMembers = fooClass.declarations; |
Expect.isNotNull(fooClassMembers, "Declared members map is null"); |
Expect.isTrue(fooClassMembers.isEmpty, "Declared members map is unempty"); |
- var fooClassConstructors = fooClass.constructors; |
- Expect.isNotNull(fooClassConstructors, "Constructors map is null"); |
- Expect.isTrue(fooClassConstructors.isEmpty, |
- "Constructors map is unempty"); |
- |
- // TODO(johnniwinther): Add thorough tests of [ClassMirror.functions], |
- // [ClassMirror.getters], [ClassMirror.setters], [ClassMirror.members], |
- // and [ClassMirror.variable]. |
- Expect.isNotNull(fooClass.functions); |
- Expect.isNotNull(fooClass.members); |
- Expect.isNotNull(fooClass.getters); |
- Expect.isNotNull(fooClass.setters); |
- Expect.isNotNull(fooClass.variables); |
- |
////////////////////////////////////////////////////////////////////////////// |
// Metadata tests |
////////////////////////////////////////////////////////////////////////////// |
@@ -191,7 +167,7 @@ void testFoo(MirrorSystem system, LibraryMirror helperLibrary, |
var dartMirrorsLibrary = system.libraries[DART_MIRRORS_URI]; |
Expect.isNotNull(dartMirrorsLibrary); |
- var commentType = dartMirrorsLibrary.classes['Comment']; |
+ var commentType = dartMirrorsLibrary.declarations[#Comment]; |
Expect.isNotNull(commentType); |
// /// Singleline doc comment. |
@@ -215,7 +191,7 @@ void testFoo(MirrorSystem system, LibraryMirror helperLibrary, |
Expect.isTrue(metadata is TypeInstanceMirror); |
var metadataType = metadata.representedType; |
Expect.isNotNull(metadataType); |
- Expect.stringEquals('Metadata', metadataType.simpleName); |
+ Expect.equals(#Metadata, metadataType.simpleName); |
// // This is intentionally the type literal. |
metadata = metadataList[metadataListIndex++]; |
@@ -262,7 +238,7 @@ void testFoo(MirrorSystem system, LibraryMirror helperLibrary, |
Expect.isFalse(metadata.hasReflectee); |
Expect.throws(() => metadata.reflectee, (_) => true); |
Expect.equals(metadataType.originalDeclaration, metadata.type); |
- InstanceMirror data = metadata.getField('data'); |
+ InstanceMirror data = metadata.getField(#data); |
Expect.isNotNull(data); |
Expect.isTrue(data.hasReflectee); |
Expect.isNull(data.reflectee); |
@@ -273,7 +249,7 @@ void testFoo(MirrorSystem system, LibraryMirror helperLibrary, |
Expect.isFalse(metadata.hasReflectee); |
Expect.throws(() => metadata.reflectee, (_) => true); |
Expect.equals(metadataType.originalDeclaration, metadata.type); |
- data = metadata.getField('data'); |
+ data = metadata.getField(#data); |
Expect.isNotNull(data); |
Expect.isTrue(data.hasReflectee); |
Expect.isTrue(data.reflectee); |
@@ -284,7 +260,7 @@ void testFoo(MirrorSystem system, LibraryMirror helperLibrary, |
Expect.isFalse(metadata.hasReflectee); |
Expect.throws(() => metadata.reflectee, (_) => true); |
Expect.equals(metadataType.originalDeclaration, metadata.type); |
- data = metadata.getField('data'); |
+ data = metadata.getField(#data); |
Expect.isNotNull(data); |
Expect.isTrue(data.hasReflectee); |
Expect.isFalse(data.reflectee); |
@@ -295,7 +271,7 @@ void testFoo(MirrorSystem system, LibraryMirror helperLibrary, |
Expect.isFalse(metadata.hasReflectee); |
Expect.throws(() => metadata.reflectee, (_) => true); |
Expect.equals(metadataType.originalDeclaration, metadata.type); |
- data = metadata.getField('data'); |
+ data = metadata.getField(#data); |
Expect.isNotNull(data); |
Expect.isTrue(data.hasReflectee); |
Expect.equals(0, data.reflectee); |
@@ -306,7 +282,7 @@ void testFoo(MirrorSystem system, LibraryMirror helperLibrary, |
Expect.isFalse(metadata.hasReflectee); |
Expect.throws(() => metadata.reflectee, (_) => true); |
Expect.equals(metadataType.originalDeclaration, metadata.type); |
- data = metadata.getField('data'); |
+ data = metadata.getField(#data); |
Expect.isNotNull(data); |
Expect.isTrue(data.hasReflectee); |
Expect.equals(1.5, data.reflectee); |
@@ -317,7 +293,7 @@ void testFoo(MirrorSystem system, LibraryMirror helperLibrary, |
Expect.isFalse(metadata.hasReflectee); |
Expect.throws(() => metadata.reflectee, (_) => true); |
Expect.equals(metadataType.originalDeclaration, metadata.type); |
- data = metadata.getField('data'); |
+ data = metadata.getField(#data); |
Expect.isNotNull(data); |
Expect.isTrue(data.hasReflectee); |
Expect.stringEquals("Foo", data.reflectee); |
@@ -328,13 +304,13 @@ void testFoo(MirrorSystem system, LibraryMirror helperLibrary, |
Expect.isFalse(metadata.hasReflectee); |
Expect.throws(() => metadata.reflectee, (_) => true); |
Expect.equals(metadataType.originalDeclaration, metadata.type); |
- data = metadata.getField('data'); |
+ data = metadata.getField(#data); |
Expect.isTrue(data is ListInstanceMirror); |
Expect.isFalse(data.hasReflectee); |
Expect.throws(() => data.reflectee, (_) => true); |
ListInstanceMirror listData = data; |
Expect.equals(1, listData.length); |
- InstanceMirror element = listData[0]; |
+ InstanceMirror element = listData.getElement(0); |
Expect.isNotNull(element); |
Expect.isTrue(element.hasReflectee); |
Expect.stringEquals("Foo", element.reflectee); |
@@ -345,7 +321,7 @@ void testFoo(MirrorSystem system, LibraryMirror helperLibrary, |
Expect.isFalse(metadata.hasReflectee); |
Expect.throws(() => metadata.reflectee, (_) => true); |
Expect.equals(metadataType.originalDeclaration, metadata.type); |
- data = metadata.getField('data'); |
+ data = metadata.getField(#data); |
Expect.isTrue(data is MapInstanceMirror); |
Expect.isFalse(data.hasReflectee); |
Expect.throws(() => data.reflectee, (_) => true); |
@@ -354,11 +330,11 @@ void testFoo(MirrorSystem system, LibraryMirror helperLibrary, |
var it = mapData.keys.iterator; |
Expect.isTrue(it.moveNext()); |
Expect.stringEquals('foo', it.current); |
- element = mapData['foo']; |
+ element = mapData.getValue('foo'); |
Expect.isNotNull(element); |
Expect.isTrue(element.hasReflectee); |
Expect.stringEquals("Foo", element.reflectee); |
- Expect.isNull(mapData['bar']); |
+ Expect.isNull(mapData.getValue('bar')); |
// @metadata |
metadata = metadataList[metadataListIndex++]; |
@@ -366,7 +342,7 @@ void testFoo(MirrorSystem system, LibraryMirror helperLibrary, |
Expect.isFalse(metadata.hasReflectee); |
Expect.throws(() => metadata.reflectee, (_) => true); |
Expect.equals(metadataType.originalDeclaration, metadata.type); |
- data = metadata.getField('data'); |
+ data = metadata.getField(#data); |
Expect.isNotNull(data); |
Expect.isTrue(data.hasReflectee); |
Expect.isNull(data.reflectee); |
@@ -421,46 +397,46 @@ void testFoo(MirrorSystem system, LibraryMirror helperLibrary, |
// |
// } |
void testBar(MirrorSystem system, LibraryMirror helperLibrary, |
- Map<String,TypeMirror> classes) { |
- var barClass = classes["Bar"]; |
+ Map<Symbol, DeclarationMirror> classes) { |
+ var barClass = classes[#Bar]; |
Expect.isNotNull(barClass, "Type 'Bar' not found"); |
Expect.isTrue(barClass is ClassMirror, |
"Unexpected mirror type returned"); |
- Expect.stringEquals("Bar", barClass.simpleName, |
+ Expect.equals(#Bar, barClass.simpleName, |
"Unexpected type simple name"); |
- Expect.stringEquals("mirrors_helper.Bar", barClass.qualifiedName, |
- "Unexpected type qualified name"); |
+ Expect.equals(#mirrors_helper.Bar, barClass.qualifiedName, |
+ "Unexpected type qualified name"); |
- Expect.equals(helperLibrary, barClass.library, |
+ Expect.equals(helperLibrary, getLibrary(barClass), |
"Unexpected library returned from type"); |
- Expect.isFalse(barClass.isObject, "Interface is Object"); |
+ Expect.isFalse(isObject(barClass), "Interface is Object"); |
Expect.isFalse(barClass.isDynamic, "Interface is dynamic"); |
Expect.isFalse(barClass.isVoid, "Interface is void"); |
- Expect.isFalse(barClass.isTypeVariable, "Interface is a type variable"); |
- Expect.isFalse(barClass.isTypedef, "Interface is a typedef"); |
- Expect.isFalse(barClass.isFunction, "Interface is a function"); |
+ Expect.isFalse(barClass is TypeVariableMirror, "Interface is a type variable"); |
+ Expect.isFalse(barClass is TypedefMirror, "Interface is a typedef"); |
+ Expect.isFalse(barClass is FunctionTypeMirror, "Interface is a function"); |
Expect.isTrue(barClass.isOriginalDeclaration); |
Expect.equals(barClass, barClass.originalDeclaration); |
- Expect.isTrue(barClass.isClass); |
+ Expect.isTrue(barClass is ClassMirror); |
Expect.isTrue(barClass.isAbstract); |
Expect.isFalse(barClass.isPrivate, "Interface is private"); |
var objectType = barClass.superclass; |
Expect.isNotNull(objectType, "Superclass is null"); |
- Expect.isTrue(objectType.isObject, "Object is not Object"); |
- Expect.isFalse(objectType.isOriginalDeclaration); |
+ Expect.isTrue(isObject(objectType), "Object is not Object"); |
+ Expect.isTrue(objectType.isOriginalDeclaration); |
Expect.isTrue(containsType(barClass, |
- computeSubdeclarations(objectType)), |
+ computeSubdeclarations(system, objectType)), |
"Class is not subclass of superclass"); |
var barInterfaces = barClass.superinterfaces; |
Expect.isNotNull(barInterfaces, "Interfaces map is null"); |
Expect.isTrue(barInterfaces.isEmpty, "Interfaces map is not empty"); |
- var barSubdeclarations = computeSubdeclarations(barClass); |
+ var barSubdeclarations = computeSubdeclarations(system, barClass); |
Expect.equals(1, count(barSubdeclarations), "Unexpected subtype count"); |
for (var barSubdeclaration in barSubdeclarations) { |
Expect.isTrue(containsType(barClass, |
@@ -468,9 +444,7 @@ void testBar(MirrorSystem system, LibraryMirror helperLibrary, |
"Interface is not superinterface of subclass"); |
} |
- Expect.throws(() => barClass.typeArguments, |
- (exception) => true, |
- "Interface has type arguments"); |
+ Expect.isTrue(barClass.typeArguments.isEmpty); |
var barInterfaceTypeVariables = barClass.typeVariables; |
Expect.isNotNull(barInterfaceTypeVariables, "Type variable list is null"); |
Expect.isFalse(barInterfaceTypeVariables.isEmpty, |
@@ -480,17 +454,12 @@ void testBar(MirrorSystem system, LibraryMirror helperLibrary, |
var barE = barInterfaceTypeVariables[0]; |
Expect.isNotNull(barE, "Type variable is null"); |
- Expect.isTrue(barE.isTypeVariable, "Type variable is not type variable"); |
+ Expect.isTrue(barE is TypeVariableMirror); |
- var barInterfaceMembers = barClass.members; |
+ var barInterfaceMembers = barClass.declarations; |
Expect.isNotNull(barInterfaceMembers, "Declared members map is null"); |
Expect.isTrue(barInterfaceMembers.isEmpty, |
- "Declared members map is unempty"); |
- |
- var barInterfaceConstructors = barClass.constructors; |
- Expect.isNotNull(barInterfaceConstructors, "Constructors map is null"); |
- Expect.isTrue(barInterfaceConstructors.isEmpty, |
- "Constructors map is unempty"); |
+ "Declarations map is unempty"); |
var metadata = barClass.metadata; |
Expect.isNotNull(metadata); |
@@ -512,39 +481,39 @@ void testBar(MirrorSystem system, LibraryMirror helperLibrary, |
// int operator -() => 0; |
// } |
void testBaz(MirrorSystem system, LibraryMirror helperLibrary, |
- Map<String,TypeMirror> classes) { |
- var bazClass = classes["Baz"]; |
+ Map<Symbol, DeclarationMirror> declarations) { |
+ var bazClass = declarations[#Baz]; |
Expect.isNotNull(bazClass, "Type 'Baz' not found"); |
Expect.isTrue(bazClass is ClassMirror, |
"Unexpected mirror type returned"); |
- Expect.stringEquals("Baz", bazClass.simpleName, |
- "Unexpected type simple name"); |
- Expect.stringEquals("mirrors_helper.Baz", bazClass.qualifiedName, |
- "Unexpected type qualified name"); |
+ Expect.equals(#Baz, bazClass.simpleName, |
+ "Unexpected type simple name"); |
+ Expect.equals(#mirrors_helper.Baz, bazClass.qualifiedName, |
+ "Unexpected type qualified name"); |
- Expect.equals(helperLibrary, bazClass.library, |
+ Expect.equals(helperLibrary, getLibrary(bazClass), |
"Unexpected library returned from type"); |
- Expect.isFalse(bazClass.isObject, "Class is Object"); |
+ Expect.isFalse(isObject(bazClass), "Class is Object"); |
Expect.isFalse(bazClass.isDynamic, "Class is dynamic"); |
Expect.isFalse(bazClass.isVoid, "Class is void"); |
- Expect.isFalse(bazClass.isTypeVariable, "Class is a type variable"); |
- Expect.isFalse(bazClass.isTypedef, "Class is a typedef"); |
- Expect.isFalse(bazClass.isFunction, "Class is a function"); |
+ Expect.isFalse(bazClass is TypeVariableMirror, "Class is a type variable"); |
+ Expect.isFalse(bazClass is TypedefMirror, "Class is a typedef"); |
+ Expect.isFalse(bazClass is FunctionTypeMirror, "Class is a function"); |
Expect.isTrue(bazClass.isOriginalDeclaration); |
Expect.equals(bazClass, bazClass.originalDeclaration); |
- Expect.isTrue(bazClass.isClass, "Class is not class"); |
+ Expect.isTrue(bazClass is ClassMirror, "Class is not class"); |
Expect.isFalse(bazClass.isAbstract); |
Expect.isFalse(bazClass.isPrivate, "Class is private"); |
var objectType = bazClass.superclass; |
Expect.isNotNull(objectType, "Superclass is null"); |
- Expect.isTrue(objectType.isObject, "Object is not Object"); |
- Expect.isFalse(objectType.isOriginalDeclaration); |
+ Expect.isTrue(isObject(objectType), "Object is not Object"); |
+ Expect.isTrue(objectType.isOriginalDeclaration); |
Expect.isTrue(containsType(bazClass, |
- computeSubdeclarations(objectType)), |
+ computeSubdeclarations(system, objectType)), |
"Class is not subclass of superclass"); |
var bazInterfaces = bazClass.superinterfaces; |
@@ -552,14 +521,14 @@ void testBaz(MirrorSystem system, LibraryMirror helperLibrary, |
Expect.isTrue(!bazInterfaces.isEmpty, "Interfaces map is empty"); |
for (var bazInterface in bazInterfaces) { |
Expect.isTrue(containsType(bazClass, |
- computeSubdeclarations(objectType)), |
+ computeSubdeclarations(system, objectType)), |
"Class is not subclass of superinterface"); |
} |
- var bazSubdeclarations = computeSubdeclarations(bazClass); |
+ var bazSubdeclarations = computeSubdeclarations(system, bazClass); |
Expect.equals(0, count(bazSubdeclarations), "Unexpected subtype count"); |
- var barInterface = findMirror(bazInterfaces, "Bar"); |
+ var barInterface = findMirror(bazInterfaces, #Bar); |
Expect.isNotNull(barInterface, "Interface bar is missing"); |
Expect.isFalse(barInterface.isOriginalDeclaration); |
var barInterfaceTypeArguments = barInterface.typeArguments; |
@@ -567,9 +536,7 @@ void testBaz(MirrorSystem system, LibraryMirror helperLibrary, |
Expect.equals(1, barInterfaceTypeArguments.length, |
"Type arguments is empty"); |
- Expect.throws(() => bazClass.typeArguments, |
- (exception) => true, |
- "Class has type arguments"); |
+ Expect.isTrue(bazClass.typeArguments.isEmpty, "Class has type arguments"); |
var bazClassTypeVariables = bazClass.typeVariables; |
Expect.isNotNull(bazClassTypeVariables, "Type variable list is null"); |
Expect.equals(2, bazClassTypeVariables.length, |
@@ -577,29 +544,29 @@ void testBaz(MirrorSystem system, LibraryMirror helperLibrary, |
var bazE = bazClassTypeVariables[0]; |
Expect.isNotNull(bazE, "Type variable is null"); |
- Expect.stringEquals('E', bazE.simpleName, "Unexpected simpleName"); |
- Expect.stringEquals('mirrors_helper.Baz.E', bazE.qualifiedName, |
- "Unexpected qualifiedName"); |
- Expect.equals(bazClass, bazE.declarer, |
+ Expect.equals(#E, bazE.simpleName, "Unexpected simpleName"); |
+ Expect.equals(#mirrors_helper.Baz.E, bazE.qualifiedName, |
+ "Unexpected qualifiedName"); |
+ Expect.equals(bazClass, bazE.owner, |
"Unexpected type variable declarer"); |
var bazEbound = bazE.upperBound; |
Expect.isNotNull(bazEbound); |
- Expect.isFalse(bazEbound.isOriginalDeclaration); |
- Expect.isTrue(bazEbound.isObject, "Bound is not object"); |
+ Expect.isTrue(bazEbound.isOriginalDeclaration); |
+ Expect.isTrue(isObject(bazEbound), "Bound is not object"); |
var bazF = bazClassTypeVariables[1]; |
Expect.isNotNull(bazF, "Type variable is null"); |
- Expect.stringEquals('F', bazF.simpleName, "Unexpected simpleName"); |
- Expect.stringEquals('mirrors_helper.Baz.F', bazF.qualifiedName, |
- "Unexpected qualifiedName"); |
- Expect.equals(bazClass, bazF.declarer); |
+ Expect.equals(#F, bazF.simpleName, "Unexpected simpleName"); |
+ Expect.equals(#mirrors_helper.Baz.F, bazF.qualifiedName, |
+ "Unexpected qualifiedName"); |
+ Expect.equals(bazClass, bazF.owner); |
var bazFbound = bazF.upperBound; |
Expect.isNotNull(bazFbound); |
- Expect.isFalse(bazFbound.isOriginalDeclaration); |
- Expect.stringEquals("mirrors_helper.Foo", bazFbound.qualifiedName, |
- "Bound is not Foo"); |
+ Expect.isTrue(bazFbound.isOriginalDeclaration); |
+ Expect.equals(#mirrors_helper.Foo, bazFbound.qualifiedName, |
+ "Bound is not Foo"); |
- var bazClassMembers = bazClass.members; |
+ var bazClassMembers = bazClass.declarations; |
Expect.isNotNull(bazClassMembers, "Declared members map is null"); |
Expect.equals(8, bazClassMembers.length, |
"Unexpected number of declared members"); |
@@ -607,20 +574,16 @@ void testBaz(MirrorSystem system, LibraryMirror helperLibrary, |
//////////////////////////////////////////////////////////////////////////// |
// static method1(e) {} |
//////////////////////////////////////////////////////////////////////////// |
- var method1 = bazClassMembers["method1"]; |
+ var method1 = bazClassMembers[#method1]; |
Expect.isNotNull(method1, "method1 not found"); |
- Expect.stringEquals('method1', method1.simpleName, |
- "Unexpected method simpleName"); |
- Expect.stringEquals('mirrors_helper.Baz.method1', method1.qualifiedName, |
- "Unexpected method qualifiedName"); |
+ Expect.equals(#method1, method1.simpleName); |
+ Expect.equals(#mirrors_helper.Baz.method1, method1.qualifiedName); |
Expect.equals(method1.owner, bazClass); |
Expect.isFalse(method1.isTopLevel); |
+ Expect.isTrue(method1 is MethodMirror); |
Expect.isFalse(method1.isConstructor); |
- Expect.isFalse(method1.isVariable); |
- Expect.isTrue(method1.isMethod); |
Expect.isFalse(method1.isPrivate); |
Expect.isTrue(method1.isStatic); |
- Expect.isTrue(method1 is MethodMirror); |
Expect.isTrue(method1.isRegularMethod); |
Expect.isFalse(method1.isConstConstructor); |
Expect.isFalse(method1.isGenerativeConstructor); |
@@ -632,12 +595,12 @@ void testBaz(MirrorSystem system, LibraryMirror helperLibrary, |
var dynamicType = method1.returnType; |
Expect.isNotNull(dynamicType, "Return type was null"); |
- Expect.isFalse(dynamicType.isObject, "dynamic is Object"); |
+ Expect.isFalse(isObject(dynamicType), "dynamic is Object"); |
Expect.isTrue(dynamicType.isDynamic, "dynamic is not dynamic"); |
Expect.isFalse(dynamicType.isVoid, "dynamic is void"); |
- Expect.isFalse(dynamicType.isTypeVariable, "dynamic is a type variable"); |
- Expect.isFalse(dynamicType.isTypedef, "dynamic is a typedef"); |
- Expect.isFalse(dynamicType.isFunction, "dynamic is a function"); |
+ Expect.isFalse(dynamicType is TypeVariableMirror, "dynamic is a type variable"); |
+ Expect.isFalse(dynamicType is TypedefMirror, "dynamic is a typedef"); |
+ Expect.isFalse(dynamicType is FunctionTypeMirror, "dynamic is a function"); |
var method1Parameters = method1.parameters; |
Expect.isNotNull(method1Parameters, "Method parameters is null"); |
@@ -645,11 +608,8 @@ void testBaz(MirrorSystem system, LibraryMirror helperLibrary, |
var method1Parameter1 = method1Parameters[0]; |
Expect.isNotNull(method1Parameter1, "Parameter is null"); |
Expect.equals(dynamicType, method1Parameter1.type); |
- Expect.stringEquals("e", method1Parameter1.simpleName, |
- "Unexpected parameter simpleName"); |
- Expect.stringEquals("mirrors_helper.Baz.method1#e", |
- method1Parameter1.qualifiedName, |
- "Unexpected parameter qualifiedName"); |
+ Expect.equals(#e, method1Parameter1.simpleName); |
+ Expect.equals(#mirrors_helper.Baz.method1.e, method1Parameter1.qualifiedName); |
Expect.isFalse(method1Parameter1.hasDefaultValue, |
"Parameter has default value"); |
Expect.isNull(method1Parameter1.defaultValue, |
@@ -659,20 +619,16 @@ void testBaz(MirrorSystem system, LibraryMirror helperLibrary, |
//////////////////////////////////////////////////////////////////////////// |
// static void method2(E e, [F f = null]) {} |
//////////////////////////////////////////////////////////////////////////// |
- var method2 = bazClassMembers["method2"]; |
+ var method2 = bazClassMembers[#method2]; |
Expect.isNotNull(method2, "method2 not found"); |
- Expect.stringEquals('method2', method2.simpleName, |
- "Unexpected method simpleName"); |
- Expect.stringEquals('mirrors_helper.Baz.method2', method2.qualifiedName, |
- "Unexpected method qualifiedName"); |
+ Expect.equals(#method2, method2.simpleName); |
+ Expect.equals(#mirrors_helper.Baz.method2, method2.qualifiedName); |
Expect.equals(method2.owner, bazClass); |
Expect.isFalse(method2.isTopLevel); |
+ Expect.isTrue(method2 is MethodMirror); |
Expect.isFalse(method2.isConstructor); |
- Expect.isFalse(method2.isVariable); |
- Expect.isTrue(method2.isMethod); |
Expect.isFalse(method2.isPrivate); |
Expect.isFalse(method2.isStatic); |
- Expect.isTrue(method2 is MethodMirror); |
Expect.isTrue(method2.isRegularMethod); |
Expect.isFalse(method2.isConstConstructor); |
Expect.isFalse(method2.isGenerativeConstructor); |
@@ -684,12 +640,12 @@ void testBaz(MirrorSystem system, LibraryMirror helperLibrary, |
var voidType = method2.returnType; |
Expect.isNotNull(voidType, "Return type was null"); |
- Expect.isFalse(voidType.isObject, "void is Object"); |
+ Expect.isFalse(isObject(voidType), "void is Object"); |
Expect.isFalse(voidType.isDynamic, "void is dynamic"); |
Expect.isTrue(voidType.isVoid, "void is not void"); |
- Expect.isFalse(voidType.isTypeVariable, "void is a type variable"); |
- Expect.isFalse(voidType.isTypedef, "void is a typedef"); |
- Expect.isFalse(voidType.isFunction, "void is a function"); |
+ Expect.isFalse(voidType is TypeVariableMirror, "void is a type variable"); |
+ Expect.isFalse(voidType is TypedefMirror, "void is a typedef"); |
+ Expect.isFalse(voidType is FunctionTypeMirror, "void is a function"); |
var method2Parameters = method2.parameters; |
Expect.isNotNull(method2Parameters, "Method parameters is null"); |
@@ -697,11 +653,8 @@ void testBaz(MirrorSystem system, LibraryMirror helperLibrary, |
var method2Parameter1 = method2Parameters[0]; |
Expect.isNotNull(method2Parameter1, "Parameter is null"); |
Expect.equals(bazE, method2Parameter1.type); |
- Expect.stringEquals("e", method2Parameter1.simpleName, |
- "Unexpected parameter simpleName"); |
- Expect.stringEquals("mirrors_helper.Baz.method2#e", |
- method2Parameter1.qualifiedName, |
- "Unexpected parameter qualifiedName"); |
+ Expect.equals(#e, method2Parameter1.simpleName); |
+ Expect.equals(#mirrors_helper.Baz.method2.e, method2Parameter1.qualifiedName); |
Expect.isFalse(method2Parameter1.hasDefaultValue, |
"Parameter has default value"); |
Expect.isNull(method2Parameter1.defaultValue, |
@@ -710,34 +663,28 @@ void testBaz(MirrorSystem system, LibraryMirror helperLibrary, |
var method2Parameter2 = method2Parameters[1]; |
Expect.isNotNull(method2Parameter2, "Parameter is null"); |
Expect.equals(bazF, method2Parameter2.type); |
- Expect.stringEquals("f", method2Parameter2.simpleName, |
- "Unexpected parameter simpleName"); |
- Expect.stringEquals("mirrors_helper.Baz.method2#f", |
- method2Parameter2.qualifiedName, |
- "Unexpected parameter qualifiedName"); |
+ Expect.equals(#f, method2Parameter2.simpleName); |
+ Expect.equals(#mirrors_helper.Baz.method2.f, |
+ method2Parameter2.qualifiedName); |
Expect.isTrue(method2Parameter2.hasDefaultValue, |
"Parameter has default value"); |
- Expect.stringEquals("null", method2Parameter2.defaultValue, |
- "Parameter default value is non-null"); |
+ Expect.isNotNull(method2Parameter2.defaultValue, |
+ "Parameter default value is null"); |
Expect.isTrue(method2Parameter2.isOptional, "Parameter is not optional"); |
//////////////////////////////////////////////////////////////////////////// |
// Baz<E,F> method3(E func1(F f), Func<E,F> func2) => null; |
//////////////////////////////////////////////////////////////////////////// |
- var method3 = bazClassMembers["method3"]; |
+ var method3 = bazClassMembers[#method3]; |
Expect.isNotNull(method3, "method3 not found"); |
- Expect.stringEquals('method3', method3.simpleName, |
- "Unexpected method simpleName"); |
- Expect.stringEquals('mirrors_helper.Baz.method3', method3.qualifiedName, |
- "Unexpected method qualifiedName"); |
+ Expect.equals(#method3, method3.simpleName); |
+ Expect.equals(#mirrors_helper.Baz.method3, method3.qualifiedName); |
Expect.equals(method3.owner, bazClass); |
Expect.isFalse(method3.isTopLevel); |
+ Expect.isTrue(method3 is MethodMirror); |
Expect.isFalse(method3.isConstructor); |
- Expect.isFalse(method3.isVariable); |
- Expect.isTrue(method3.isMethod); |
Expect.isFalse(method3.isPrivate); |
Expect.isFalse(method3.isStatic); |
- Expect.isTrue(method3 is MethodMirror); |
Expect.isTrue(method3.isRegularMethod); |
Expect.isFalse(method3.isConstConstructor); |
Expect.isFalse(method3.isGenerativeConstructor); |
@@ -773,15 +720,12 @@ void testBaz(MirrorSystem system, LibraryMirror helperLibrary, |
"Return type of 'func1' is not a E"); |
Expect.isNotNull(method3Parameter1type.parameters[0], |
"Parameter 1 of 'func1' is null"); |
- Expect.stringEquals('f', method3Parameter1type.parameters[0].simpleName, |
- "Unexpected name parameter 1 of 'func1'"); |
+ Expect.equals(#f, method3Parameter1type.parameters[0].simpleName); |
Expect.equals(bazF, method3Parameter1type.parameters[0].type, |
"Argument type of 'func1' is not a F"); |
- Expect.stringEquals("func1", method3Parameter1.simpleName, |
- "Unexpected parameter simpleName"); |
- Expect.stringEquals("mirrors_helper.Baz.method3#func1", |
- method3Parameter1.qualifiedName, |
- "Unexpected parameter qualifiedName"); |
+ Expect.equals(#func1, method3Parameter1.simpleName); |
+ Expect.equals(#mirrors_helper.Baz.method3.func1, |
+ method3Parameter1.qualifiedName); |
Expect.isFalse(method3Parameter1.hasDefaultValue, |
"Parameter has default value"); |
Expect.isNull(method3Parameter1.defaultValue, |
@@ -792,48 +736,33 @@ void testBaz(MirrorSystem system, LibraryMirror helperLibrary, |
Expect.isNotNull(method3Parameter2, "Parameter is null"); |
var funcTypedef = method3Parameter2.type; |
Expect.isNotNull(funcTypedef, "Parameter type is null"); |
- Expect.stringEquals("Func", funcTypedef.simpleName, |
- "Unexpected simpleName"); |
- Expect.stringEquals("mirrors_helper.Func", funcTypedef.qualifiedName, |
- "Unexpected simpleName"); |
- Expect.isFalse(funcTypedef.isObject, "Typedef is Object"); |
+ Expect.equals(#Func, funcTypedef.simpleName); |
+ Expect.equals(#mirrors_helper.Func, funcTypedef.qualifiedName); |
+ Expect.isFalse(isObject(funcTypedef), "Typedef is Object"); |
Expect.isFalse(funcTypedef.isDynamic, "Typedef is dynamic"); |
Expect.isFalse(funcTypedef.isVoid, "Typedef is void"); |
- Expect.isFalse(funcTypedef.isTypeVariable, "Typedef is a type variable"); |
- Expect.isTrue(funcTypedef.isTypedef, "Typedef is not a typedef"); |
- Expect.isFalse(funcTypedef.isFunction, "Typedef is a function"); |
+ Expect.isFalse(funcTypedef is TypeVariableMirror, "Typedef is a type variable"); |
+ Expect.isTrue(funcTypedef is TypedefMirror, "Typedef is not a typedef"); |
+ Expect.isFalse(funcTypedef is FunctionTypeMirror, "Typedef is a function"); |
- Expect.equals(helperLibrary, funcTypedef.library, |
+ Expect.equals(helperLibrary, getLibrary(funcTypedef), |
"Unexpected typedef library"); |
- Expect.isNull(funcTypedef.superclass, "Non-null superclass on typedef"); |
- Expect.isNotNull(funcTypedef.superinterfaces); |
- Expect.isTrue(funcTypedef.superinterfaces.isEmpty); |
- Expect.isNotNull(funcTypedef.members); |
- Expect.isTrue(funcTypedef.members.isEmpty); |
- |
- // TODO(johnniwinther): Returned typedef should not be the original |
- // declaration: |
- Expect.isTrue(funcTypedef.isOriginalDeclaration); |
- Expect.isFalse(funcTypedef.isClass, "Typedef is class"); |
+ |
+ Expect.isFalse(funcTypedef.isOriginalDeclaration); |
+ Expect.isFalse(funcTypedef is ClassMirror, "Typedef is class"); |
Expect.isFalse(funcTypedef.isPrivate, "Typedef is private"); |
- // TODO(johnniwinther): Should not throw an exception since the type should |
- // not be the original declaration. |
- Expect.throws(() => funcTypedef.typeArguments, |
- (exception) => true, |
- "Typedef has type arguments"); |
+ Expect.equals(2, funcTypedef.typeArguments.length); |
var funcTypedefTypeVariables = funcTypedef.typeVariables; |
Expect.isNotNull(funcTypedefTypeVariables); |
Expect.equals(2, funcTypedefTypeVariables.length); |
- var funcTypedefDefinition = funcTypedef.value; |
+ var funcTypedefDefinition = funcTypedef.referent; |
Expect.isNotNull(funcTypedefDefinition); |
Expect.isTrue(funcTypedefDefinition is FunctionTypeMirror); |
- Expect.stringEquals("func2", method3Parameter2.simpleName, |
- "Unexpected parameter simpleName"); |
- Expect.stringEquals("mirrors_helper.Baz.method3#func2", |
- method3Parameter2.qualifiedName, |
- "Unexpected parameter qualifiedName"); |
+ Expect.equals(#func2, method3Parameter2.simpleName); |
+ Expect.equals(#mirrors_helper.Baz.method3.func2, |
+ method3Parameter2.qualifiedName); |
Expect.isFalse(method3Parameter2.hasDefaultValue, |
"Parameter 'func2' has default value: " |
"${method3Parameter2.defaultValue}"); |
@@ -844,22 +773,20 @@ void testBaz(MirrorSystem system, LibraryMirror helperLibrary, |
//////////////////////////////////////////////////////////////////////////// |
// bool operator==(Object other) => false; |
//////////////////////////////////////////////////////////////////////////// |
- var operator_eq = bazClassMembers['==']; |
+ var operator_eq = bazClassMembers[const Symbol('==')]; |
Expect.isNotNull(operator_eq, "operator == not found"); |
- Expect.stringEquals('==', operator_eq.simpleName, |
- "Unexpected method simpleName"); |
+ Expect.equals(const Symbol('=='), operator_eq.simpleName, |
+ "Unexpected method simpleName"); |
Expect.stringEquals('operator ==', displayName(operator_eq)); |
- Expect.stringEquals('mirrors_helper.Baz.==', |
- operator_eq.qualifiedName, |
- "Unexpected method qualifiedName"); |
+ Expect.equals(const Symbol('mirrors_helper.Baz.=='), |
+ operator_eq.qualifiedName, |
+ "Unexpected method qualifiedName"); |
Expect.equals(operator_eq.owner, bazClass); |
Expect.isFalse(operator_eq.isTopLevel); |
+ Expect.isTrue(operator_eq is MethodMirror); |
Expect.isFalse(operator_eq.isConstructor); |
- Expect.isFalse(operator_eq.isVariable); |
- Expect.isTrue(operator_eq.isMethod); |
Expect.isFalse(operator_eq.isPrivate); |
Expect.isFalse(operator_eq.isStatic); |
- Expect.isTrue(operator_eq is MethodMirror); |
Expect.isTrue(operator_eq.isRegularMethod); |
Expect.isFalse(operator_eq.isConstConstructor); |
Expect.isFalse(operator_eq.isGenerativeConstructor); |
@@ -873,22 +800,20 @@ void testBaz(MirrorSystem system, LibraryMirror helperLibrary, |
//////////////////////////////////////////////////////////////////////////// |
// int operator -() => 0; |
//////////////////////////////////////////////////////////////////////////// |
- var operator_negate = bazClassMembers[Mirror.UNARY_MINUS]; |
+ var operator_negate = bazClassMembers[const Symbol('unary-')]; |
Expect.isNotNull(operator_negate, "operator < not found"); |
- Expect.stringEquals(Mirror.UNARY_MINUS, operator_negate.simpleName, |
+ Expect.equals(const Symbol('unary-'), operator_negate.simpleName, |
"Unexpected method simpleName"); |
Expect.stringEquals('operator -', displayName(operator_negate)); |
- Expect.stringEquals('mirrors_helper.Baz.${Mirror.UNARY_MINUS}', |
+ Expect.equals(const Symbol('mirrors_helper.Baz.unary-'), |
operator_negate.qualifiedName, |
"Unexpected method qualifiedName"); |
Expect.equals(operator_negate.owner, bazClass); |
Expect.isFalse(operator_negate.isTopLevel); |
+ Expect.isTrue(operator_negate is MethodMirror); |
Expect.isFalse(operator_negate.isConstructor); |
- Expect.isFalse(operator_negate.isVariable); |
- Expect.isTrue(operator_negate.isMethod); |
Expect.isFalse(operator_negate.isPrivate); |
Expect.isFalse(operator_negate.isStatic); |
- Expect.isTrue(operator_negate is MethodMirror); |
Expect.isTrue(operator_negate.isRegularMethod); |
Expect.isFalse(operator_negate.isConstConstructor); |
Expect.isFalse(operator_negate.isGenerativeConstructor); |
@@ -899,16 +824,10 @@ void testBaz(MirrorSystem system, LibraryMirror helperLibrary, |
Expect.isTrue(operator_negate.isOperator); |
Expect.stringEquals('-', operatorName(operator_negate)); |
- |
- var bazClassConstructors = bazClass.constructors; |
- Expect.isNotNull(bazClassConstructors, "Constructors map is null"); |
- Expect.equals(3, bazClassConstructors.length, |
- "Unexpected number of constructors"); |
- |
//////////////////////////////////////////////////////////////////////////// |
// Baz(); |
//////////////////////////////////////////////////////////////////////////// |
- var bazClassNonameConstructor = bazClassConstructors['']; |
+ var bazClassNonameConstructor = bazClassMembers[const Symbol('')]; |
Expect.isNotNull(bazClassNonameConstructor); |
Expect.isTrue(bazClassNonameConstructor is MethodMirror); |
Expect.isTrue(bazClassNonameConstructor.isConstructor); |
@@ -917,15 +836,15 @@ void testBaz(MirrorSystem system, LibraryMirror helperLibrary, |
Expect.isTrue(bazClassNonameConstructor.isGenerativeConstructor); |
Expect.isFalse(bazClassNonameConstructor.isRedirectingConstructor); |
Expect.isFalse(bazClassNonameConstructor.isFactoryConstructor); |
- Expect.stringEquals('', bazClassNonameConstructor.simpleName); |
+ Expect.equals(const Symbol(''), bazClassNonameConstructor.simpleName); |
Expect.stringEquals('Baz', displayName(bazClassNonameConstructor)); |
- Expect.stringEquals('mirrors_helper.Baz.', |
+ Expect.equals(const Symbol('mirrors_helper.Baz.'), |
bazClassNonameConstructor.qualifiedName); |
//////////////////////////////////////////////////////////////////////////// |
// const Baz.named(); |
//////////////////////////////////////////////////////////////////////////// |
- var bazClassNamedConstructor = bazClassConstructors['named']; |
+ var bazClassNamedConstructor = bazClassMembers[#named]; |
Expect.isNotNull(bazClassNamedConstructor); |
Expect.isTrue(bazClassNamedConstructor is MethodMirror); |
Expect.isTrue(bazClassNamedConstructor.isConstructor); |
@@ -934,15 +853,15 @@ void testBaz(MirrorSystem system, LibraryMirror helperLibrary, |
Expect.isFalse(bazClassNamedConstructor.isGenerativeConstructor); |
Expect.isFalse(bazClassNamedConstructor.isRedirectingConstructor); |
Expect.isFalse(bazClassNamedConstructor.isFactoryConstructor); |
- Expect.stringEquals('named', bazClassNamedConstructor.simpleName); |
+ Expect.equals(#named, bazClassNamedConstructor.simpleName); |
Expect.stringEquals('Baz.named', displayName(bazClassNamedConstructor)); |
- Expect.stringEquals('mirrors_helper.Baz.named', |
+ Expect.equals(#mirrors_helper.Baz.named, |
bazClassNamedConstructor.qualifiedName); |
//////////////////////////////////////////////////////////////////////////// |
// factory Baz.factory() => new Baz<E,F>(); |
//////////////////////////////////////////////////////////////////////////// |
- var bazClassFactoryConstructor = bazClassConstructors['factory']; |
+ var bazClassFactoryConstructor = bazClassMembers[#factory]; |
Expect.isNotNull(bazClassFactoryConstructor); |
Expect.isTrue(bazClassFactoryConstructor is MethodMirror); |
Expect.isTrue(bazClassFactoryConstructor.isConstructor); |
@@ -951,9 +870,9 @@ void testBaz(MirrorSystem system, LibraryMirror helperLibrary, |
Expect.isFalse(bazClassFactoryConstructor.isGenerativeConstructor); |
Expect.isFalse(bazClassFactoryConstructor.isRedirectingConstructor); |
Expect.isTrue(bazClassFactoryConstructor.isFactoryConstructor); |
- Expect.stringEquals('factory', bazClassFactoryConstructor.simpleName); |
+ Expect.equals(#factory, bazClassFactoryConstructor.simpleName); |
Expect.stringEquals('Baz.factory', displayName(bazClassFactoryConstructor)); |
- Expect.stringEquals('mirrors_helper.Baz.factory', |
+ Expect.equals(#mirrors_helper.Baz.factory, |
bazClassFactoryConstructor.qualifiedName); |
// TODO(johnniwinther): Add more tests of constructors. |
@@ -973,41 +892,41 @@ void testBaz(MirrorSystem system, LibraryMirror helperLibrary, |
// factory _PrivateClass._privateFactoryConstructor() => new _PrivateClass(); |
// } |
void testPrivate(MirrorSystem system, LibraryMirror helperLibrary, |
- Map<String,TypeMirror> classes) { |
- var privateClass = classes['_PrivateClass']; |
+ Map<Symbol, DeclarationMirror> declarations) { |
+ var privateClass = declarations[const Symbol('_PrivateClass')]; |
Expect.isNotNull(privateClass); |
Expect.isTrue(privateClass is ClassMirror); |
- Expect.isTrue(privateClass.isClass); |
Expect.isFalse(privateClass.isAbstract); |
Expect.isTrue(privateClass.isPrivate); |
- var privateField = privateClass.members['_privateField']; |
+ var privateField = privateClass.declarations[const Symbol('_privateField')]; |
Expect.isNotNull(privateField); |
Expect.isTrue(privateField is VariableMirror); |
Expect.isTrue(privateField.isPrivate); |
- var privateGetter = privateClass.members['_privateGetter']; |
+ var privateGetter = privateClass.declarations[const Symbol('_privateGetter')]; |
Expect.isNotNull(privateGetter); |
Expect.isTrue(privateGetter is MethodMirror); |
Expect.isTrue(privateGetter.isGetter); |
Expect.isTrue(privateGetter.isPrivate); |
Expect.isFalse(privateGetter.isRegularMethod); |
- var privateSetter = privateClass.members['_privateSetter=']; |
+ var privateSetter = |
+ privateClass.declarations[const Symbol('_privateSetter=')]; |
Expect.isNotNull(privateSetter); |
Expect.isTrue(privateSetter is MethodMirror); |
Expect.isTrue(privateSetter.isSetter); |
Expect.isTrue(privateSetter.isPrivate); |
Expect.isFalse(privateSetter.isRegularMethod); |
- var privateMethod = privateClass.members['_privateMethod']; |
+ var privateMethod = privateClass.declarations[const Symbol('_privateMethod')]; |
Expect.isNotNull(privateMethod); |
Expect.isTrue(privateMethod is MethodMirror); |
Expect.isTrue(privateMethod.isPrivate); |
Expect.isTrue(privateMethod.isRegularMethod); |
var privateConstructor = |
- privateClass.members['_privateConstructor']; |
+ privateClass.declarations[const Symbol('_privateConstructor')]; |
Expect.isNotNull(privateConstructor); |
Expect.isTrue(privateConstructor is MethodMirror); |
Expect.isTrue(privateConstructor.isConstructor); |
@@ -1018,7 +937,7 @@ void testPrivate(MirrorSystem system, LibraryMirror helperLibrary, |
Expect.isFalse(privateConstructor.isFactoryConstructor); |
var privateFactoryConstructor = |
- privateClass.members['_privateFactoryConstructor']; |
+ privateClass.declarations[const Symbol('_privateFactoryConstructor')]; |
Expect.isNotNull(privateFactoryConstructor); |
Expect.isTrue(privateFactoryConstructor is MethodMirror); |
Expect.isTrue(privateFactoryConstructor.isConstructor); |