| 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 ddc.test.checker_test; | 6 library ddc.test.checker_test; |
| 7 | 7 |
| 8 import 'package:unittest/compact_vm_config.dart'; | 8 import 'package:unittest/compact_vm_config.dart'; |
| 9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
| 10 | 10 |
| (...skipping 1429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1440 l2 = /*warning:DownCastDynamic*/l1; | 1440 l2 = /*warning:DownCastDynamic*/l1; |
| 1441 | 1441 |
| 1442 l2 = /*warning:DownCastExact*/new List(); | 1442 l2 = /*warning:DownCastExact*/new List(); |
| 1443 l2 = /*warning:DownCastExact*/new List(10); | 1443 l2 = /*warning:DownCastExact*/new List(10); |
| 1444 l2 = /*warning:DownCastExact*/new List.filled(10, 42); | 1444 l2 = /*warning:DownCastExact*/new List.filled(10, 42); |
| 1445 } | 1445 } |
| 1446 ''' | 1446 ''' |
| 1447 }); | 1447 }); |
| 1448 }); | 1448 }); |
| 1449 | 1449 |
| 1450 test('Type checking literals', () { |
| 1451 testChecker({ |
| 1452 '/main.dart': ''' |
| 1453 test() { |
| 1454 num n = 3; |
| 1455 int i = 3; |
| 1456 String s = "hello"; |
| 1457 { |
| 1458 List<int> l = <int>[i]; |
| 1459 l = <int>[/*severe:StaticTypeError*/s]; |
| 1460 l = <int>[/*info:DownCast*/n]; |
| 1461 l = <int>[i, /*info:DownCast*/n, /*severe:StaticTypeError*/s]; |
| 1462 } |
| 1463 { |
| 1464 List l = [i]; |
| 1465 l = [s]; |
| 1466 l = [n]; |
| 1467 l = [i, n, s]; |
| 1468 } |
| 1469 { |
| 1470 Map<String, int> m = <String, int>{s: i}; |
| 1471 m = <String, int>{s: /*severe:StaticTypeError*/s}; |
| 1472 m = <String, int>{s: /*info:DownCast*/n}; |
| 1473 m = <String, int>{s: i, |
| 1474 s: /*info:DownCast*/n, |
| 1475 s: /*severe:StaticTypeError*/s}; |
| 1476 } |
| 1477 // TODO(leafp): We can't currently test for key errors since the |
| 1478 // error marker binds to the entire entry. |
| 1479 { |
| 1480 Map m = {s: i}; |
| 1481 m = {s: s}; |
| 1482 m = {s: n}; |
| 1483 m = {s: i, |
| 1484 s: n, |
| 1485 s: s}; |
| 1486 m = {i: s, |
| 1487 n: s, |
| 1488 s: s}; |
| 1489 } |
| 1490 } |
| 1491 ''' |
| 1492 }); |
| 1493 }); |
| 1494 |
| 1450 test('redirecting constructor', () { | 1495 test('redirecting constructor', () { |
| 1451 testChecker({ | 1496 testChecker({ |
| 1452 '/main.dart': ''' | 1497 '/main.dart': ''' |
| 1453 class A { | 1498 class A { |
| 1454 A(A x) {} | 1499 A(A x) {} |
| 1455 A.two() : this(/*severe:StaticTypeError*/3); | 1500 A.two() : this(/*severe:StaticTypeError*/3); |
| 1456 } | 1501 } |
| 1457 ''' | 1502 ''' |
| 1458 }); | 1503 }); |
| 1459 }); | 1504 }); |
| (...skipping 1143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2603 '/main.dart': ''' | 2648 '/main.dart': ''' |
| 2604 class A {} | 2649 class A {} |
| 2605 class T1 implements A { | 2650 class T1 implements A { |
| 2606 /*severe:InferableOverride*/toString() {} | 2651 /*severe:InferableOverride*/toString() {} |
| 2607 } | 2652 } |
| 2608 ''' | 2653 ''' |
| 2609 }, inferFromOverrides: false); | 2654 }, inferFromOverrides: false); |
| 2610 }); | 2655 }); |
| 2611 }); | 2656 }); |
| 2612 } | 2657 } |
| OLD | NEW |