| 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 1700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1711 const A(num a) : this.fi = /*$error1*/a; | 1711 const A(num a) : this.fi = /*$error1*/a; |
| 1712 } | 1712 } |
| 1713 class B extends A { | 1713 class B extends A { |
| 1714 const B(Object a) : super(/*$error1*/a); | 1714 const B(Object a) : super(/*$error1*/a); |
| 1715 } | 1715 } |
| 1716 void foo(Object o) { | 1716 void foo(Object o) { |
| 1717 var a = const A(/*$error1*/o); | 1717 var a = const A(/*$error1*/o); |
| 1718 } | 1718 } |
| 1719 '''; | 1719 '''; |
| 1720 testChecker( | 1720 testChecker( |
| 1721 {'/main.dart': mk("severe:StaticTypeError", "severe:StaticTypeError")}, | 1721 {'/main.dart': mk("warning:DownCastImplicit", "info:AssignmentCast")}); |
| 1722 allowConstCasts: false); | |
| 1723 testChecker( | |
| 1724 {'/main.dart': mk("warning:DownCastImplicit", "info:AssignmentCast")}, | |
| 1725 allowConstCasts: true); | |
| 1726 }); | 1722 }); |
| 1727 | 1723 |
| 1728 test('casts in conditionals', () { | 1724 test('casts in conditionals', () { |
| 1729 testChecker({ | 1725 testChecker({ |
| 1730 '/main.dart': ''' | 1726 '/main.dart': ''' |
| 1731 main() { | 1727 main() { |
| 1732 bool b = true; | 1728 bool b = true; |
| 1733 num x = b ? 1 : 2.3; | 1729 num x = b ? 1 : 2.3; |
| 1734 int y = /*info:AssignmentCast*/b ? 1 : 2.3; | 1730 int y = /*info:AssignmentCast*/b ? 1 : 2.3; |
| 1735 String z = !b ? "hello" : null; | 1731 String z = !b ? "hello" : null; |
| (...skipping 1296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3032 '/main.dart': ''' | 3028 '/main.dart': ''' |
| 3033 import 'dart:foobar' show Baz; | 3029 import 'dart:foobar' show Baz; |
| 3034 main() { | 3030 main() { |
| 3035 print(Baz.quux); | 3031 print(Baz.quux); |
| 3036 }''' | 3032 }''' |
| 3037 }, | 3033 }, |
| 3038 customUrlMappings: { | 3034 customUrlMappings: { |
| 3039 'dart:foobar': '$testDirectory/checker/dart_foobar.dart' | 3035 'dart:foobar': '$testDirectory/checker/dart_foobar.dart' |
| 3040 })); | 3036 })); |
| 3041 } | 3037 } |
| OLD | NEW |