| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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.compile_time_error_code_test; | 5 library analyzer.test.generated.compile_time_error_code_test; |
| 6 | 6 |
| 7 import 'package:analyzer/src/generated/error.dart'; | 7 import 'package:analyzer/src/generated/error.dart'; |
| 8 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; | 8 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; |
| 9 import 'package:analyzer/src/generated/source_io.dart'; | 9 import 'package:analyzer/src/generated/source_io.dart'; |
| 10 | 10 |
| (...skipping 1444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1455 Source source = addSource(r''' | 1455 Source source = addSource(r''' |
| 1456 class T { | 1456 class T { |
| 1457 T(a, b, {c, d}) {} | 1457 T(a, b, {c, d}) {} |
| 1458 } | 1458 } |
| 1459 f() { return const T(0, 1, c: 2, d: 3); }'''); | 1459 f() { return const T(0, 1, c: 2, d: 3); }'''); |
| 1460 computeLibrarySourceErrors(source); | 1460 computeLibrarySourceErrors(source); |
| 1461 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_NON_CONST]); | 1461 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_NON_CONST]); |
| 1462 verify([source]); | 1462 verify([source]); |
| 1463 } | 1463 } |
| 1464 | 1464 |
| 1465 void test_constWithNonConst_with() { |
| 1466 Source source = addSource(r''' |
| 1467 class B { |
| 1468 const B(); |
| 1469 } |
| 1470 class C = B with M; |
| 1471 class M {} |
| 1472 const x = const C(); |
| 1473 main() { |
| 1474 print(x); |
| 1475 } |
| 1476 '''); |
| 1477 computeLibrarySourceErrors(source); |
| 1478 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_NON_CONST]); |
| 1479 verify([source]); |
| 1480 } |
| 1481 |
| 1465 void test_constWithNonConstantArgument_annotation() { | 1482 void test_constWithNonConstantArgument_annotation() { |
| 1466 Source source = addSource(r''' | 1483 Source source = addSource(r''' |
| 1467 class A { | 1484 class A { |
| 1468 const A(int p); | 1485 const A(int p); |
| 1469 } | 1486 } |
| 1470 var v = 42; | 1487 var v = 42; |
| 1471 @A(v) | 1488 @A(v) |
| 1472 main() { | 1489 main() { |
| 1473 }'''); | 1490 }'''); |
| 1474 computeLibrarySourceErrors(source); | 1491 computeLibrarySourceErrors(source); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1662 r''' | 1679 r''' |
| 1663 part of lib; | 1680 part of lib; |
| 1664 | 1681 |
| 1665 class A {}'''); | 1682 class A {}'''); |
| 1666 computeLibrarySourceErrors(librarySource); | 1683 computeLibrarySourceErrors(librarySource); |
| 1667 assertErrors(sourceB, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); | 1684 assertErrors(sourceB, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); |
| 1668 assertNoErrors(librarySource); | 1685 assertNoErrors(librarySource); |
| 1669 verify([librarySource, sourceA, sourceB]); | 1686 verify([librarySource, sourceA, sourceB]); |
| 1670 } | 1687 } |
| 1671 | 1688 |
| 1672 void test_duplicateDefinition_inPart() { | |
| 1673 Source librarySource = addNamedSource( | |
| 1674 "/lib.dart", | |
| 1675 r''' | |
| 1676 library test; | |
| 1677 part 'a.dart'; | |
| 1678 class A {}'''); | |
| 1679 Source sourceA = addNamedSource( | |
| 1680 "/a.dart", | |
| 1681 r''' | |
| 1682 part of test; | |
| 1683 class A {}'''); | |
| 1684 computeLibrarySourceErrors(librarySource); | |
| 1685 assertErrors(sourceA, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); | |
| 1686 assertNoErrors(librarySource); | |
| 1687 verify([librarySource, sourceA]); | |
| 1688 } | |
| 1689 | |
| 1690 void test_duplicateDefinition_catch() { | 1689 void test_duplicateDefinition_catch() { |
| 1691 Source source = addSource(r''' | 1690 Source source = addSource(r''' |
| 1692 main() { | 1691 main() { |
| 1693 try {} catch (e, e) {} | 1692 try {} catch (e, e) {} |
| 1694 }'''); | 1693 }'''); |
| 1695 computeLibrarySourceErrors(source); | 1694 computeLibrarySourceErrors(source); |
| 1696 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); | 1695 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); |
| 1697 verify([source]); | 1696 verify([source]); |
| 1698 } | 1697 } |
| 1699 | 1698 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1723 Source source = addSource(r''' | 1722 Source source = addSource(r''' |
| 1724 class A { | 1723 class A { |
| 1725 m() {} | 1724 m() {} |
| 1726 m() {} | 1725 m() {} |
| 1727 }'''); | 1726 }'''); |
| 1728 computeLibrarySourceErrors(source); | 1727 computeLibrarySourceErrors(source); |
| 1729 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); | 1728 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); |
| 1730 verify([source]); | 1729 verify([source]); |
| 1731 } | 1730 } |
| 1732 | 1731 |
| 1732 void test_duplicateDefinition_inPart() { |
| 1733 Source librarySource = addNamedSource( |
| 1734 "/lib.dart", |
| 1735 r''' |
| 1736 library test; |
| 1737 part 'a.dart'; |
| 1738 class A {}'''); |
| 1739 Source sourceA = addNamedSource( |
| 1740 "/a.dart", |
| 1741 r''' |
| 1742 part of test; |
| 1743 class A {}'''); |
| 1744 computeLibrarySourceErrors(librarySource); |
| 1745 assertErrors(sourceA, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); |
| 1746 assertNoErrors(librarySource); |
| 1747 verify([librarySource, sourceA]); |
| 1748 } |
| 1749 |
| 1733 void test_duplicateDefinition_locals_inCase() { | 1750 void test_duplicateDefinition_locals_inCase() { |
| 1734 Source source = addSource(r''' | 1751 Source source = addSource(r''' |
| 1735 main() { | 1752 main() { |
| 1736 switch(1) { | 1753 switch(1) { |
| 1737 case 1: | 1754 case 1: |
| 1738 var a; | 1755 var a; |
| 1739 var a; | 1756 var a; |
| 1740 } | 1757 } |
| 1741 }'''); | 1758 }'''); |
| 1742 computeLibrarySourceErrors(source); | 1759 computeLibrarySourceErrors(source); |
| (...skipping 4524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6267 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]); | 6284 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]); |
| 6268 verify([source]); | 6285 verify([source]); |
| 6269 reset(); | 6286 reset(); |
| 6270 } | 6287 } |
| 6271 | 6288 |
| 6272 void _check_wrongNumberOfParametersForOperator1(String name) { | 6289 void _check_wrongNumberOfParametersForOperator1(String name) { |
| 6273 _check_wrongNumberOfParametersForOperator(name, ""); | 6290 _check_wrongNumberOfParametersForOperator(name, ""); |
| 6274 _check_wrongNumberOfParametersForOperator(name, "a, b"); | 6291 _check_wrongNumberOfParametersForOperator(name, "a, b"); |
| 6275 } | 6292 } |
| 6276 } | 6293 } |
| OLD | NEW |