| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'package:expect/expect.dart'; | 5 import 'package:expect/expect.dart'; |
| 6 | 6 |
| 7 final values = <int>[]; | 7 final values = <int>[]; |
| 8 | 8 |
| 9 class Mock { | 9 class Mock { |
| 10 noSuchMethod(Invocation i) { | 10 noSuchMethod(Invocation i) { |
| 11 Expect.equals(i.memberName.toString(), 'Symbol("_x")'); | 11 var expected = i.isGetter ? "_x" : "_x="; |
| 12 Expect.equals('Symbol("$expected")', i.memberName.toString()); |
| 12 values.add(i.positionalArguments[0]); | 13 values.add(i.positionalArguments[0]); |
| 13 } | 14 } |
| 14 } | 15 } |
| 15 | 16 |
| 16 class Foo { | 17 class Foo { |
| 17 int _x; | 18 int _x; |
| 18 } | 19 } |
| 19 | 20 |
| 20 class Bar extends Mock implements Foo { | 21 class Bar extends Mock implements Foo { |
| 21 final int _x = 42; | 22 final int _x = 42; |
| 22 } | 23 } |
| 23 | 24 |
| 24 void main() { | 25 void main() { |
| 25 { | 26 { |
| 26 Bar b = new Bar(); | 27 Bar b = new Bar(); |
| 27 Expect.equals(b._x, 42); | 28 Expect.equals(b._x, 42); |
| 28 b._x = 123; | 29 b._x = 123; |
| 29 Expect.listEquals(values, [123]); | 30 Expect.listEquals(values, [123]); |
| 30 values.clear(); | 31 values.clear(); |
| 31 } | 32 } |
| 32 { | 33 { |
| 33 // It works the same if called statically through the Foo interface. | 34 // It works the same if called statically through the Foo interface. |
| 34 Foo b = new Bar(); | 35 Foo b = new Bar(); |
| 35 Expect.equals(b._x, 42); | 36 Expect.equals(b._x, 42); |
| 36 b._x = 123; | 37 b._x = 123; |
| 37 Expect.listEquals(values, [123]); | 38 Expect.listEquals(values, [123]); |
| 38 values.clear(); | 39 values.clear(); |
| 39 } | 40 } |
| 40 } | 41 } |
| OLD | NEW |