OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 // Test various setter situations, testing special cases in optimizing compiler. | 4 // Test various setter situations, testing special cases in optimizing compiler. |
5 | 5 |
6 class A { | 6 class A { |
7 int field = 0; | 7 int field = 0; |
8 } | 8 } |
9 | 9 |
10 class B extends A { | 10 class B extends A { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 var r = maybeSet(a, 6, true); | 58 var r = maybeSet(a, 6, true); |
59 Expect.equals(6, a.field); | 59 Expect.equals(6, a.field); |
60 Expect.equals(6, r); | 60 Expect.equals(6, r); |
61 } | 61 } |
62 } | 62 } |
63 | 63 |
64 // Check non-implicit setter | 64 // Check non-implicit setter |
65 class X { | 65 class X { |
66 int pField = 0; | 66 int pField = 0; |
67 set field(v) { pField = v; } | 67 set field(v) { pField = v; } |
68 get field() => 10; | 68 get field => 10; |
69 } | 69 } |
70 | 70 |
71 void sameNotImplicitSetter() { | 71 void sameNotImplicitSetter() { |
72 oneTarget(var a, var v) { | 72 oneTarget(var a, var v) { |
73 return a.field = v; | 73 return a.field = v; |
74 } | 74 } |
75 | 75 |
76 incField(var a) { | 76 incField(var a) { |
77 a.field++; | 77 a.field++; |
78 } | 78 } |
(...skipping 30 matching lines...) Expand all Loading... |
109 Expect.equals(5, r); | 109 Expect.equals(5, r); |
110 r = oneTarget(y, 6); | 110 r = oneTarget(y, 6); |
111 Expect.equals(6, y.field); | 111 Expect.equals(6, y.field); |
112 Expect.equals(6, r); | 112 Expect.equals(6, r); |
113 } | 113 } |
114 } | 114 } |
115 | 115 |
116 class Z { | 116 class Z { |
117 int pField = 0; | 117 int pField = 0; |
118 set field(v) { pField = v; } | 118 set field(v) { pField = v; } |
119 get field() => 10; | 119 get field => 10; |
120 } | 120 } |
121 | 121 |
122 multiNotImplicitSetter() { | 122 multiNotImplicitSetter() { |
123 oneTarget(var a, var v) { | 123 oneTarget(var a, var v) { |
124 return a.field = v; | 124 return a.field = v; |
125 } | 125 } |
126 | 126 |
127 Y y = new Y(); | 127 Y y = new Y(); |
128 Z z = new Z(); | 128 Z z = new Z(); |
129 for (int i = 0; i < 2000; i++) { | 129 for (int i = 0; i < 2000; i++) { |
(...skipping 12 matching lines...) Expand all Loading... |
142 | 142 |
143 void main() { | 143 void main() { |
144 for (int i = 0; i< 2000; i++) {} | 144 for (int i = 0; i< 2000; i++) {} |
145 sameImplicitSetter(); | 145 sameImplicitSetter(); |
146 setterNoFeedback(); | 146 setterNoFeedback(); |
147 sameNotImplicitSetter(); | 147 sameNotImplicitSetter(); |
148 | 148 |
149 multiImplicitSetter(); | 149 multiImplicitSetter(); |
150 multiNotImplicitSetter(); | 150 multiNotImplicitSetter(); |
151 } | 151 } |
OLD | NEW |