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

Side by Side Diff: tests/lib/mirrors/mirrors_test.dart

Issue 23450040: Implement redirecting factories in mirrors. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 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
« no previous file with comments | « tests/lib/lib.status ('k') | tests/lib/mirrors/redirecting_factory_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 library MirrorsTest; 5 library MirrorsTest;
6 6
7 import 'dart:mirrors'; 7 import 'dart:mirrors';
8 8
9 import '../../light_unittest.dart'; 9 import '../../light_unittest.dart';
10 10
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 expect(instanceMirror.reflectee is Class, equals(true)); 189 expect(instanceMirror.reflectee is Class, equals(true));
190 expect(instanceMirror.reflectee.field, equals(16)); 190 expect(instanceMirror.reflectee.field, equals(16));
191 191
192 instanceMirror = classMirror.newInstance(const Symbol('faktory'), 192 instanceMirror = classMirror.newInstance(const Symbol('faktory'),
193 [9]); 193 [9]);
194 expect(instanceMirror.reflectee is Class, equals(true)); 194 expect(instanceMirror.reflectee is Class, equals(true));
195 expect(instanceMirror.reflectee.field, equals(27)); 195 expect(instanceMirror.reflectee.field, equals(27));
196 196
197 instanceMirror = classMirror.newInstance(const Symbol('redirectingFactory'), 197 instanceMirror = classMirror.newInstance(const Symbol('redirectingFactory'),
198 [10]); 198 [10]);
199 if (!isDart2js) { 199 expect(instanceMirror.reflectee is Class, equals(true));
200 expect(instanceMirror.reflectee is Class, equals(true)); 200 expect(instanceMirror.reflectee.field, equals(30));
201 expect(instanceMirror.reflectee.field, equals(30));
202 }
203 201
204 202
205 var future = classMirror.newInstanceAsync(const Symbol(''), []); 203 var future = classMirror.newInstanceAsync(const Symbol(''), []);
206 future.then(expectAsync1((resultMirror) { 204 future.then(expectAsync1((resultMirror) {
207 var instance = resultMirror.reflectee; 205 var instance = resultMirror.reflectee;
208 expect(instance is Class, equals(true)); 206 expect(instance is Class, equals(true));
209 expect(instance.field, equals("default value")); 207 expect(instance.field, equals("default value"));
210 })); 208 }));
211 209
212 future = classMirror.newInstanceAsync(const Symbol('withInitialValue'), [45]); 210 future = classMirror.newInstanceAsync(const Symbol('withInitialValue'), [45]);
213 future.then(expectAsync1((resultMirror) { 211 future.then(expectAsync1((resultMirror) {
214 var instance = resultMirror.reflectee; 212 var instance = resultMirror.reflectee;
215 expect(instance is Class, equals(true)); 213 expect(instance is Class, equals(true));
216 expect(instance.field, equals(45)); 214 expect(instance.field, equals(45));
217 })); 215 }));
218 } 216 }
219 217
220 testReflectClass(mirrors) { 218 testReflectClass(mirrors) {
221 var classMirror = reflectClass(Class); 219 var classMirror = reflectClass(Class);
222 expect(classMirror is ClassMirror, equals(true)); 220 expect(classMirror is ClassMirror, equals(true));
223 var symbolClassMirror = reflectClass(Symbol); 221 var symbolClassMirror = reflectClass(Symbol);
224 var symbolMirror = symbolClassMirror.newInstance(const Symbol(''), 222 var symbolMirror = symbolClassMirror.newInstance(const Symbol(''),
225 ['withInitialValue']); 223 ['withInitialValue']);
226 if (isDart2js) return;
227 var objectMirror = classMirror.newInstance(symbolMirror.reflectee,[1234]); 224 var objectMirror = classMirror.newInstance(symbolMirror.reflectee,[1234]);
228 expect(objectMirror.reflectee is Class, equals(true)); 225 expect(objectMirror.reflectee is Class, equals(true));
229 expect(objectMirror.reflectee.field, equals(1234)); 226 expect(objectMirror.reflectee.field, equals(1234));
230 } 227 }
231 228
232 testNames(mirrors) { 229 testNames(mirrors) {
233 var libMirror = mirrors.findLibrary(const Symbol("MirrorsTest")).single; 230 var libMirror = mirrors.findLibrary(const Symbol("MirrorsTest")).single;
234 var classMirror = libMirror.classes[const Symbol('Class')]; 231 var classMirror = libMirror.classes[const Symbol('Class')];
235 var typedefMirror = libMirror.members[const Symbol('Typedef')]; 232 var typedefMirror = libMirror.members[const Symbol('Typedef')];
236 var methodMirror = libMirror.functions[const Symbol('testNames')]; 233 var methodMirror = libMirror.functions[const Symbol('testNames')];
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 test("Test current library uri", () { 282 test("Test current library uri", () {
286 testLibraryUri(new Class(), 283 testLibraryUri(new Class(),
287 (Uri uri) => uri.path.endsWith('/mirrors_test.dart')); 284 (Uri uri) => uri.path.endsWith('/mirrors_test.dart'));
288 }); 285 });
289 test("Test dart library uri", () { 286 test("Test dart library uri", () {
290 testLibraryUri("test", (Uri uri) => uri == Uri.parse('dart:core')); 287 testLibraryUri("test", (Uri uri) => uri == Uri.parse('dart:core'));
291 }); 288 });
292 test("Test simple and qualifiedName", () { testNames(mirrors); }); 289 test("Test simple and qualifiedName", () { testNames(mirrors); });
293 test("Test reflect type", () { testReflectClass(mirrors); }); 290 test("Test reflect type", () { testReflectClass(mirrors); });
294 } 291 }
OLDNEW
« no previous file with comments | « tests/lib/lib.status ('k') | tests/lib/mirrors/redirecting_factory_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698