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 // TODO(jmesserly): this file needs to be refactored, it's a port from | 5 // TODO(jmesserly): this file needs to be refactored, it's a port from |
6 // package:dev_compiler's tests | 6 // package:dev_compiler's tests |
7 /// General type checking tests | 7 /// General type checking tests |
8 library test.src.task.strong.checker_test; | 8 library test.src.task.strong.checker_test; |
9 | 9 |
10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
(...skipping 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1098 main() { | 1098 main() { |
1099 bool b = true; | 1099 bool b = true; |
1100 num x = b ? 1 : 2.3; | 1100 num x = b ? 1 : 2.3; |
1101 int y = /*info:AssignmentCast*/b ? 1 : 2.3; | 1101 int y = /*info:AssignmentCast*/b ? 1 : 2.3; |
1102 String z = !b ? "hello" : null; | 1102 String z = !b ? "hello" : null; |
1103 z = b ? null : "hello"; | 1103 z = b ? null : "hello"; |
1104 } | 1104 } |
1105 ''' | 1105 ''' |
1106 }); | 1106 }); |
1107 | 1107 |
| 1108 // This is a regression test for https://github.com/dart-lang/sdk/issues/25071 |
| 1109 testChecker('unbound redirecting constructor', { |
| 1110 '/main.dart': ''' |
| 1111 class Foo { |
| 1112 Foo() : this.init(); |
| 1113 } |
| 1114 ''' |
| 1115 }); |
| 1116 |
1108 testChecker('redirecting constructor', { | 1117 testChecker('redirecting constructor', { |
1109 '/main.dart': ''' | 1118 '/main.dart': ''' |
1110 class A { | 1119 class A { |
1111 A(A x) {} | 1120 A(A x) {} |
1112 A.two() : this(/*severe:StaticTypeError*/3); | 1121 A.two() : this(/*severe:StaticTypeError*/3); |
1113 } | 1122 } |
1114 ''' | 1123 ''' |
1115 }); | 1124 }); |
1116 | 1125 |
1117 testChecker('super constructor', { | 1126 testChecker('super constructor', { |
(...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2404 | 2413 |
2405 baz1() sync* { yield* (/*info:DynamicCast*/x); } | 2414 baz1() sync* { yield* (/*info:DynamicCast*/x); } |
2406 Iterable baz2() sync* { yield* (/*info:DynamicCast*/x); } | 2415 Iterable baz2() sync* { yield* (/*info:DynamicCast*/x); } |
2407 Iterable<int> baz3() sync* { yield* (/*warning:DownCastComposite*/x); } | 2416 Iterable<int> baz3() sync* { yield* (/*warning:DownCastComposite*/x); } |
2408 Iterable<int> baz4() sync* { yield* new Iterable<int>(); } | 2417 Iterable<int> baz4() sync* { yield* new Iterable<int>(); } |
2409 Iterable<int> baz5() sync* { yield* (/*info:InferredTypeAllocation*/new
Iterable()); } | 2418 Iterable<int> baz5() sync* { yield* (/*info:InferredTypeAllocation*/new
Iterable()); } |
2410 ''' | 2419 ''' |
2411 }); | 2420 }); |
2412 }); | 2421 }); |
2413 } | 2422 } |
OLD | NEW |