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 | 4 |
5 library analyzer.test.generated.strong_mode_test; | 5 library analyzer.test.generated.strong_mode_test; |
6 | 6 |
7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
8 import 'package:analyzer/dart/element/element.dart'; | 8 import 'package:analyzer/dart/element/element.dart'; |
9 import 'package:analyzer/dart/element/type.dart'; | 9 import 'package:analyzer/dart/element/type.dart'; |
10 import 'package:analyzer/src/dart/element/element.dart'; | 10 import 'package:analyzer/src/dart/element/element.dart'; |
(...skipping 2028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2039 verify([source]); | 2039 verify([source]); |
2040 } | 2040 } |
2041 | 2041 |
2042 void test_ternaryOperator_null_left() { | 2042 void test_ternaryOperator_null_left() { |
2043 String code = r''' | 2043 String code = r''' |
2044 main() { | 2044 main() { |
2045 var foo = (true) ? null : 3; | 2045 var foo = (true) ? null : 3; |
2046 } | 2046 } |
2047 '''; | 2047 '''; |
2048 resolveTestUnit(code); | 2048 resolveTestUnit(code); |
2049 expectInitializerType('foo', 'int', isNull); | 2049 expectInitializerType('foo', 'dynamic', isNull); |
Jennifer Messerly
2016/08/04 13:10:16
This case is really unfortunate and makes me doubt
Leaf
2016/08/04 23:52:55
Yeah, I think this will cause problems. I think i
Jennifer Messerly
2016/08/05 13:46:36
Yeah, definitely doesn't seem right at the moment.
| |
2050 } | 2050 } |
2051 | 2051 |
2052 void test_ternaryOperator_null_right() { | 2052 void test_ternaryOperator_null_right() { |
2053 String code = r''' | 2053 String code = r''' |
2054 main() { | 2054 main() { |
2055 var foo = (true) ? 3 : null; | 2055 var foo = (true) ? 3 : null; |
2056 } | 2056 } |
2057 '''; | 2057 '''; |
2058 resolveTestUnit(code); | 2058 resolveTestUnit(code); |
2059 expectInitializerType('foo', 'int', isNull); | 2059 expectInitializerType('foo', 'dynamic', isNull); |
2060 } | 2060 } |
2061 } | 2061 } |
2062 | 2062 |
2063 @reflectiveTest | 2063 @reflectiveTest |
2064 class StrongModeTypePropagationTest extends ResolverTestCase { | 2064 class StrongModeTypePropagationTest extends ResolverTestCase { |
2065 @override | 2065 @override |
2066 void setUp() { | 2066 void setUp() { |
2067 super.setUp(); | 2067 super.setUp(); |
2068 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); | 2068 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); |
2069 options.strongMode = true; | 2069 options.strongMode = true; |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2308 main() { | 2308 main() { |
2309 var v = x; | 2309 var v = x; |
2310 v; // marker | 2310 v; // marker |
2311 } | 2311 } |
2312 int x = 3; | 2312 int x = 3; |
2313 '''; | 2313 '''; |
2314 assertPropagatedAssignedType(code, typeProvider.intType, null); | 2314 assertPropagatedAssignedType(code, typeProvider.intType, null); |
2315 assertTypeOfMarkedExpression(code, typeProvider.intType, null); | 2315 assertTypeOfMarkedExpression(code, typeProvider.intType, null); |
2316 } | 2316 } |
2317 } | 2317 } |
OLD | NEW |