Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 #library("MirrorsTest.dart"); | |
| 6 #import("dart:mirrors"); | |
| 7 | |
| 8 | |
|
turnidge
2012/07/17 23:59:33
Add a TODO to move the existing mirrors tests out
| |
| 9 var topLevelField; | |
| 10 topLevelFunction() {} | |
| 11 | |
| 12 class Class { | |
| 13 var field; | |
| 14 static var staticField; | |
| 15 } | |
| 16 | |
| 17 main() { | |
| 18 | |
|
turnidge
2012/07/17 23:59:33
No blank line here.
| |
| 19 var instance = new Class(); | |
| 20 | |
|
turnidge
2012/07/17 23:59:33
We will eventually have more tests in this file.
| |
| 21 var mirrors = currentMirrorSystem(); | |
| 22 var libMirror = mirrors.rootLibrary; | |
| 23 var classMirror = libMirror.classes()["Class"]; | |
| 24 var instMirror = mirrors.mirrorOf(instance); | |
| 25 | |
| 26 libMirror.setField('topLevelField', 42); | |
| 27 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
| |
| 28 Expect.equals(42, topLevelField ); | |
| 29 | |
| 30 classMirror.setField('staticField', 43); | |
| 31 Expect.equals(43, classMirror.getField('staticField').value.reflectee ); | |
| 32 Expect.equals(43, Class.staticField ); | |
| 33 | |
| 34 instMirror.setField('field', 44); | |
| 35 Expect.equals(44, instMirror.getField('field').value.reflectee ); | |
| 36 Expect.equals(44, instance.field ); | |
| 37 } | |
| 38 | |
| OLD | NEW |