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

Side by Side Diff: tests/language/if_null_precedence_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 that '??' binds tighter than '?:' and less tightly than '||'. 5 // Verify that '??' binds tighter than '?:' and less tightly than '||'.
6 6
7 // SharedOptions=--enable-null-aware-operators
8
9 import "package:expect/expect.dart"; 7 import "package:expect/expect.dart";
10 8
11 assertionError(e) => e is AssertionError; 9 assertionError(e) => e is AssertionError;
12 10
13 // Determine whether the VM is running in checked mode. 11 // Determine whether the VM is running in checked mode.
14 bool get checkedMode { 12 bool get checkedMode {
15 try { 13 try {
16 var x = 'foo'; 14 var x = 'foo';
17 int y = x; 15 int y = x;
18 return false; 16 return false;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 // An incorrect parse of "a || (b ?? c)" would result in no checked-mode 55 // An incorrect parse of "a || (b ?? c)" would result in no checked-mode
58 // error. 56 // error.
59 Expect.throws(() => false || null ?? true, assertionError); /// 08: ok 57 Expect.throws(() => false || null ?? true, assertionError); /// 08: ok
60 } else { 58 } else {
61 // An incorrect parse of "a || (b ?? c)" would result in c being evaluated. 59 // An incorrect parse of "a || (b ?? c)" would result in c being evaluated.
62 int i = 0; /// 08: continue d 60 int i = 0; /// 08: continue d
63 Expect.equals(false, false || null ?? i++ == 0); /// 08: continue d 61 Expect.equals(false, false || null ?? i++ == 0); /// 08: continue d
64 Expect.equals(0, i); /// 08: continue d 62 Expect.equals(0, i); /// 08: continue d
65 } 63 }
66 } 64 }
OLDNEW
« no previous file with comments | « tests/language/if_null_evaluation_order_test.dart ('k') | tests/language/nullaware_opt_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698