| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 // Verify semantics of the ??= operator, including order of operations, by | 5 // Verify semantics of the ??= operator, including order of operations, by |
| 6 // keeping track of the operations performed. | 6 // keeping track of the operations performed. |
| 7 | 7 |
| 8 import "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
| 9 import "if_null_assignment_helper.dart" as h; | 9 import "if_null_assignment_helper.dart" as h; |
| 10 | 10 |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 check(2, () => x[y] ??= bad(), ['x', 'y', 'x[1]']); /// 24: co
ntinued | 194 check(2, () => x[y] ??= bad(), ['x', 'y', 'x[1]']); /// 24: co
ntinued |
| 195 xGetValue = new C('x'); yGetValue = 1; zGetValue = 2; /// 25: ok | 195 xGetValue = new C('x'); yGetValue = 1; zGetValue = 2; /// 25: ok |
| 196 check(2, () => x[y] ??= z, ['x', 'y', 'x[1]', 'z', 'x[1]=2']); /// 25: continu
ed | 196 check(2, () => x[y] ??= z, ['x', 'y', 'x[1]', 'z', 'x[1]=2']); /// 25: continu
ed |
| 197 | 197 |
| 198 // e1?.v ??= e2 is equivalent to ((x) => x == null ? null : x.v ??= e2)(e1). | 198 // e1?.v ??= e2 is equivalent to ((x) => x == null ? null : x.v ??= e2)(e1). |
| 199 check(null, () => x?.v ??= bad(), ['x']); /// 26: ok | 199 check(null, () => x?.v ??= bad(), ['x']); /// 26: ok |
| 200 xGetValue = new C('x'); xGetValue.vGetValue = 1; /// 27: ok | 200 xGetValue = new C('x'); xGetValue.vGetValue = 1; /// 27: ok |
| 201 check(1, () => x?.v ??= bad(), ['x', 'x.v']); /// 27: continued | 201 check(1, () => x?.v ??= bad(), ['x', 'x.v']); /// 27: continued |
| 202 xGetValue = new C('x'); yGetValue = 1; /// 28: ok | 202 xGetValue = new C('x'); yGetValue = 1; /// 28: ok |
| 203 check(1, () => x?.v ??= y, ['x', 'x.v', 'y', 'x.v=1']); /// 28: continued | 203 check(1, () => x?.v ??= y, ['x', 'x.v', 'y', 'x.v=1']); /// 28: continued |
| 204 |
| 205 // C?.v ??= e2 is equivalent to C.v ??= e2. |
| 206 C.xGetValue = 1; /// 29: ok |
| 207 check(1, () => C?.x ??= bad(), ['C.x']); /// 29: continued |
| 208 h.C.xgetValue = 1; /// 30: ok |
| 209 check(1, () => h.c?.x ??= bad(), ['h.C.x']); /// 30: continued |
| 210 yGetValue = 1; /// 31: ok |
| 211 check(1, () => C?.x ??= y, ['C.x', 'y', 'C.x=1']); /// 31: continued |
| 212 yGetValue = 1; /// 32: ok |
| 213 check(1, () => h.C?.x ??= y, ['h.C.x', 'y', 'h.C.x=1']); /// 32: continued |
| 204 } | 214 } |
| OLD | NEW |