| 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 /// General type checking tests | 5 /// General type checking tests |
| 6 library dev_compiler.test.checker_test; | 6 library dev_compiler.test.checker_test; |
| 7 | 7 |
| 8 import 'package:test/test.dart'; | 8 import 'package:test/test.dart'; |
| 9 | 9 |
| 10 import 'package:dev_compiler/src/testing.dart'; | 10 import 'package:dev_compiler/src/testing.dart'; |
| (...skipping 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1064 '/main.dart': ''' | 1064 '/main.dart': ''' |
| 1065 | 1065 |
| 1066 class A { | 1066 class A { |
| 1067 void bar() => null; | 1067 void bar() => null; |
| 1068 void foo() => bar; // allowed | 1068 void foo() => bar; // allowed |
| 1069 } | 1069 } |
| 1070 ''' | 1070 ''' |
| 1071 }); | 1071 }); |
| 1072 }); | 1072 }); |
| 1073 | 1073 |
| 1074 test('Closure wrapping of literals', () { | |
| 1075 testChecker({ | |
| 1076 '/main.dart': ''' | |
| 1077 typedef T F<T>(T t1, T t2); | |
| 1078 typedef dynamic D(t1, t2); | |
| 1079 | |
| 1080 void main() { | |
| 1081 F f1 = (x, y) => /*info:DynamicInvoke*/x + y; | |
| 1082 F<int> f2 = /*warning:ClosureWrapLiteral*/(x, y) => /*info:DynamicInvoke
*/x + y; | |
| 1083 D f3 = (x, y) => /*info:DynamicInvoke*/x + y; | |
| 1084 Function f4 = (x, y) => /*info:DynamicInvoke*/x + y; | |
| 1085 f2 = /*warning:ClosureWrap*/f1; | |
| 1086 f1 = (int x, int y) => x + y; | |
| 1087 f2 = /*severe:StaticTypeError*/(int x) => -x; | |
| 1088 } | |
| 1089 ''' | |
| 1090 }, wrapClosures: true, inferDownwards: false); | |
| 1091 }); | |
| 1092 | |
| 1093 test('Generic subtyping: invariance', () { | 1074 test('Generic subtyping: invariance', () { |
| 1094 testChecker({ | 1075 testChecker({ |
| 1095 '/main.dart': ''' | 1076 '/main.dart': ''' |
| 1096 | 1077 |
| 1097 class A {} | 1078 class A {} |
| 1098 class B extends A {} | 1079 class B extends A {} |
| 1099 class C implements A {} | 1080 class C implements A {} |
| 1100 | 1081 |
| 1101 class L<T> {} | 1082 class L<T> {} |
| 1102 class M<T> extends L<T> {} | 1083 class M<T> extends L<T> {} |
| (...skipping 1925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3028 '/main.dart': ''' | 3009 '/main.dart': ''' |
| 3029 import 'dart:foobar' show Baz; | 3010 import 'dart:foobar' show Baz; |
| 3030 main() { | 3011 main() { |
| 3031 print(Baz.quux); | 3012 print(Baz.quux); |
| 3032 }''' | 3013 }''' |
| 3033 }, | 3014 }, |
| 3034 customUrlMappings: { | 3015 customUrlMappings: { |
| 3035 'dart:foobar': '$testDirectory/checker/dart_foobar.dart' | 3016 'dart:foobar': '$testDirectory/checker/dart_foobar.dart' |
| 3036 })); | 3017 })); |
| 3037 } | 3018 } |
| OLD | NEW |