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

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

Issue 64793003: Update mirror tests for removed API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: . Created 7 years, 1 month 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) 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 ' null, null, null, null, null, null, null, null, null, null,' 84 ' null, null, null, null, null, null, null, null, null, null,'
85 ' null, null, null, null, null, null, null, null, null, null,' 85 ' null, null, null, null, null, null, null, null, null, null,'
86 ' null, null, null, null, null, null, null, null, null, null,' 86 ' null, null, null, null, null, null, null, null, null, null,'
87 ' null, null, null, null]')); 87 ' null, null, null, null]'));
88 } 88 }
89 89
90 testFieldAccess(mirrors) { 90 testFieldAccess(mirrors) {
91 var instance = new Class(); 91 var instance = new Class();
92 92
93 var libMirror = mirrors.findLibrary(#MirrorsTest); 93 var libMirror = mirrors.findLibrary(#MirrorsTest);
94 var classMirror = libMirror.classes[#Class]; 94 var classMirror = libMirror.declarations[#Class];
95 var instMirror = reflect(instance); 95 var instMirror = reflect(instance);
96 var fieldMirror = classMirror.members[#field]; 96 var fieldMirror = classMirror.declarations[#field];
97 var future; 97 var future;
98 98
99 expect(fieldMirror is VariableMirror, isTrue); 99 expect(fieldMirror is VariableMirror, isTrue);
100 expect(fieldMirror.type, equals(mirrors.dynamicType)); 100 expect(fieldMirror.type, equals(mirrors.dynamicType));
101 101
102 libMirror.setField(#topLevelField, [91]); 102 libMirror.setField(#topLevelField, [91]);
103 expect(libMirror.getField(#topLevelField).reflectee, 103 expect(libMirror.getField(#topLevelField).reflectee,
104 equals([91])); 104 equals([91]));
105 expect(topLevelField, equals([91])); 105 expect(topLevelField, equals([91]));
106 } 106 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 var symbolClassMirror = reflectClass(Symbol); 159 var symbolClassMirror = reflectClass(Symbol);
160 var symbolMirror = symbolClassMirror.newInstance(const Symbol(''), 160 var symbolMirror = symbolClassMirror.newInstance(const Symbol(''),
161 ['withInitialValue']); 161 ['withInitialValue']);
162 var objectMirror = classMirror.newInstance(symbolMirror.reflectee,[1234]); 162 var objectMirror = classMirror.newInstance(symbolMirror.reflectee,[1234]);
163 expect(objectMirror.reflectee is Class, equals(true)); 163 expect(objectMirror.reflectee is Class, equals(true));
164 expect(objectMirror.reflectee.field, equals(1234)); 164 expect(objectMirror.reflectee.field, equals(1234));
165 } 165 }
166 166
167 testNames(mirrors) { 167 testNames(mirrors) {
168 var libMirror = mirrors.findLibrary(#MirrorsTest); 168 var libMirror = mirrors.findLibrary(#MirrorsTest);
169 var classMirror = libMirror.classes[#Class]; 169 var classMirror = libMirror.declarations[#Class];
170 var typedefMirror = libMirror.members[#Typedef]; 170 var typedefMirror = libMirror.declarations[#Typedef];
171 var methodMirror = libMirror.functions[#testNames]; 171 var methodMirror = libMirror.declarations[#testNames];
172 var variableMirror = classMirror.variables[#field]; 172 var variableMirror = classMirror.declarations[#field];
173 173
174 expect(libMirror.simpleName, equals(#MirrorsTest)); 174 expect(libMirror.simpleName, equals(#MirrorsTest));
175 expect(libMirror.qualifiedName, equals(#MirrorsTest)); 175 expect(libMirror.qualifiedName, equals(#MirrorsTest));
176 176
177 expect(classMirror.simpleName, equals(#Class)); 177 expect(classMirror.simpleName, equals(#Class));
178 expect(classMirror.qualifiedName, equals(#MirrorsTest.Class)); 178 expect(classMirror.qualifiedName, equals(#MirrorsTest.Class));
179 179
180 TypeVariableMirror typeVariable = classMirror.typeVariables.single; 180 TypeVariableMirror typeVariable = classMirror.typeVariables.single;
181 expect(typeVariable.simpleName, equals(#T)); 181 expect(typeVariable.simpleName, equals(#T));
182 expect(typeVariable.qualifiedName, 182 expect(typeVariable.qualifiedName,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 test("Test current library uri", () { 219 test("Test current library uri", () {
220 testLibraryUri(new Class(), 220 testLibraryUri(new Class(),
221 (Uri uri) => uri.path.endsWith('/mirrors_test.dart')); 221 (Uri uri) => uri.path.endsWith('/mirrors_test.dart'));
222 }); 222 });
223 test("Test dart library uri", () { 223 test("Test dart library uri", () {
224 testLibraryUri("test", (Uri uri) => uri == Uri.parse('dart:core')); 224 testLibraryUri("test", (Uri uri) => uri == Uri.parse('dart:core'));
225 }); 225 });
226 test("Test simple and qualifiedName", () { testNames(mirrors); }); 226 test("Test simple and qualifiedName", () { testNames(mirrors); });
227 test("Test reflect type", () { testReflectClass(mirrors); }); 227 test("Test reflect type", () { testReflectClass(mirrors); });
228 } 228 }
OLDNEW
« no previous file with comments | « tests/lib/mirrors/method_mirror_source_test.dart ('k') | tests/lib/mirrors/mixin_application_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698