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 'package:expect/expect.dart'; |
| 6 |
| 7 final values = <int>[]; |
| 8 |
| 9 class Mock { |
| 10 noSuchMethod(Invocation i) { |
| 11 Expect.equals(i.memberName.toString(), 'Symbol("_x")'); |
| 12 values.add(i.positionalArguments[0]); |
| 13 } |
| 14 } |
| 15 |
| 16 class Foo { |
| 17 int _x; |
| 18 } |
| 19 |
| 20 class Bar extends Mock implements Foo { |
| 21 final int _x = 42; |
| 22 } |
| 23 |
| 24 void main() { |
| 25 { |
| 26 Bar b = new Bar(); |
| 27 Expect.equals(b._x, 42); |
| 28 b._x = 123; |
| 29 Expect.listEquals(values, [123]); |
| 30 values.clear(); |
| 31 } |
| 32 { |
| 33 // It works the same if called statically through the Foo interface. |
| 34 Foo b = new Bar(); |
| 35 Expect.equals(b._x, 42); |
| 36 b._x = 123; |
| 37 Expect.listEquals(values, [123]); |
| 38 values.clear(); |
| 39 } |
| 40 } |
OLD | NEW |