OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2017, 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 import 'dart:mirrors'; |
| 6 import 'package:expect/expect.dart'; |
| 7 |
| 8 class Bar { |
| 9 final String name; |
| 10 |
| 11 const Bar(this.name); |
| 12 } |
| 13 |
| 14 class Foo { |
| 15 @Bar('bar') |
| 16 int x = 40; |
| 17 |
| 18 @Bar('baz') |
| 19 final String y = 'hi'; |
| 20 } |
| 21 |
| 22 void main() { |
| 23 dynamic f = new Foo(); |
| 24 Expect.throws(() { |
| 25 f.x = 'hello'; |
| 26 }); |
| 27 f.x += 2; |
| 28 Expect.equals(f.x, 42); |
| 29 Expect.equals(f.y, 'hi'); |
| 30 |
| 31 var members = reflect(f).type.declarations; |
| 32 var x = members[#x] as VariableMirror; |
| 33 var y = members[#y] as VariableMirror; |
| 34 Expect.equals(x.type.simpleName, #int); |
| 35 Expect.equals(y.type.simpleName, #String); |
| 36 } |
OLD | NEW |