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

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

Issue 1239513005: Switch on null-aware operators by default in analyzer. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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
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
9
10 import "package:expect/expect.dart"; 8 import "package:expect/expect.dart";
11 import "if_null_assignment_helper.dart" as h; 9 import "if_null_assignment_helper.dart" as h;
12 10
13 bad() { 11 bad() {
14 Expect.fail('Should not be executed'); 12 Expect.fail('Should not be executed');
15 } 13 }
16 14
17 var xGetValue = null; 15 var xGetValue = null;
18 16
19 get x { 17 get x {
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 xGetValue = new C('x'); yGetValue = 1; zGetValue = 2; /// 25: ok 195 xGetValue = new C('x'); yGetValue = 1; zGetValue = 2; /// 25: ok
198 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
199 197
200 // 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).
201 check(null, () => x?.v ??= bad(), ['x']); /// 26: ok 199 check(null, () => x?.v ??= bad(), ['x']); /// 26: ok
202 xGetValue = new C('x'); xGetValue.vGetValue = 1; /// 27: ok 200 xGetValue = new C('x'); xGetValue.vGetValue = 1; /// 27: ok
203 check(1, () => x?.v ??= bad(), ['x', 'x.v']); /// 27: continued 201 check(1, () => x?.v ??= bad(), ['x', 'x.v']); /// 27: continued
204 xGetValue = new C('x'); yGetValue = 1; /// 28: ok 202 xGetValue = new C('x'); yGetValue = 1; /// 28: ok
205 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
206 } 204 }
OLDNEW
« no previous file with comments | « tests/language/conditional_property_increment_decrement_test.dart ('k') | tests/language/if_null_assignment_static_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698