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

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

Issue 22301009: Retain fewer names for reflection. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Make sure that receiver-less symbols are retained when there is insufficient @MirrorsUsed. Created 7 years, 4 months 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
OLDNEW
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 10
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 // 1. Too many elements retained for reflection. 47 // 1. Too many elements retained for reflection.
48 // 2. Some code was refactored, and there are more methods. 48 // 2. Some code was refactored, and there are more methods.
49 // Either situation could be problematic, but in situation 2, it is often 49 // Either situation could be problematic, but in situation 2, it is often
50 // acceptable to increase [expectedMethodCount] a little. 50 // acceptable to increase [expectedMethodCount] a little.
51 int expectedMethodCount = 317; 51 int expectedMethodCount = 317;
52 Expect.isTrue( 52 Expect.isTrue(
53 generatedCode.length <= expectedMethodCount, 53 generatedCode.length <= expectedMethodCount,
54 'Too many compiled methods: ' 54 'Too many compiled methods: '
55 '${generatedCode.length} > $expectedMethodCount'); 55 '${generatedCode.length} > $expectedMethodCount');
56 56
57 // The following names should be retained:
58 List expectedNames = [
59 'Foo', // The name of class Foo.
60 r'Foo$', // The name of class Foo's constructor.
61 'Foo_staticMethod', // The name of Foo.staticMethod.
62 r'get$field', // The (getter) name of Foo.field.
63 r'instanceMethod$0']; // The name of Foo.instanceMethod.
64 Set recordedNames = new Set()
65 ..addAll(compiler.backend.emitter.recordedMangledNames)
66 ..addAll(compiler.backend.emitter.mangledFieldNames.keys)
67 ..addAll(compiler.backend.emitter.mangledGlobalFieldNames.keys);
68 Expect.setEquals(new Set.from(expectedNames), recordedNames);
69
57 for (var library in compiler.libraries.values) { 70 for (var library in compiler.libraries.values) {
58 library.forEachLocalMember((member) { 71 library.forEachLocalMember((member) {
59 if (library == compiler.mainApp 72 if (library == compiler.mainApp
60 && member.name == const SourceString('Foo')) { 73 && member.name == const SourceString('Foo')) {
61 Expect.isTrue( 74 Expect.isTrue(
62 compiler.backend.isNeededForReflection(member), '$member'); 75 compiler.backend.isNeededForReflection(member), '$member');
63 member.forEachLocalMember((classMember) { 76 member.forEachLocalMember((classMember) {
64 Expect.isTrue( 77 Expect.isTrue(
65 compiler.backend.isNeededForReflection(classMember), 78 compiler.backend.isNeededForReflection(classMember),
66 '$classMember'); 79 '$classMember');
(...skipping 30 matching lines...) Expand all
97 library lib; 110 library lib;
98 111
99 import 'dart:mirrors'; 112 import 'dart:mirrors';
100 113
101 useReflect(type) { 114 useReflect(type) {
102 print(new Symbol('Foo')); 115 print(new Symbol('Foo'));
103 print(MirrorSystem.getName(reflectClass(type).owner.qualifiedName)); 116 print(MirrorSystem.getName(reflectClass(type).owner.qualifiedName));
104 } 117 }
105 """, 118 """,
106 }; 119 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698