Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 /// Test that the @MirrorsUsed annotation suppress hints and that only | 5 /// Test that the @MirrorsUsed annotation suppress hints and that only |
| 6 /// requested elements are retained for reflection. | 6 /// requested elements are retained for reflection. |
| 7 library dart2js.test.mirrors_used_test; | 7 library dart2js.test.mirrors_used_test; |
| 8 | 8 |
| 9 import 'package:expect/expect.dart'; | 9 import 'package:expect/expect.dart'; |
| 10 import "package:async_helper/async_helper.dart"; | 10 import "package:async_helper/async_helper.dart"; |
| 11 | 11 |
| 12 import 'memory_compiler.dart' show | 12 import 'memory_compiler.dart' show |
| 13 compilerFor; | 13 compilerFor; |
| 14 | 14 |
| 15 import '../../../sdk/lib/_internal/compiler/implementation/apiimpl.dart' show | 15 import '../../../sdk/lib/_internal/compiler/implementation/apiimpl.dart' show |
| 16 Compiler; | 16 Compiler; |
| 17 | 17 |
| 18 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart' show | 18 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart' show |
| 19 Constant, | 19 Constant, |
| 20 SourceString, | |
| 21 TypeConstant; | 20 TypeConstant; |
| 22 | 21 |
| 23 import | 22 import |
| 24 '../../../sdk/lib/_internal/compiler/implementation/elements/elements.dart' | 23 '../../../sdk/lib/_internal/compiler/implementation/elements/elements.dart' |
| 25 show | 24 show |
| 26 Elements; | 25 Elements; |
| 27 | 26 |
| 28 void expectOnlyVerboseInfo(Uri uri, int begin, int end, String message, kind) { | 27 void expectOnlyVerboseInfo(Uri uri, int begin, int end, String message, kind) { |
| 29 if (kind.name == 'verbose info') { | 28 if (kind.name == 'verbose info') { |
| 30 print(message); | 29 print(message); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 r'get$field', // The (getter) name of Foo.field. | 72 r'get$field', // The (getter) name of Foo.field. |
| 74 r'instanceMethod$0']; // The name of Foo.instanceMethod. | 73 r'instanceMethod$0']; // The name of Foo.instanceMethod. |
| 75 Set recordedNames = new Set() | 74 Set recordedNames = new Set() |
| 76 ..addAll(compiler.backend.emitter.recordedMangledNames) | 75 ..addAll(compiler.backend.emitter.recordedMangledNames) |
| 77 ..addAll(compiler.backend.emitter.mangledFieldNames.keys) | 76 ..addAll(compiler.backend.emitter.mangledFieldNames.keys) |
| 78 ..addAll(compiler.backend.emitter.mangledGlobalFieldNames.keys); | 77 ..addAll(compiler.backend.emitter.mangledGlobalFieldNames.keys); |
| 79 Expect.setEquals(new Set.from(expectedNames), recordedNames); | 78 Expect.setEquals(new Set.from(expectedNames), recordedNames); |
| 80 | 79 |
| 81 for (var library in compiler.libraries.values) { | 80 for (var library in compiler.libraries.values) { |
| 82 library.forEachLocalMember((member) { | 81 library.forEachLocalMember((member) { |
| 83 if (library == compiler.mainApp | 82 if (library == compiler.mainApp |
|
kasperl
2013/10/18 06:44:57
Fits on one line?
lukas
2013/10/18 08:39:46
Done.
| |
| 84 && member.name == const SourceString('Foo')) { | 83 && member.name == 'Foo') { |
| 85 Expect.isTrue( | 84 Expect.isTrue( |
| 86 compiler.backend.isNeededForReflection(member), '$member'); | 85 compiler.backend.isNeededForReflection(member), '$member'); |
| 87 member.forEachLocalMember((classMember) { | 86 member.forEachLocalMember((classMember) { |
| 88 Expect.isTrue( | 87 Expect.isTrue( |
| 89 compiler.backend.isNeededForReflection(classMember), | 88 compiler.backend.isNeededForReflection(classMember), |
| 90 '$classMember'); | 89 '$classMember'); |
| 91 }); | 90 }); |
| 92 } else { | 91 } else { |
| 93 Expect.isFalse( | 92 Expect.isFalse( |
| 94 compiler.backend.isNeededForReflection(member), '$member'); | 93 compiler.backend.isNeededForReflection(member), '$member'); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 library lib; | 146 library lib; |
| 148 | 147 |
| 149 import 'dart:mirrors'; | 148 import 'dart:mirrors'; |
| 150 | 149 |
| 151 useReflect(type) { | 150 useReflect(type) { |
| 152 print(new Symbol('Foo')); | 151 print(new Symbol('Foo')); |
| 153 print(MirrorSystem.getName(reflectClass(type).owner.qualifiedName)); | 152 print(MirrorSystem.getName(reflectClass(type).owner.qualifiedName)); |
| 154 } | 153 } |
| 155 """, | 154 """, |
| 156 }; | 155 }; |
| OLD | NEW |