OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 // Dart test for testing the ternary operator. | 4 // Dart test for testing the ternary operator. |
5 | 5 |
6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
7 | 7 |
8 // Test that `Null` acts like the bottom type - less than any other type. | 8 // Test that `Null` acts like the bottom type - less than any other type. |
9 | 9 |
10 bool isCheckedMode = () { | 10 final bool isCheckedMode = (() { |
11 bool c = false; | 11 try { |
12 assert(c = true); | 12 var i = 42; |
13 return c; | 13 String s = i; |
14 }(); | 14 } on TypeError catch (e) { |
| 15 return true; |
| 16 } |
| 17 return false; |
| 18 })(); |
15 | 19 |
16 typedef R Fun<A, R>(A argument); | 20 typedef R Fun<A, R>(A argument); |
17 | 21 |
18 class C<T> { | 22 class C<T> { |
19 const C(); | 23 const C(); |
20 T returns() => null; | 24 T returns() => null; |
21 void accepts(T x) {} | 25 void accepts(T x) {} |
22 } | 26 } |
23 | 27 |
24 class NullBound<T extends num> {} | 28 class NullBound<T extends num> {} |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 Null foo(Null x) => null; | 136 Null foo(Null x) => null; |
133 Null bar(Null x) => null; | 137 Null bar(Null x) => null; |
134 int baz(int x) => x; | 138 int baz(int x) => x; |
135 int qux(int x) => x; | 139 int qux(int x) => x; |
136 } | 140 } |
137 | 141 |
138 // Avoid "variable not used" warnings. | 142 // Avoid "variable not used" warnings. |
139 use(x) { | 143 use(x) { |
140 return identical(x, x); | 144 return identical(x, x); |
141 } | 145 } |
OLD | NEW |