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

Side by Side Diff: tests/language/src/InstanceCompoundAssignmentOperatorTest.dart

Issue 10248007: test rename overhaul: step 8 - language tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012, 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 // Test correct instance compound assignment operator.
5
6 class A {
7 A() : f = 2 {}
8 var f;
9 operator [](index) => f;
10 operator []=(index, value) => f = value;
11
12 var _g = 0;
13 var gGetCount = 0;
14 var gSetCount = 0;
15 get g() {
16 gGetCount++;
17 return _g;
18 }
19 set g(value) {
20 gSetCount++;
21 _g = value;
22 }
23 }
24
25
26 class B {
27 B() : _a = new A(), count = 0 {}
28 get a() {
29 count++;
30 return _a;
31 }
32 var _a;
33 var count;
34 }
35
36 var globalA;
37 var fooCounter = 0;
38 foo() {
39 fooCounter++;
40 return globalA;
41 }
42
43 main() {
44 B b = new B();
45 Expect.equals(0, b.count);
46 Expect.equals(2, b.a.f);
47 Expect.equals(1, b.count);
48 var o = b.a;
49 Expect.equals(2, b.count);
50 b.a.f = 1;
51 Expect.equals(3, b.count);
52 Expect.equals(1, b._a.f);
53 b.a.f += 1;
54 Expect.equals(4, b.count);
55 Expect.equals(2, b._a.f);
56
57 b.count = 0;
58 b._a.f = 2;
59 Expect.equals(0, b.count);
60 Expect.equals(2, b.a[0]);
61 Expect.equals(1, b.count);
62 o = b.a;
63 Expect.equals(2, b.count);
64 b.a[0] = 1;
65 Expect.equals(3, b.count);
66 Expect.equals(1, b._a.f);
67 b.a[0] += 1;
68 Expect.equals(4, b.count);
69 Expect.equals(2, b._a.f);
70
71 b._a.g++;
72 Expect.equals(1, b._a.gGetCount);
73 Expect.equals(1, b._a.gSetCount);
74 Expect.equals(1, b._a._g);
75
76 globalA = b._a;
77 globalA.f = 0;
78 foo().f += 1;
79 Expect.equals(1, fooCounter);
80 Expect.equals(1, globalA.f);
81 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698