| 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 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 Loading... |
| 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 } |
| OLD | NEW |