Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: tests/language_strong/mock_writable_final_field_test.dart

Issue 2803673007: fix #29233, final fields can be settable in a mock (Closed)
Patch Set: fix Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698