| Index: dart/runtime/tests/vm/dart/isolate_mirror_local_test.dart
|
| diff --git a/dart/runtime/tests/vm/dart/isolate_mirror_local_test.dart b/dart/runtime/tests/vm/dart/isolate_mirror_local_test.dart
|
| index e72f5a138f6071d23383bef3892205a2ce081ec5..6d1827db74bbd9696512d7fdd6b9fd4fb42dd4c7 100644
|
| --- a/dart/runtime/tests/vm/dart/isolate_mirror_local_test.dart
|
| +++ b/dart/runtime/tests/vm/dart/isolate_mirror_local_test.dart
|
| @@ -49,7 +49,8 @@ _stringCompare(String a, String b) => a.compareTo(b);
|
| sort(list) => list.sort(_stringCompare);
|
|
|
| String buildMethodString(MethodMirror func) {
|
| - var result = '${func.simpleName} return(${func.returnType.simpleName})';
|
| + var result = '${MirrorSystem.getName(func.simpleName)} '
|
| + 'return(${MirrorSystem.getName(func.returnType.simpleName)})';
|
| if (func.isPrivate) {
|
| result = '$result private';
|
| }
|
| @@ -90,7 +91,8 @@ String buildMethodString(MethodMirror func) {
|
| }
|
|
|
| String buildVariableString(VariableMirror variable) {
|
| - var result = '${variable.simpleName} type(${variable.type.simpleName})';
|
| + var result = '${MirrorSystem.getName(variable.simpleName)} '
|
| + 'type(${MirrorSystem.getName(variable.type.simpleName)})';
|
| if (variable.isPrivate) {
|
| result = '$result private';
|
| }
|
| @@ -107,27 +109,30 @@ String buildVariableString(VariableMirror variable) {
|
| }
|
|
|
| void testRootLibraryMirror(LibraryMirror lib_mirror) {
|
| - Expect.equals('isolate_mirror_local_test', lib_mirror.simpleName);
|
| - Expect.equals('isolate_mirror_local_test', lib_mirror.qualifiedName);
|
| + Expect.equals(const Symbol('isolate_mirror_local_test'),
|
| + lib_mirror.simpleName);
|
| + Expect.equals(const Symbol('isolate_mirror_local_test'),
|
| + lib_mirror.qualifiedName);
|
| Expect.equals(null, lib_mirror.owner);
|
| Expect.isFalse(lib_mirror.isPrivate);
|
| Expect.isTrue(lib_mirror.url.contains('isolate_mirror_local_test.dart'));
|
| - Expect.equals("LibraryMirror on 'isolate_mirror_local_test'",
|
| - lib_mirror.toString());
|
| + // TODO(ahe): toString() test disabled for now as Symbols are 100% opaque.
|
| + // Expect.equals("LibraryMirror on 'isolate_mirror_local_test'",
|
| + // lib_mirror.toString());
|
|
|
| // Test library invocation by calling function(123).
|
| Expect.equals(0, global_var);
|
| - lib_mirror.invokeAsync('function', [123]).then(
|
| + lib_mirror.invokeAsync(const Symbol('function'), [123]).then(
|
| (InstanceMirror retval) {
|
| Expect.equals(123, global_var);
|
| - Expect.equals('int', retval.type.simpleName);
|
| + Expect.equals(const Symbol('int'), retval.type.simpleName);
|
| Expect.isTrue(retval.hasReflectee);
|
| Expect.equals(124, retval.reflectee);
|
| testDone('testRootLibraryMirror');
|
| });
|
|
|
| // Check that the members map is complete.
|
| - List keys = lib_mirror.members.keys.toList();
|
| + List keys = lib_mirror.members.keys.map(MirrorSystem.getName).toList();
|
| sort(keys);
|
| Expect.equals('['
|
| 'FuncType, '
|
| @@ -164,7 +169,7 @@ void testRootLibraryMirror(LibraryMirror lib_mirror) {
|
| '$keys');
|
|
|
| // Check that the classes map is complete.
|
| - keys = lib_mirror.classes.keys.toList();
|
| + keys = lib_mirror.classes.keys.map(MirrorSystem.getName).toList();
|
| sort(keys);
|
| Expect.equals('['
|
| 'FuncType, '
|
| @@ -176,7 +181,7 @@ void testRootLibraryMirror(LibraryMirror lib_mirror) {
|
| '$keys');
|
|
|
| // Check that the functions map is complete.
|
| - keys = lib_mirror.functions.keys.toList();
|
| + keys = lib_mirror.functions.keys.map(MirrorSystem.getName).toList();
|
| sort(keys);
|
| Expect.equals('['
|
| '_stringCompare, '
|
| @@ -202,17 +207,17 @@ void testRootLibraryMirror(LibraryMirror lib_mirror) {
|
| '$keys');
|
|
|
| // Check that the getters map is complete.
|
| - keys = lib_mirror.getters.keys.toList();
|
| + keys = lib_mirror.getters.keys.map(MirrorSystem.getName).toList();
|
| sort(keys);
|
| Expect.equals('[myVar]', '$keys');
|
|
|
| // Check that the setters map is complete.
|
| - keys = lib_mirror.setters.keys.toList();
|
| + keys = lib_mirror.setters.keys.map(MirrorSystem.getName).toList();
|
| sort(keys);
|
| Expect.equals('[myVar=]', '$keys');
|
|
|
| // Check that the variables map is complete.
|
| - keys = lib_mirror.variables.keys.toList();
|
| + keys = lib_mirror.variables.keys.map(MirrorSystem.getName).toList();
|
| sort(keys);
|
| Expect.equals('['
|
| 'exit_port, '
|
| @@ -222,108 +227,114 @@ void testRootLibraryMirror(LibraryMirror lib_mirror) {
|
| 'myFunc]',
|
| '$keys');
|
|
|
| - ClassMirror cls_mirror = lib_mirror.members['MyClass'];
|
| - ClassMirror generic_cls_mirror = lib_mirror.members['GenericClass'];
|
| + ClassMirror cls_mirror = lib_mirror.members[const Symbol('MyClass')];
|
| + ClassMirror generic_cls_mirror =
|
| + lib_mirror.members[const Symbol('GenericClass')];
|
|
|
| // Test function mirrors.
|
| - MethodMirror func = lib_mirror.members['function'];
|
| + MethodMirror func = lib_mirror.members[const Symbol('function')];
|
| Expect.isTrue(func is MethodMirror);
|
| Expect.equals('function return(int) toplevel static method',
|
| buildMethodString(func));
|
|
|
| - func = lib_mirror.members['myVar'];
|
| + func = lib_mirror.members[const Symbol('myVar')];
|
| Expect.isTrue(func is MethodMirror);
|
| Expect.equals('myVar return(int) toplevel static getter',
|
| buildMethodString(func));
|
|
|
| - func = lib_mirror.members['myVar='];
|
| + func = lib_mirror.members[const Symbol('myVar=')];
|
| Expect.isTrue(func is MethodMirror);
|
| Expect.equals('myVar= return(void) toplevel static setter',
|
| buildMethodString(func));
|
|
|
| - func = cls_mirror.members['method'];
|
| + func = cls_mirror.members[const Symbol('method')];
|
| Expect.isTrue(func is MethodMirror);
|
| Expect.equals('method return(int) method', buildMethodString(func));
|
|
|
| - func = cls_mirror.constructors['MyClass'];
|
| + func = cls_mirror.constructors[const Symbol('MyClass')];
|
| Expect.isTrue(func is MethodMirror);
|
| Expect.equals('MyClass return(MyClass) constructor', buildMethodString(func));
|
|
|
| - func = cls_mirror.constructors['MyClass.named'];
|
| + func = cls_mirror.constructors[const Symbol('MyClass.named')];
|
| Expect.isTrue(func is MethodMirror);
|
| Expect.equals('MyClass.named return(MyClass) constructor',
|
| buildMethodString(func));
|
|
|
| - func = generic_cls_mirror.members['method'];
|
| + func = generic_cls_mirror.members[const Symbol('method')];
|
| Expect.isTrue(func is MethodMirror);
|
| Expect.equals('method return(T) method', buildMethodString(func));
|
|
|
| // Test variable mirrors.
|
| - VariableMirror variable = lib_mirror.members['global_var'];
|
| + VariableMirror variable = lib_mirror.members[const Symbol('global_var')];
|
| Expect.isTrue(variable is VariableMirror);
|
| Expect.equals('global_var type(int) toplevel static',
|
| buildVariableString(variable));
|
|
|
| - variable = lib_mirror.members['final_global_var'];
|
| + variable = lib_mirror.members[const Symbol('final_global_var')];
|
| Expect.isTrue(variable is VariableMirror);
|
| Expect.equals('final_global_var type(int) toplevel static final',
|
| buildVariableString(variable));
|
|
|
| - variable = cls_mirror.members['value'];
|
| + variable = cls_mirror.members[const Symbol('value')];
|
| Expect.isTrue(variable is VariableMirror);
|
| Expect.equals('value type(dynamic) final', buildVariableString(variable));
|
|
|
| // Test type variable mirrors.
|
| - var type_var = generic_cls_mirror.members['method'].returnType;
|
| + var type_var = generic_cls_mirror.members[const Symbol('method')].returnType;
|
| Expect.isTrue(type_var is TypeVariableMirror);
|
| - Expect.equals('GenericClass', type_var.owner.simpleName);
|
| - Expect.equals('Object', type_var.upperBound.simpleName);
|
| + Expect.equals(const Symbol('GenericClass'), type_var.owner.simpleName);
|
| + Expect.equals(const Symbol('Object'), type_var.upperBound.simpleName);
|
|
|
| // Test typedef mirrors.
|
| - var typedef_mirror = lib_mirror.members['myFunc'].type;
|
| + var typedef_mirror = lib_mirror.members[const Symbol('myFunc')].type;
|
| Expect.isTrue(typedef_mirror is TypedefMirror);
|
| - Expect.equals('isolate_mirror_local_test', typedef_mirror.owner.simpleName);
|
| + Expect.equals(const Symbol('isolate_mirror_local_test'),
|
| + typedef_mirror.owner.simpleName);
|
|
|
| // Test function type mirrors.
|
| var func_cls_mirror = typedef_mirror.referent;
|
| Expect.isTrue(func_cls_mirror is FunctionTypeMirror);
|
| - Expect.equals('void (dart.core.String)', func_cls_mirror.simpleName);
|
| - Expect.equals('void', func_cls_mirror.returnType.simpleName);
|
| + // Expect.equals('void (dart.core.String)', func_cls_mirror.simpleName);
|
| + Expect.equals(const Symbol('void'), func_cls_mirror.returnType.simpleName);
|
| }
|
|
|
| void testLibrariesMap(Map libraries) {
|
| // Just look for a couple of well-known libs.
|
| - LibraryMirror core_lib = libraries['dart.core'];
|
| + LibraryMirror core_lib = libraries[const Symbol('dart.core')];
|
| Expect.isTrue(core_lib is LibraryMirror);
|
|
|
| - LibraryMirror mirror_lib = libraries['dart.mirrors'];
|
| + LibraryMirror mirror_lib = libraries[const Symbol('dart.mirrors')];
|
| Expect.isTrue(mirror_lib is LibraryMirror);
|
|
|
| // Lookup an interface from a library and make sure it is sane.
|
| - ClassMirror list_intf = core_lib.members['List'];
|
| + ClassMirror list_intf = core_lib.members[const Symbol('List')];
|
| Expect.isTrue(list_intf is ClassMirror);
|
| - Expect.equals('List', list_intf.simpleName);
|
| - Expect.equals('dart.core.List', list_intf.qualifiedName);
|
| + Expect.equals(const Symbol('List'), list_intf.simpleName);
|
| + Expect.equals(const Symbol('dart.core.List'), list_intf.qualifiedName);
|
| Expect.isFalse(list_intf.isPrivate);
|
| - Expect.equals('Object', list_intf.superclass.simpleName);
|
| - Expect.equals('dart.core', list_intf.owner.simpleName);
|
| + Expect.equals(const Symbol('Object'), list_intf.superclass.simpleName);
|
| + Expect.equals(const Symbol('dart.core'), list_intf.owner.simpleName);
|
| Expect.isTrue(list_intf.isClass);
|
| - Expect.equals('Iterable', list_intf.superinterfaces[0].simpleName);
|
| - Expect.equals("ClassMirror on 'List'", list_intf.toString());
|
| + Expect.equals(const Symbol('Iterable'),
|
| + list_intf.superinterfaces[0].simpleName);
|
| + // TODO(ahe): toString() test disabled for now as Symbols are 100% opaque.
|
| + // Expect.equals("ClassMirror on 'List'", list_intf.toString());
|
|
|
| // Lookup a class from a library and make sure it is sane.
|
| - ClassMirror oom_cls = core_lib.members['OutOfMemoryError'];
|
| + ClassMirror oom_cls = core_lib.members[const Symbol('OutOfMemoryError')];
|
| Expect.isTrue(oom_cls is ClassMirror);
|
| - Expect.equals('OutOfMemoryError', oom_cls.simpleName);
|
| - Expect.equals('dart.core.OutOfMemoryError', oom_cls.qualifiedName);
|
| + Expect.equals(const Symbol('OutOfMemoryError'), oom_cls.simpleName);
|
| + Expect.equals(const Symbol('dart.core.OutOfMemoryError'),
|
| + oom_cls.qualifiedName);
|
| Expect.isFalse(oom_cls.isPrivate);
|
| - Expect.equals('Object', oom_cls.superclass.simpleName);
|
| + Expect.equals(const Symbol('Object'), oom_cls.superclass.simpleName);
|
| Expect.isTrue(oom_cls.defaultFactory == null);
|
| - Expect.equals('dart.core', oom_cls.owner.simpleName);
|
| + Expect.equals(const Symbol('dart.core'), oom_cls.owner.simpleName);
|
| Expect.isTrue(oom_cls.isClass);
|
| - Expect.equals('Error', oom_cls.superinterfaces[0].simpleName);
|
| - Expect.equals("ClassMirror on 'OutOfMemoryError'",
|
| - oom_cls.toString());
|
| + Expect.equals(const Symbol('Error'), oom_cls.superinterfaces[0].simpleName);
|
| + // TODO(ahe): toString() test disabled for now as Symbols are 100% opaque.
|
| + // Expect.equals("ClassMirror on 'OutOfMemoryError'",
|
| + // oom_cls.toString());
|
| testDone('testLibrariesMap');
|
| }
|
|
|
| @@ -331,21 +342,21 @@ void testMirrorSystem(MirrorSystem mirrors) {
|
| Expect.isTrue(mirrors.isolate.debugName.contains('main'));
|
| testRootLibraryMirror(mirrors.isolate.rootLibrary);
|
| testLibrariesMap(mirrors.libraries);
|
| - Expect.equals('void', mirrors.voidType.simpleName);
|
| - Expect.equals('dynamic', mirrors.dynamicType.simpleName);
|
| + Expect.equals(const Symbol('void'), mirrors.voidType.simpleName);
|
| + Expect.equals(const Symbol('dynamic'), mirrors.dynamicType.simpleName);
|
| testDone('testMirrorSystem');
|
| }
|
|
|
| void testIntegerInstanceMirror(InstanceMirror mirror) {
|
| - Expect.equals('int', mirror.type.simpleName);
|
| + Expect.equals(const Symbol('int'), mirror.type.simpleName);
|
| Expect.isTrue(mirror.hasReflectee);
|
| Expect.equals(1001, mirror.reflectee);
|
| Expect.equals("InstanceMirror on <1001>", mirror.toString());
|
|
|
| // Invoke (mirror + mirror).
|
| - mirror.invokeAsync('+', [ mirror ]).then(
|
| + mirror.invokeAsync(const Symbol('+'), [ mirror ]).then(
|
| (InstanceMirror retval) {
|
| - Expect.equals('int', retval.type.simpleName);
|
| + Expect.equals(const Symbol('int'), retval.type.simpleName);
|
| Expect.isTrue(retval.hasReflectee);
|
| Expect.equals(2002, retval.reflectee);
|
| testDone('testIntegerInstanceMirror');
|
| @@ -353,16 +364,16 @@ void testIntegerInstanceMirror(InstanceMirror mirror) {
|
| }
|
|
|
| void testStringInstanceMirror(InstanceMirror mirror) {
|
| - Expect.equals('String', mirror.type.simpleName);
|
| + Expect.equals(const Symbol('String'), mirror.type.simpleName);
|
| Expect.isTrue(mirror.hasReflectee);
|
| Expect.equals('This\nis\na\nString', mirror.reflectee);
|
| Expect.equals("InstanceMirror on <'This\\nis\\na\\nString'>",
|
| mirror.toString());
|
|
|
| // Invoke mirror[0].
|
| - mirror.invokeAsync('[]', [ 0 ]).then(
|
| + mirror.invokeAsync(const Symbol('[]'), [ 0 ]).then(
|
| (InstanceMirror retval) {
|
| - Expect.equals('String', retval.type.simpleName);
|
| + Expect.equals(const Symbol('String'), retval.type.simpleName);
|
| Expect.isTrue(retval.hasReflectee);
|
| Expect.equals('T', retval.reflectee);
|
| testDone('testStringInstanceMirror');
|
| @@ -370,7 +381,7 @@ void testStringInstanceMirror(InstanceMirror mirror) {
|
| }
|
|
|
| void testBoolInstanceMirror(InstanceMirror mirror) {
|
| - Expect.equals('bool', mirror.type.simpleName);
|
| + Expect.equals(const Symbol('bool'), mirror.type.simpleName);
|
| Expect.isTrue(mirror.hasReflectee);
|
| Expect.equals(true, mirror.reflectee);
|
| Expect.equals("InstanceMirror on <true>", mirror.toString());
|
| @@ -379,7 +390,7 @@ void testBoolInstanceMirror(InstanceMirror mirror) {
|
|
|
| void testNullInstanceMirror(InstanceMirror mirror) {
|
| // TODO(turnidge): This is returning the wrong class. Fix it.
|
| - Expect.equals('Object', mirror.type.simpleName);
|
| + Expect.equals(const Symbol('Object'), mirror.type.simpleName);
|
| Expect.isTrue(mirror.hasReflectee);
|
| Expect.equals(null, mirror.reflectee);
|
| Expect.equals("InstanceMirror on <null>", mirror.toString());
|
| @@ -418,23 +429,25 @@ void testCustomInstanceMirror(InstanceMirror mirror) {
|
| saw_exception = true;
|
| }
|
| Expect.isFalse(saw_exception);
|
| - Expect.equals("InstanceMirror on instance of 'MyClass'", mirror.toString());
|
| + // TODO(ahe): toString() test disabled for now as Symbols are 100% opaque.
|
| + // Expect.equals("InstanceMirror on instance of 'MyClass'",
|
| + // mirror.toString());
|
|
|
| ClassMirror cls = mirror.type;
|
| Expect.isTrue(cls is ClassMirror);
|
| - Expect.equals('MyClass', cls.simpleName);
|
| - Expect.equals('MySuperClass', cls.superclass.simpleName);
|
| + Expect.equals(const Symbol('MyClass'), cls.simpleName);
|
| + Expect.equals(const Symbol('MySuperClass'), cls.superclass.simpleName);
|
| Expect.isTrue(cls.defaultFactory == null);
|
| - Expect.equals('isolate_mirror_local_test', cls.owner.simpleName);
|
| + Expect.equals(const Symbol('isolate_mirror_local_test'), cls.owner.simpleName);
|
| Expect.isTrue(cls.isClass);
|
| - Expect.equals('MyInterface', cls.superinterfaces[0].simpleName);
|
| - Expect.equals("ClassMirror on 'MyClass'",
|
| - cls.toString());
|
| + Expect.equals(const Symbol('MyInterface'), cls.superinterfaces[0].simpleName);
|
| + // TODO(ahe): toString() test disabled for now as Symbols are 100% opaque.
|
| + // Expect.equals("ClassMirror on 'MyClass'", cls.toString());
|
|
|
| // Invoke mirror.method(1000).
|
| - mirror.invokeAsync('method', [ 1000 ]).then(
|
| + mirror.invokeAsync(const Symbol('method'), [ 1000 ]).then(
|
| (InstanceMirror retval) {
|
| - Expect.equals('int', retval.type.simpleName);
|
| + Expect.equals(const Symbol('int'), retval.type.simpleName);
|
| Expect.isTrue(retval.hasReflectee);
|
| Expect.equals(1017, retval.reflectee);
|
| testDone('testCustomInstanceMirror');
|
| @@ -460,14 +473,14 @@ void methodWithError() {
|
| void testMirrorErrors(MirrorSystem mirrors) {
|
| LibraryMirror lib_mirror = mirrors.isolate.rootLibrary;
|
|
|
| - lib_mirror.invokeAsync('methodWithException', [])
|
| + lib_mirror.invokeAsync(const Symbol('methodWithException'), [])
|
| .then((InstanceMirror retval) {
|
| // Should not reach here.
|
| Expect.isTrue(false);
|
| })
|
| .catchError((exc) {
|
| Expect.isTrue(exc.error is MirroredUncaughtExceptionError);
|
| - Expect.equals('MyException',
|
| + Expect.equals(const Symbol('MyException'),
|
| exc.error.exception_mirror.type.simpleName);
|
| Expect.equals('MyException: from methodWithException',
|
| exc.error.exception_string);
|
| @@ -476,7 +489,7 @@ void testMirrorErrors(MirrorSystem mirrors) {
|
| testDone('testMirrorErrors1');
|
| });
|
|
|
| - lib_mirror.invokeAsync('methodWithError', [])
|
| + lib_mirror.invokeAsync(const Symbol('methodWithError'), [])
|
| .then((InstanceMirror retval) {
|
| // Should not reach here.
|
| Expect.isTrue(false);
|
| @@ -490,7 +503,7 @@ void testMirrorErrors(MirrorSystem mirrors) {
|
| // TODO(turnidge): When we call a method that doesn't exist, we
|
| // should probably call noSuchMethod(). I'm adding this test to
|
| // document the current behavior in the meantime.
|
| - lib_mirror.invokeAsync('methodNotFound', [])
|
| + lib_mirror.invokeAsync(const Symbol('methodNotFound'), [])
|
| .then((InstanceMirror retval) {
|
| // Should not reach here.
|
| Expect.isTrue(false);
|
|
|