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

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

Issue 221873002: Compute frontend/backend specific constants. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes Created 6 years, 8 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 import "package:async_helper/async_helper.dart"; 10 import "package:async_helper/async_helper.dart";
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 Expect.isFalse( 94 Expect.isFalse(
95 compiler.backend.isNeededForReflection(member), '$member'); 95 compiler.backend.isNeededForReflection(member), '$member');
96 } 96 }
97 }); 97 });
98 } 98 }
99 99
100 // There should at least be one metadata constant: 100 // There should at least be one metadata constant:
101 // 1. The constructed constant for 'MirrorsUsed'. 101 // 1. The constructed constant for 'MirrorsUsed'.
102 Expect.isTrue(compiler.backend.metadataConstants.length >= 1); 102 Expect.isTrue(compiler.backend.metadataConstants.length >= 1);
103 103
104 Set<Constant> compiledConstants =
105 compiler.backend.constants.compiledConstants;
104 // Make sure that most of the metadata constants aren't included in the 106 // Make sure that most of the metadata constants aren't included in the
105 // generated code. 107 // generated code.
106 for (var dependency in compiler.backend.metadataConstants) { 108 for (var dependency in compiler.backend.metadataConstants) {
107 Constant constant = dependency.constant; 109 Constant constant = dependency.constant;
108 Expect.isFalse( 110 Expect.isFalse(compiledConstants.contains(constant), '$constant');
109 compiler.constantHandler.compiledConstants.contains(constant),
110 '$constant');
111 } 111 }
112 112
113 // The type literal 'Foo' is both used as metadata, and as a plain value in 113 // The type literal 'Foo' is both used as metadata, and as a plain value in
114 // the program. Make sure that it isn't duplicated. 114 // the program. Make sure that it isn't duplicated.
115 int fooConstantCount = 0; 115 int fooConstantCount = 0;
116 for (Constant constant in compiler.constantHandler.compiledConstants) { 116 for (Constant constant in compiledConstants) {
117 if (constant is TypeConstant && '${constant.representedType}' == 'Foo') { 117 if (constant is TypeConstant && '${constant.representedType}' == 'Foo') {
118 fooConstantCount++; 118 fooConstantCount++;
119 } 119 }
120 } 120 }
121 Expect.equals( 121 Expect.equals(
122 1, fooConstantCount, 122 1, fooConstantCount,
123 "The type literal 'Foo' is duplicated or missing."); 123 "The type literal 'Foo' is duplicated or missing.");
124 })); 124 }));
125 } 125 }
126 126
(...skipping 23 matching lines...) Expand all
150 library lib; 150 library lib;
151 151
152 import 'dart:mirrors'; 152 import 'dart:mirrors';
153 153
154 useReflect(type) { 154 useReflect(type) {
155 print(new Symbol('Foo')); 155 print(new Symbol('Foo'));
156 print(MirrorSystem.getName(reflectClass(type).owner.qualifiedName)); 156 print(MirrorSystem.getName(reflectClass(type).owner.qualifiedName));
157 } 157 }
158 """, 158 """,
159 }; 159 };
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/exit_code_test.dart ('k') | tests/compiler/dart2js_extra/constant_javascript_semantics_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698