OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2016, 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 test.mixin; |
| 6 |
| 7 import 'dart:mirrors'; |
| 8 |
| 9 import 'package:expect/expect.dart'; |
| 10 |
| 11 import 'private_field_helper.dart'; |
| 12 |
| 13 class Foo extends Bar { |
| 14 int _field = 42; |
| 15 |
| 16 static int _staticField = 99; |
| 17 } |
| 18 |
| 19 var privateSymbol = #_field; |
| 20 var publicSymbol = #field; |
| 21 |
| 22 main() { |
| 23 Expect.equals(publicSymbol, publicSymbol2); |
| 24 Expect.notEquals(privateSymbol, privateSymbol2); |
| 25 |
| 26 var foo = new Foo(); |
| 27 var m = reflect(foo); |
| 28 m.setField(privateSymbol, 38); |
| 29 Expect.equals(38, foo._field); |
| 30 m.setField(privateSymbol2, "world"); |
| 31 Expect.equals("world", foo.field); |
| 32 Expect.equals("world", m.getField(publicSymbol).reflectee); |
| 33 |
| 34 var type = reflectClass(Foo); |
| 35 Expect.equals(99, type.getField(#_staticField).reflectee); |
| 36 } |
OLD | NEW |