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

Side by Side Diff: tests/language/if_null_assignment_behavior_test.dart

Issue 1062723002: Implement the new '?.' operator in analyzer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Bump analyzer version. Created 5 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 | Annotate | Revision Log
OLDNEW
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 // SharedOptions=--enable-null-aware-operators 8 // SharedOptions=--enable-null-aware-operators
9 9
10 import "package:expect/expect.dart"; 10 import "package:expect/expect.dart";
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 check(1, () => f().v ??= bad(), ['f()', 'f().v']); /// 22: continued 187 check(1, () => f().v ??= bad(), ['f()', 'f().v']); /// 22: continued
188 fValue = new C('f()'); yGetValue = 1; /// 23: ok 188 fValue = new C('f()'); yGetValue = 1; /// 23: ok
189 check(1, () => f().v ??= y, ['f()', 'f().v', 'y', 'f().v=1']); /// 23: continu ed 189 check(1, () => f().v ??= y, ['f()', 'f().v', 'y', 'f().v=1']); /// 23: continu ed
190 190
191 // e1[e2] ??= e3 is equivalent to 191 // e1[e2] ??= e3 is equivalent to
192 // ((a, i) => ((x) => x == null ? a[i] = e3 : x)(a[i]))(e1, e2) 192 // ((a, i) => ((x) => x == null ? a[i] = e3 : x)(a[i]))(e1, e2)
193 xGetValue = new C('x'); yGetValue = 1; xGetValue.indexGetValue = 2; /// 24: ok 193 xGetValue = new C('x'); yGetValue = 1; xGetValue.indexGetValue = 2; /// 24: ok
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
198 // e1?.v ??= e2 is equivalent to ((x) => x == null ? null : x.v ??= e2)(e1).
199 check(null, () => x?.v ??= bad(), ['x']); /// 26: ok
200 xGetValue = new C('x'); xGetValue.vGetValue = 1; /// 27: ok
201 check(1, () => x?.v ??= bad(), ['x', 'x.v']); /// 27: continued
202 xGetValue = new C('x'); yGetValue = 1; /// 28: ok
203 check(1, () => x?.v ??= y, ['x', 'x.v', 'y', 'x.v=1']); /// 28: continued
197 } 204 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698