Chromium Code Reviews| Index: tests/lib/mirrors/mirrors_test.dart |
| =================================================================== |
| --- tests/lib/mirrors/mirrors_test.dart (revision 0) |
| +++ tests/lib/mirrors/mirrors_test.dart (revision 0) |
| @@ -0,0 +1,38 @@ |
| +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +#library("MirrorsTest.dart"); |
| +#import("dart:mirrors"); |
| + |
| + |
|
turnidge
2012/07/17 23:59:33
Add a TODO to move the existing mirrors tests out
|
| +var topLevelField; |
| +topLevelFunction() {} |
| + |
| +class Class { |
| + var field; |
| + static var staticField; |
| +} |
| + |
| +main() { |
| + |
|
turnidge
2012/07/17 23:59:33
No blank line here.
|
| + var instance = new Class(); |
| + |
|
turnidge
2012/07/17 23:59:33
We will eventually have more tests in this file.
|
| + var mirrors = currentMirrorSystem(); |
| + var libMirror = mirrors.rootLibrary; |
| + var classMirror = libMirror.classes()["Class"]; |
| + var instMirror = mirrors.mirrorOf(instance); |
| + |
| + libMirror.setField('topLevelField', 42); |
| + Expect.equals(42, libMirror.getField('topLevelField').value.reflectee ); |
|
turnidge
2012/07/17 23:59:33
It's a little weird for the test to rely on the fu
rmacnak
2012/07/18 00:48:55
But then there should also be some check that the
turnidge
2012/07/18 05:07:35
Yes. I think they have some way of doing this in
rmacnak
2012/07/18 18:04:18
There is no such method on Expect, and I don't see
|
| + Expect.equals(42, topLevelField ); |
| + |
| + classMirror.setField('staticField', 43); |
| + Expect.equals(43, classMirror.getField('staticField').value.reflectee ); |
| + Expect.equals(43, Class.staticField ); |
| + |
| + instMirror.setField('field', 44); |
| + Expect.equals(44, instMirror.getField('field').value.reflectee ); |
| + Expect.equals(44, instance.field ); |
| +} |
| + |