Chromium Code Reviews| 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 library analyzer.test.src.summary.summary_common; | 5 library analyzer.test.src.summary.summary_common; |
| 6 | 6 |
| 7 import 'package:analyzer/analyzer.dart'; | 7 import 'package:analyzer/analyzer.dart'; |
| 8 import 'package:analyzer/dart/ast/ast.dart'; | 8 import 'package:analyzer/dart/ast/ast.dart'; |
| 9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
| 10 import 'package:analyzer/src/generated/engine.dart'; | 10 import 'package:analyzer/src/generated/engine.dart'; |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 41 analysisContext.typeProvider.objectType.element.library, | 41 analysisContext.typeProvider.objectType.element.library, |
| 42 analysisContext.typeProvider.futureType.element.library | 42 analysisContext.typeProvider.futureType.element.library |
| 43 ]; | 43 ]; |
| 44 for (LibraryElement library in libraries) { | 44 for (LibraryElement library in libraries) { |
| 45 summarize_elements.LibrarySerializationResult serializedLibrary = | 45 summarize_elements.LibrarySerializationResult serializedLibrary = |
| 46 summarize_elements.serializeLibrary( | 46 summarize_elements.serializeLibrary( |
| 47 library, analysisContext.typeProvider); | 47 library, analysisContext.typeProvider); |
| 48 for (int i = 0; i < serializedLibrary.unlinkedUnits.length; i++) { | 48 for (int i = 0; i < serializedLibrary.unlinkedUnits.length; i++) { |
| 49 uriToNamespace[serializedLibrary.unitUris[i]] = | 49 uriToNamespace[serializedLibrary.unitUris[i]] = |
| 50 new UnlinkedUnit.fromBuffer( | 50 new UnlinkedUnit.fromBuffer( |
| 51 serializedLibrary.unlinkedUnits[i].toBuffer()) | 51 serializedLibrary.unlinkedUnits[i].toBuffer()).publicNamespace; |
| 52 .publicNamespace; | |
| 53 } | 52 } |
| 54 } | 53 } |
| 55 return uriToNamespace; | 54 return uriToNamespace; |
| 56 } catch (_) { | 55 } catch (_) { |
| 57 return null; | 56 return null; |
| 58 } | 57 } |
| 59 }(); | 58 }(); |
| 60 | 59 |
| 61 /** | 60 /** |
| 62 * Convert a summary object (or a portion of one) into a canonical form that | 61 * Convert a summary object (or a portion of one) into a canonical form that |
| (...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 755 | 754 |
| 756 /** | 755 /** |
| 757 * Serialize a type declaration using the given [text] as a type name, and | 756 * Serialize a type declaration using the given [text] as a type name, and |
| 758 * return a summary of the corresponding [EntityRef]. If the type | 757 * return a summary of the corresponding [EntityRef]. If the type |
| 759 * declaration needs to refer to types that are not available in core, those | 758 * declaration needs to refer to types that are not available in core, those |
| 760 * types may be declared in [otherDeclarations]. | 759 * types may be declared in [otherDeclarations]. |
| 761 */ | 760 */ |
| 762 EntityRef serializeTypeText(String text, | 761 EntityRef serializeTypeText(String text, |
| 763 {String otherDeclarations: '', bool allowErrors: false}) { | 762 {String otherDeclarations: '', bool allowErrors: false}) { |
| 764 return serializeVariableText('$otherDeclarations\n$text v;', | 763 return serializeVariableText('$otherDeclarations\n$text v;', |
| 765 allowErrors: allowErrors) | 764 allowErrors: allowErrors).type; |
| 766 .type; | |
| 767 } | 765 } |
| 768 | 766 |
| 769 /** | 767 /** |
| 770 * Serialize the given library [text] and return the summary of the variable | 768 * Serialize the given library [text] and return the summary of the variable |
| 771 * with the given [variableName]. | 769 * with the given [variableName]. |
| 772 */ | 770 */ |
| 773 UnlinkedVariable serializeVariableText(String text, | 771 UnlinkedVariable serializeVariableText(String text, |
| 774 {String variableName: 'v', bool allowErrors: false}) { | 772 {String variableName: 'v', bool allowErrors: false}) { |
| 775 serializeLibraryText(text, allowErrors: allowErrors); | 773 serializeLibraryText(text, allowErrors: allowErrors); |
| 776 return findVariable(variableName, failIfAbsent: true); | 774 return findVariable(variableName, failIfAbsent: true); |
| (...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1551 '' | 1549 '' |
| 1552 ], referenceValidators: [ | 1550 ], referenceValidators: [ |
| 1553 (EntityRef r) => checkTypeRef(r, null, null, 'C', | 1551 (EntityRef r) => checkTypeRef(r, null, null, 'C', |
| 1554 expectedKind: ReferenceKind.classOrEnum) | 1552 expectedKind: ReferenceKind.classOrEnum) |
| 1555 ]); | 1553 ]); |
| 1556 } | 1554 } |
| 1557 | 1555 |
| 1558 test_constExpr_length() { | 1556 test_constExpr_length() { |
| 1559 UnlinkedVariable variable = | 1557 UnlinkedVariable variable = |
| 1560 serializeVariableText('const v = "abc".length;'); | 1558 serializeVariableText('const v = "abc".length;'); |
| 1561 _assertUnlinkedConst(variable.constExpr, operators: [ | 1559 _assertUnlinkedConst(variable.constExpr, |
| 1562 UnlinkedConstOperation.pushString, | 1560 operators: |
| 1563 UnlinkedConstOperation.length | 1561 [UnlinkedConstOperation.pushString, UnlinkedConstOperation.length], |
| 1564 ], strings: [ | 1562 strings: ['abc']); |
| 1565 'abc' | |
| 1566 ]); | |
| 1567 } | 1563 } |
| 1568 | 1564 |
| 1569 test_constExpr_makeList_typed() { | 1565 test_constExpr_makeList_typed() { |
| 1570 UnlinkedVariable variable = | 1566 UnlinkedVariable variable = |
| 1571 serializeVariableText('const v = const <int>[11, 22, 33];'); | 1567 serializeVariableText('const v = const <int>[11, 22, 33];'); |
| 1572 _assertUnlinkedConst(variable.constExpr, operators: [ | 1568 _assertUnlinkedConst(variable.constExpr, operators: [ |
| 1573 UnlinkedConstOperation.pushInt, | 1569 UnlinkedConstOperation.pushInt, |
| 1574 UnlinkedConstOperation.pushInt, | 1570 UnlinkedConstOperation.pushInt, |
| 1575 UnlinkedConstOperation.pushInt, | 1571 UnlinkedConstOperation.pushInt, |
| 1576 UnlinkedConstOperation.makeList | 1572 UnlinkedConstOperation.makeTypedList |
| 1577 ], ints: [ | 1573 ], ints: [ |
| 1578 11, | 1574 11, |
| 1579 22, | 1575 22, |
| 1580 33, | 1576 33, |
| 1581 3 | 1577 3 |
| 1582 ], referenceValidators: [ | 1578 ], referenceValidators: [ |
| 1583 (EntityRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'int', | 1579 (EntityRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'int', |
| 1584 expectedKind: ReferenceKind.classOrEnum) | 1580 expectedKind: ReferenceKind.classOrEnum) |
| 1585 ]); | 1581 ]); |
| 1586 } | 1582 } |
| 1587 | 1583 |
| 1588 test_constExpr_makeList_untyped() { | 1584 test_constExpr_makeList_typed_dynamic() { |
| 1589 UnlinkedVariable variable = | 1585 UnlinkedVariable variable = |
| 1590 serializeVariableText('const v = const [11, 22, 33];'); | 1586 serializeVariableText('const v = const <dynamic>[11, 22, 33];'); |
| 1591 _assertUnlinkedConst(variable.constExpr, operators: [ | 1587 _assertUnlinkedConst(variable.constExpr, operators: [ |
| 1592 UnlinkedConstOperation.pushInt, | 1588 UnlinkedConstOperation.pushInt, |
| 1593 UnlinkedConstOperation.pushInt, | 1589 UnlinkedConstOperation.pushInt, |
| 1594 UnlinkedConstOperation.pushInt, | 1590 UnlinkedConstOperation.pushInt, |
| 1595 UnlinkedConstOperation.makeList | 1591 UnlinkedConstOperation.makeTypedList |
| 1596 ], ints: [ | 1592 ], ints: [ |
| 1597 11, | 1593 11, |
| 1598 22, | 1594 22, |
| 1599 33, | 1595 33, |
| 1600 3 | 1596 3 |
| 1601 ], referenceValidators: [ | 1597 ], referenceValidators: [ |
| 1602 (EntityRef r) => checkDynamicTypeRef(r) | 1598 (EntityRef r) => checkDynamicTypeRef(r) |
| 1603 ]); | 1599 ]); |
| 1604 } | 1600 } |
| 1605 | 1601 |
| 1602 test_constExpr_makeList_untyped() { | |
|
scheglov
2016/01/22 19:39:52
I try to name tests using the name of the operatio
Paul Berry
2016/01/22 19:54:38
Done.
| |
| 1603 UnlinkedVariable variable = | |
| 1604 serializeVariableText('const v = const [11, 22, 33];'); | |
| 1605 _assertUnlinkedConst(variable.constExpr, operators: [ | |
| 1606 UnlinkedConstOperation.pushInt, | |
| 1607 UnlinkedConstOperation.pushInt, | |
| 1608 UnlinkedConstOperation.pushInt, | |
| 1609 UnlinkedConstOperation.makeUntypedList | |
| 1610 ], ints: [ | |
| 1611 11, | |
| 1612 22, | |
| 1613 33, | |
| 1614 3 | |
| 1615 ]); | |
| 1616 } | |
| 1617 | |
| 1606 test_constExpr_makeMap_typed() { | 1618 test_constExpr_makeMap_typed() { |
| 1607 UnlinkedVariable variable = serializeVariableText( | 1619 UnlinkedVariable variable = serializeVariableText( |
| 1608 'const v = const <int, String>{11: "aaa", 22: "bbb", 33: "ccc"};'); | 1620 'const v = const <int, String>{11: "aaa", 22: "bbb", 33: "ccc"};'); |
| 1609 _assertUnlinkedConst(variable.constExpr, operators: [ | 1621 _assertUnlinkedConst(variable.constExpr, operators: [ |
| 1610 UnlinkedConstOperation.pushInt, | 1622 UnlinkedConstOperation.pushInt, |
| 1611 UnlinkedConstOperation.pushString, | 1623 UnlinkedConstOperation.pushString, |
| 1612 UnlinkedConstOperation.pushInt, | 1624 UnlinkedConstOperation.pushInt, |
| 1613 UnlinkedConstOperation.pushString, | 1625 UnlinkedConstOperation.pushString, |
| 1614 UnlinkedConstOperation.pushInt, | 1626 UnlinkedConstOperation.pushInt, |
| 1615 UnlinkedConstOperation.pushString, | 1627 UnlinkedConstOperation.pushString, |
| 1616 UnlinkedConstOperation.makeMap | 1628 UnlinkedConstOperation.makeTypedMap |
| 1617 ], ints: [ | 1629 ], ints: [ |
| 1618 11, | 1630 11, |
| 1619 22, | 1631 22, |
| 1620 33, | 1632 33, |
| 1621 3 | 1633 3 |
| 1622 ], strings: [ | 1634 ], strings: [ |
| 1623 'aaa', | 1635 'aaa', |
| 1624 'bbb', | 1636 'bbb', |
| 1625 'ccc' | 1637 'ccc' |
| 1626 ], referenceValidators: [ | 1638 ], referenceValidators: [ |
| 1627 (EntityRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'int', | 1639 (EntityRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'int', |
| 1628 expectedKind: ReferenceKind.classOrEnum), | 1640 expectedKind: ReferenceKind.classOrEnum), |
| 1629 (EntityRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'String', | 1641 (EntityRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'String', |
| 1630 expectedKind: ReferenceKind.classOrEnum) | 1642 expectedKind: ReferenceKind.classOrEnum) |
| 1631 ]); | 1643 ]); |
| 1632 } | 1644 } |
| 1633 | 1645 |
| 1634 test_constExpr_makeMap_untyped() { | 1646 test_constExpr_makeMap_typed_dynamic() { |
| 1635 UnlinkedVariable variable = serializeVariableText( | 1647 UnlinkedVariable variable = serializeVariableText( |
| 1636 'const v = const {11: "aaa", 22: "bbb", 33: "ccc"};'); | 1648 'const v = const <dynamic, dynamic>{11: "aaa", 22: "bbb", 33: "ccc"};'); |
| 1637 _assertUnlinkedConst(variable.constExpr, operators: [ | 1649 _assertUnlinkedConst(variable.constExpr, operators: [ |
| 1638 UnlinkedConstOperation.pushInt, | 1650 UnlinkedConstOperation.pushInt, |
| 1639 UnlinkedConstOperation.pushString, | 1651 UnlinkedConstOperation.pushString, |
| 1640 UnlinkedConstOperation.pushInt, | 1652 UnlinkedConstOperation.pushInt, |
| 1641 UnlinkedConstOperation.pushString, | 1653 UnlinkedConstOperation.pushString, |
| 1642 UnlinkedConstOperation.pushInt, | 1654 UnlinkedConstOperation.pushInt, |
| 1643 UnlinkedConstOperation.pushString, | 1655 UnlinkedConstOperation.pushString, |
| 1644 UnlinkedConstOperation.makeMap | 1656 UnlinkedConstOperation.makeTypedMap |
| 1645 ], ints: [ | 1657 ], ints: [ |
| 1646 11, | 1658 11, |
| 1647 22, | 1659 22, |
| 1648 33, | 1660 33, |
| 1649 3 | 1661 3 |
| 1650 ], strings: [ | 1662 ], strings: [ |
| 1651 'aaa', | 1663 'aaa', |
| 1652 'bbb', | 1664 'bbb', |
| 1653 'ccc' | 1665 'ccc' |
| 1654 ], referenceValidators: [ | 1666 ], referenceValidators: [ |
| 1655 (EntityRef r) => checkDynamicTypeRef(r), | 1667 (EntityRef r) => checkDynamicTypeRef(r), |
| 1656 (EntityRef r) => checkDynamicTypeRef(r) | 1668 (EntityRef r) => checkDynamicTypeRef(r) |
| 1657 ]); | 1669 ]); |
| 1658 } | 1670 } |
| 1659 | 1671 |
| 1672 test_constExpr_makeMap_untyped() { | |
| 1673 UnlinkedVariable variable = serializeVariableText( | |
| 1674 'const v = const {11: "aaa", 22: "bbb", 33: "ccc"};'); | |
| 1675 _assertUnlinkedConst(variable.constExpr, operators: [ | |
| 1676 UnlinkedConstOperation.pushInt, | |
| 1677 UnlinkedConstOperation.pushString, | |
| 1678 UnlinkedConstOperation.pushInt, | |
| 1679 UnlinkedConstOperation.pushString, | |
| 1680 UnlinkedConstOperation.pushInt, | |
| 1681 UnlinkedConstOperation.pushString, | |
| 1682 UnlinkedConstOperation.makeUntypedMap | |
| 1683 ], ints: [ | |
| 1684 11, | |
| 1685 22, | |
| 1686 33, | |
| 1687 3 | |
| 1688 ], strings: [ | |
| 1689 'aaa', | |
| 1690 'bbb', | |
| 1691 'ccc' | |
| 1692 ]); | |
| 1693 } | |
| 1694 | |
| 1660 test_constExpr_makeSymbol() { | 1695 test_constExpr_makeSymbol() { |
| 1661 UnlinkedVariable variable = serializeVariableText('const v = #a.bb.ccc;'); | 1696 UnlinkedVariable variable = serializeVariableText('const v = #a.bb.ccc;'); |
| 1662 _assertUnlinkedConst(variable.constExpr, operators: [ | 1697 _assertUnlinkedConst(variable.constExpr, operators: [ |
| 1663 UnlinkedConstOperation.pushString, | 1698 UnlinkedConstOperation.pushString, |
| 1664 UnlinkedConstOperation.makeSymbol | 1699 UnlinkedConstOperation.makeSymbol |
| 1665 ], strings: [ | 1700 ], strings: [ |
| 1666 'a.bb.ccc' | 1701 'a.bb.ccc' |
| 1667 ]); | 1702 ]); |
| 1668 } | 1703 } |
| 1669 | 1704 |
| 1670 test_constExpr_parenthesized() { | 1705 test_constExpr_parenthesized() { |
| 1671 UnlinkedVariable variable = serializeVariableText('const v = (1 + 2) * 3;'); | 1706 UnlinkedVariable variable = serializeVariableText('const v = (1 + 2) * 3;'); |
| 1672 _assertUnlinkedConst(variable.constExpr, operators: [ | 1707 _assertUnlinkedConst(variable.constExpr, operators: [ |
| 1673 UnlinkedConstOperation.pushInt, | 1708 UnlinkedConstOperation.pushInt, |
| 1674 UnlinkedConstOperation.pushInt, | 1709 UnlinkedConstOperation.pushInt, |
| 1675 UnlinkedConstOperation.add, | 1710 UnlinkedConstOperation.add, |
| 1676 UnlinkedConstOperation.pushInt, | 1711 UnlinkedConstOperation.pushInt, |
| 1677 UnlinkedConstOperation.multiply, | 1712 UnlinkedConstOperation.multiply, |
| 1678 ], ints: [ | 1713 ], ints: [ |
| 1679 1, | 1714 1, |
| 1680 2, | 1715 2, |
| 1681 3 | 1716 3 |
| 1682 ]); | 1717 ]); |
| 1683 } | 1718 } |
| 1684 | 1719 |
| 1685 test_constExpr_prefix_complement() { | 1720 test_constExpr_prefix_complement() { |
| 1686 UnlinkedVariable variable = serializeVariableText('const v = ~2;'); | 1721 UnlinkedVariable variable = serializeVariableText('const v = ~2;'); |
| 1687 _assertUnlinkedConst(variable.constExpr, operators: [ | 1722 _assertUnlinkedConst(variable.constExpr, |
| 1688 UnlinkedConstOperation.pushInt, | 1723 operators: |
| 1689 UnlinkedConstOperation.complement | 1724 [UnlinkedConstOperation.pushInt, UnlinkedConstOperation.complement], |
| 1690 ], ints: [ | 1725 ints: [2]); |
| 1691 2 | |
| 1692 ]); | |
| 1693 } | 1726 } |
| 1694 | 1727 |
| 1695 test_constExpr_prefix_negate() { | 1728 test_constExpr_prefix_negate() { |
| 1696 UnlinkedVariable variable = serializeVariableText('const v = -(2);'); | 1729 UnlinkedVariable variable = serializeVariableText('const v = -(2);'); |
| 1697 _assertUnlinkedConst(variable.constExpr, operators: [ | 1730 _assertUnlinkedConst(variable.constExpr, |
| 1698 UnlinkedConstOperation.pushInt, | 1731 operators: |
| 1699 UnlinkedConstOperation.negate | 1732 [UnlinkedConstOperation.pushInt, UnlinkedConstOperation.negate], |
| 1700 ], ints: [ | 1733 ints: [2]); |
| 1701 2 | |
| 1702 ]); | |
| 1703 } | 1734 } |
| 1704 | 1735 |
| 1705 test_constExpr_prefix_not() { | 1736 test_constExpr_prefix_not() { |
| 1706 UnlinkedVariable variable = serializeVariableText('const v = !true;'); | 1737 UnlinkedVariable variable = serializeVariableText('const v = !true;'); |
| 1707 _assertUnlinkedConst(variable.constExpr, operators: [ | 1738 _assertUnlinkedConst(variable.constExpr, operators: |
| 1708 UnlinkedConstOperation.pushTrue, | 1739 [UnlinkedConstOperation.pushTrue, UnlinkedConstOperation.not]); |
| 1709 UnlinkedConstOperation.not | |
| 1710 ]); | |
| 1711 } | 1740 } |
| 1712 | 1741 |
| 1713 test_constExpr_pushDouble() { | 1742 test_constExpr_pushDouble() { |
| 1714 UnlinkedVariable variable = serializeVariableText('const v = 123.4567;'); | 1743 UnlinkedVariable variable = serializeVariableText('const v = 123.4567;'); |
| 1715 _assertUnlinkedConst(variable.constExpr, | 1744 _assertUnlinkedConst(variable.constExpr, |
| 1716 operators: [UnlinkedConstOperation.pushDouble], doubles: [123.4567]); | 1745 operators: [UnlinkedConstOperation.pushDouble], doubles: [123.4567]); |
| 1717 } | 1746 } |
| 1718 | 1747 |
| 1719 test_constExpr_pushFalse() { | 1748 test_constExpr_pushFalse() { |
| 1720 UnlinkedVariable variable = serializeVariableText('const v = false;'); | 1749 UnlinkedVariable variable = serializeVariableText('const v = false;'); |
| 1721 _assertUnlinkedConst(variable.constExpr, | 1750 _assertUnlinkedConst(variable.constExpr, |
| 1722 operators: [UnlinkedConstOperation.pushFalse]); | 1751 operators: [UnlinkedConstOperation.pushFalse]); |
| 1723 } | 1752 } |
| 1724 | 1753 |
| 1725 test_constExpr_pushInt() { | 1754 test_constExpr_pushInt() { |
| 1726 UnlinkedVariable variable = serializeVariableText('const v = 1;'); | 1755 UnlinkedVariable variable = serializeVariableText('const v = 1;'); |
| 1727 _assertUnlinkedConst(variable.constExpr, | 1756 _assertUnlinkedConst(variable.constExpr, |
| 1728 operators: [UnlinkedConstOperation.pushInt], ints: [1]); | 1757 operators: [UnlinkedConstOperation.pushInt], ints: [1]); |
| 1729 } | 1758 } |
| 1730 | 1759 |
| 1731 test_constExpr_pushInt_max() { | 1760 test_constExpr_pushInt_max() { |
| 1732 UnlinkedVariable variable = serializeVariableText('const v = 0xFFFFFFFF;'); | 1761 UnlinkedVariable variable = serializeVariableText('const v = 0xFFFFFFFF;'); |
| 1733 _assertUnlinkedConst(variable.constExpr, | 1762 _assertUnlinkedConst(variable.constExpr, |
| 1734 operators: [UnlinkedConstOperation.pushInt,], ints: [0xFFFFFFFF]); | 1763 operators: [UnlinkedConstOperation.pushInt,], ints: [0xFFFFFFFF]); |
| 1735 } | 1764 } |
| 1736 | 1765 |
| 1737 test_constExpr_pushInt_negative() { | 1766 test_constExpr_pushInt_negative() { |
| 1738 UnlinkedVariable variable = serializeVariableText('const v = -5;'); | 1767 UnlinkedVariable variable = serializeVariableText('const v = -5;'); |
| 1739 _assertUnlinkedConst(variable.constExpr, operators: [ | 1768 _assertUnlinkedConst(variable.constExpr, |
| 1740 UnlinkedConstOperation.pushInt, | 1769 operators: |
| 1741 UnlinkedConstOperation.negate | 1770 [UnlinkedConstOperation.pushInt, UnlinkedConstOperation.negate], |
| 1742 ], ints: [ | 1771 ints: [5]); |
| 1743 5 | |
| 1744 ]); | |
| 1745 } | 1772 } |
| 1746 | 1773 |
| 1747 test_constExpr_pushInt_shiftOr_long() { | 1774 test_constExpr_pushInt_shiftOr_long() { |
| 1748 UnlinkedVariable variable = | 1775 UnlinkedVariable variable = |
| 1749 serializeVariableText('const v = 0xA123456789ABCDEF012345678;'); | 1776 serializeVariableText('const v = 0xA123456789ABCDEF012345678;'); |
| 1750 _assertUnlinkedConst(variable.constExpr, operators: [ | 1777 _assertUnlinkedConst(variable.constExpr, operators: [ |
| 1751 UnlinkedConstOperation.pushInt, | 1778 UnlinkedConstOperation.pushInt, |
| 1752 UnlinkedConstOperation.shiftOr, | 1779 UnlinkedConstOperation.shiftOr, |
| 1753 UnlinkedConstOperation.shiftOr, | 1780 UnlinkedConstOperation.shiftOr, |
| 1754 UnlinkedConstOperation.shiftOr | 1781 UnlinkedConstOperation.shiftOr |
| 1755 ], ints: [ | 1782 ], ints: [ |
| 1756 0xA, | 1783 0xA, |
| 1757 0x12345678, | 1784 0x12345678, |
| 1758 0x9ABCDEF0, | 1785 0x9ABCDEF0, |
| 1759 0x12345678 | 1786 0x12345678 |
| 1760 ]); | 1787 ]); |
| 1761 } | 1788 } |
| 1762 | 1789 |
| 1763 test_constExpr_pushInt_shiftOr_min() { | 1790 test_constExpr_pushInt_shiftOr_min() { |
| 1764 UnlinkedVariable variable = serializeVariableText('const v = 0x100000000;'); | 1791 UnlinkedVariable variable = serializeVariableText('const v = 0x100000000;'); |
| 1765 _assertUnlinkedConst(variable.constExpr, operators: [ | 1792 _assertUnlinkedConst(variable.constExpr, |
| 1766 UnlinkedConstOperation.pushInt, | 1793 operators: |
| 1767 UnlinkedConstOperation.shiftOr, | 1794 [UnlinkedConstOperation.pushInt, UnlinkedConstOperation.shiftOr,], |
| 1768 ], ints: [ | 1795 ints: [1, 0,]); |
| 1769 1, | |
| 1770 0, | |
| 1771 ]); | |
| 1772 } | 1796 } |
| 1773 | 1797 |
| 1774 test_constExpr_pushInt_shiftOr_min2() { | 1798 test_constExpr_pushInt_shiftOr_min2() { |
| 1775 UnlinkedVariable variable = | 1799 UnlinkedVariable variable = |
| 1776 serializeVariableText('const v = 0x10000000000000000;'); | 1800 serializeVariableText('const v = 0x10000000000000000;'); |
| 1777 _assertUnlinkedConst(variable.constExpr, operators: [ | 1801 _assertUnlinkedConst(variable.constExpr, operators: [ |
| 1778 UnlinkedConstOperation.pushInt, | 1802 UnlinkedConstOperation.pushInt, |
| 1779 UnlinkedConstOperation.shiftOr, | 1803 UnlinkedConstOperation.shiftOr, |
| 1780 UnlinkedConstOperation.shiftOr, | 1804 UnlinkedConstOperation.shiftOr, |
| 1781 ], ints: [ | 1805 ], ints: [ |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1936 UnlinkedVariable variable = serializeVariableText('const v = true;'); | 1960 UnlinkedVariable variable = serializeVariableText('const v = true;'); |
| 1937 _assertUnlinkedConst(variable.constExpr, | 1961 _assertUnlinkedConst(variable.constExpr, |
| 1938 operators: [UnlinkedConstOperation.pushTrue]); | 1962 operators: [UnlinkedConstOperation.pushTrue]); |
| 1939 } | 1963 } |
| 1940 | 1964 |
| 1941 test_constructor() { | 1965 test_constructor() { |
| 1942 String text = 'class C { C(); }'; | 1966 String text = 'class C { C(); }'; |
| 1943 UnlinkedExecutable executable = | 1967 UnlinkedExecutable executable = |
| 1944 findExecutable('', executables: serializeClassText(text).executables); | 1968 findExecutable('', executables: serializeClassText(text).executables); |
| 1945 expect(executable.kind, UnlinkedExecutableKind.constructor); | 1969 expect(executable.kind, UnlinkedExecutableKind.constructor); |
| 1946 expect(executable.hasImplicitReturnType, isFalse); | 1970 expect(executable.returnType, isNull); |
| 1947 expect(executable.isExternal, isFalse); | 1971 expect(executable.isExternal, isFalse); |
| 1948 expect(executable.nameOffset, text.indexOf('C();')); | 1972 expect(executable.nameOffset, text.indexOf('C();')); |
| 1949 } | 1973 } |
| 1950 | 1974 |
| 1951 test_constructor_anonymous() { | 1975 test_constructor_anonymous() { |
| 1952 UnlinkedExecutable executable = findExecutable('', | 1976 UnlinkedExecutable executable = findExecutable('', |
| 1953 executables: serializeClassText('class C { C(); }').executables); | 1977 executables: serializeClassText('class C { C(); }').executables); |
| 1954 expect(executable.name, isEmpty); | 1978 expect(executable.name, isEmpty); |
| 1955 } | 1979 } |
| 1956 | 1980 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2031 test_constructor_initializing_formal_function_typed_explicit_return_type() { | 2055 test_constructor_initializing_formal_function_typed_explicit_return_type() { |
| 2032 UnlinkedExecutable executable = findExecutable('', | 2056 UnlinkedExecutable executable = findExecutable('', |
| 2033 executables: | 2057 executables: |
| 2034 serializeClassText('class C { C(int this.x()); Function x; }') | 2058 serializeClassText('class C { C(int this.x()); Function x; }') |
| 2035 .executables); | 2059 .executables); |
| 2036 UnlinkedParam parameter = executable.parameters[0]; | 2060 UnlinkedParam parameter = executable.parameters[0]; |
| 2037 checkTypeRef(parameter.type, 'dart:core', 'dart:core', 'int'); | 2061 checkTypeRef(parameter.type, 'dart:core', 'dart:core', 'int'); |
| 2038 } | 2062 } |
| 2039 | 2063 |
| 2040 test_constructor_initializing_formal_function_typed_implicit_return_type() { | 2064 test_constructor_initializing_formal_function_typed_implicit_return_type() { |
| 2065 if (!checkAstDerivedData) { | |
| 2066 // TODO(paulberry): this test fails when building the summary from the | |
| 2067 // element model because the elment model doesn't record whether a | |
| 2068 // function-typed parameter's return type is implicit. | |
| 2069 return; | |
| 2070 } | |
| 2041 UnlinkedExecutable executable = findExecutable('', | 2071 UnlinkedExecutable executable = findExecutable('', |
| 2042 executables: serializeClassText('class C { C(this.x()); Function x; }') | 2072 executables: serializeClassText('class C { C(this.x()); Function x; }') |
| 2043 .executables); | 2073 .executables); |
| 2044 UnlinkedParam parameter = executable.parameters[0]; | 2074 UnlinkedParam parameter = executable.parameters[0]; |
| 2045 // Since the parameter is function-typed it is considered to have an | 2075 expect(parameter.isFunctionTyped, isTrue); |
| 2046 // explicit type, even though that explicit type itself has an implicit | 2076 expect(parameter.type, isNull); |
| 2047 // return type. | |
| 2048 expect(parameter.hasImplicitType, isFalse); | |
| 2049 checkDynamicTypeRef(parameter.type); | |
| 2050 } | 2077 } |
| 2051 | 2078 |
| 2052 test_constructor_initializing_formal_function_typed_no_parameters() { | 2079 test_constructor_initializing_formal_function_typed_no_parameters() { |
| 2053 UnlinkedExecutable executable = findExecutable('', | 2080 UnlinkedExecutable executable = findExecutable('', |
| 2054 executables: serializeClassText('class C { C(this.x()); final x; }') | 2081 executables: serializeClassText('class C { C(this.x()); final x; }') |
| 2055 .executables); | 2082 .executables); |
| 2056 UnlinkedParam parameter = executable.parameters[0]; | 2083 UnlinkedParam parameter = executable.parameters[0]; |
| 2057 expect(parameter.parameters, isEmpty); | 2084 expect(parameter.parameters, isEmpty); |
| 2058 } | 2085 } |
| 2059 | 2086 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 2076 } | 2103 } |
| 2077 | 2104 |
| 2078 test_constructor_initializing_formal_implicit_type() { | 2105 test_constructor_initializing_formal_implicit_type() { |
| 2079 // Note: the implicit type of an initializing formal is the type of the | 2106 // Note: the implicit type of an initializing formal is the type of the |
| 2080 // field. | 2107 // field. |
| 2081 UnlinkedExecutable executable = findExecutable('', | 2108 UnlinkedExecutable executable = findExecutable('', |
| 2082 executables: | 2109 executables: |
| 2083 serializeClassText('class C { C(this.x); int x; }').executables); | 2110 serializeClassText('class C { C(this.x); int x; }').executables); |
| 2084 UnlinkedParam parameter = executable.parameters[0]; | 2111 UnlinkedParam parameter = executable.parameters[0]; |
| 2085 expect(parameter.type, isNull); | 2112 expect(parameter.type, isNull); |
| 2086 expect(parameter.hasImplicitType, isTrue); | |
| 2087 } | 2113 } |
| 2088 | 2114 |
| 2089 test_constructor_initializing_formal_name() { | 2115 test_constructor_initializing_formal_name() { |
| 2090 UnlinkedExecutable executable = findExecutable('', | 2116 UnlinkedExecutable executable = findExecutable('', |
| 2091 executables: | 2117 executables: |
| 2092 serializeClassText('class C { C(this.x); final x; }').executables); | 2118 serializeClassText('class C { C(this.x); final x; }').executables); |
| 2093 UnlinkedParam parameter = executable.parameters[0]; | 2119 UnlinkedParam parameter = executable.parameters[0]; |
| 2094 expect(parameter.name, 'x'); | 2120 expect(parameter.name, 'x'); |
| 2095 } | 2121 } |
| 2096 | 2122 |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2379 test_executable_concrete() { | 2405 test_executable_concrete() { |
| 2380 UnlinkedExecutable executable = | 2406 UnlinkedExecutable executable = |
| 2381 serializeClassText('abstract class C { f() {} }').executables[0]; | 2407 serializeClassText('abstract class C { f() {} }').executables[0]; |
| 2382 expect(executable.isAbstract, isFalse); | 2408 expect(executable.isAbstract, isFalse); |
| 2383 } | 2409 } |
| 2384 | 2410 |
| 2385 test_executable_function() { | 2411 test_executable_function() { |
| 2386 String text = ' f() {}'; | 2412 String text = ' f() {}'; |
| 2387 UnlinkedExecutable executable = serializeExecutableText(text); | 2413 UnlinkedExecutable executable = serializeExecutableText(text); |
| 2388 expect(executable.kind, UnlinkedExecutableKind.functionOrMethod); | 2414 expect(executable.kind, UnlinkedExecutableKind.functionOrMethod); |
| 2389 expect(executable.hasImplicitReturnType, isTrue); | 2415 expect(executable.returnType, isNull); |
| 2390 checkDynamicTypeRef(executable.returnType); | |
| 2391 expect(executable.isExternal, isFalse); | 2416 expect(executable.isExternal, isFalse); |
| 2392 expect(executable.nameOffset, text.indexOf('f')); | 2417 expect(executable.nameOffset, text.indexOf('f')); |
| 2393 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1)); | 2418 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1)); |
| 2394 expect(unlinkedUnits[0].publicNamespace.names[0].kind, | 2419 expect(unlinkedUnits[0].publicNamespace.names[0].kind, |
| 2395 ReferenceKind.topLevelFunction); | 2420 ReferenceKind.topLevelFunction); |
| 2396 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'f'); | 2421 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'f'); |
| 2397 expect(unlinkedUnits[0].publicNamespace.names[0].numTypeParameters, 0); | 2422 expect(unlinkedUnits[0].publicNamespace.names[0].numTypeParameters, 0); |
| 2398 } | 2423 } |
| 2399 | 2424 |
| 2400 test_executable_function_explicit_return() { | 2425 test_executable_function_explicit_return() { |
| 2401 UnlinkedExecutable executable = | 2426 UnlinkedExecutable executable = |
| 2402 serializeExecutableText('dynamic f() => null;'); | 2427 serializeExecutableText('dynamic f() => null;'); |
| 2403 expect(executable.hasImplicitReturnType, isFalse); | |
| 2404 checkDynamicTypeRef(executable.returnType); | 2428 checkDynamicTypeRef(executable.returnType); |
| 2405 } | 2429 } |
| 2406 | 2430 |
| 2407 test_executable_function_external() { | 2431 test_executable_function_external() { |
| 2408 UnlinkedExecutable executable = serializeExecutableText('external f();'); | 2432 UnlinkedExecutable executable = serializeExecutableText('external f();'); |
| 2409 expect(executable.isExternal, isTrue); | 2433 expect(executable.isExternal, isTrue); |
| 2410 } | 2434 } |
| 2411 | 2435 |
| 2412 test_executable_function_private() { | 2436 test_executable_function_private() { |
| 2413 serializeExecutableText('_f() {}', '_f'); | 2437 serializeExecutableText('_f() {}', '_f'); |
| 2414 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); | 2438 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); |
| 2415 } | 2439 } |
| 2416 | 2440 |
| 2417 test_executable_getter() { | 2441 test_executable_getter() { |
| 2418 String text = 'int get f => 1;'; | 2442 String text = 'int get f => 1;'; |
| 2419 UnlinkedExecutable executable = serializeExecutableText(text); | 2443 UnlinkedExecutable executable = serializeExecutableText(text); |
| 2420 expect(executable.kind, UnlinkedExecutableKind.getter); | 2444 expect(executable.kind, UnlinkedExecutableKind.getter); |
| 2421 expect(executable.hasImplicitReturnType, isFalse); | 2445 expect(executable.returnType, isNotNull); |
| 2422 expect(executable.isExternal, isFalse); | 2446 expect(executable.isExternal, isFalse); |
| 2423 expect(executable.nameOffset, text.indexOf('f')); | 2447 expect(executable.nameOffset, text.indexOf('f')); |
| 2424 expect(findVariable('f'), isNull); | 2448 expect(findVariable('f'), isNull); |
| 2425 expect(findExecutable('f='), isNull); | 2449 expect(findExecutable('f='), isNull); |
| 2426 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1)); | 2450 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1)); |
| 2427 expect(unlinkedUnits[0].publicNamespace.names[0].kind, | 2451 expect(unlinkedUnits[0].publicNamespace.names[0].kind, |
| 2428 ReferenceKind.topLevelPropertyAccessor); | 2452 ReferenceKind.topLevelPropertyAccessor); |
| 2429 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'f'); | 2453 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'f'); |
| 2430 } | 2454 } |
| 2431 | 2455 |
| 2432 test_executable_getter_external() { | 2456 test_executable_getter_external() { |
| 2433 UnlinkedExecutable executable = | 2457 UnlinkedExecutable executable = |
| 2434 serializeExecutableText('external int get f;'); | 2458 serializeExecutableText('external int get f;'); |
| 2435 expect(executable.isExternal, isTrue); | 2459 expect(executable.isExternal, isTrue); |
| 2436 } | 2460 } |
| 2437 | 2461 |
| 2438 test_executable_getter_private() { | 2462 test_executable_getter_private() { |
| 2439 serializeExecutableText('int get _f => 1;', '_f'); | 2463 serializeExecutableText('int get _f => 1;', '_f'); |
| 2440 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); | 2464 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); |
| 2441 } | 2465 } |
| 2442 | 2466 |
| 2443 test_executable_getter_type() { | 2467 test_executable_getter_type() { |
| 2444 UnlinkedExecutable executable = serializeExecutableText('int get f => 1;'); | 2468 UnlinkedExecutable executable = serializeExecutableText('int get f => 1;'); |
| 2445 checkTypeRef(executable.returnType, 'dart:core', 'dart:core', 'int'); | 2469 checkTypeRef(executable.returnType, 'dart:core', 'dart:core', 'int'); |
| 2446 expect(executable.parameters, isEmpty); | 2470 expect(executable.parameters, isEmpty); |
| 2447 } | 2471 } |
| 2448 | 2472 |
| 2449 test_executable_getter_type_implicit() { | 2473 test_executable_getter_type_implicit() { |
| 2450 UnlinkedExecutable executable = serializeExecutableText('get f => 1;'); | 2474 UnlinkedExecutable executable = serializeExecutableText('get f => 1;'); |
| 2451 checkDynamicTypeRef(executable.returnType); | 2475 expect(executable.returnType, isNull); |
| 2452 expect(executable.hasImplicitReturnType, isTrue); | |
| 2453 expect(executable.parameters, isEmpty); | 2476 expect(executable.parameters, isEmpty); |
| 2454 } | 2477 } |
| 2455 | 2478 |
| 2456 test_executable_member_function() { | 2479 test_executable_member_function() { |
| 2457 UnlinkedExecutable executable = findExecutable('f', | 2480 UnlinkedExecutable executable = findExecutable('f', |
| 2458 executables: serializeClassText('class C { f() {} }').executables); | 2481 executables: serializeClassText('class C { f() {} }').executables); |
| 2459 expect(executable.kind, UnlinkedExecutableKind.functionOrMethod); | 2482 expect(executable.kind, UnlinkedExecutableKind.functionOrMethod); |
| 2460 expect(executable.hasImplicitReturnType, isTrue); | 2483 expect(executable.returnType, isNull); |
| 2461 expect(executable.isExternal, isFalse); | 2484 expect(executable.isExternal, isFalse); |
| 2462 } | 2485 } |
| 2463 | 2486 |
| 2464 test_executable_member_function_explicit_return() { | 2487 test_executable_member_function_explicit_return() { |
| 2465 UnlinkedExecutable executable = findExecutable('f', | 2488 UnlinkedExecutable executable = findExecutable('f', |
| 2466 executables: | 2489 executables: |
| 2467 serializeClassText('class C { dynamic f() => null; }').executables); | 2490 serializeClassText('class C { dynamic f() => null; }').executables); |
| 2468 expect(executable.hasImplicitReturnType, isFalse); | 2491 expect(executable.returnType, isNotNull); |
| 2469 } | 2492 } |
| 2470 | 2493 |
| 2471 test_executable_member_function_external() { | 2494 test_executable_member_function_external() { |
| 2472 UnlinkedExecutable executable = findExecutable('f', | 2495 UnlinkedExecutable executable = findExecutable('f', |
| 2473 executables: | 2496 executables: |
| 2474 serializeClassText('class C { external f(); }').executables); | 2497 serializeClassText('class C { external f(); }').executables); |
| 2475 expect(executable.isExternal, isTrue); | 2498 expect(executable.isExternal, isTrue); |
| 2476 } | 2499 } |
| 2477 | 2500 |
| 2478 test_executable_member_getter() { | 2501 test_executable_member_getter() { |
| 2479 UnlinkedClass cls = serializeClassText('class C { int get f => 1; }'); | 2502 UnlinkedClass cls = serializeClassText('class C { int get f => 1; }'); |
| 2480 UnlinkedExecutable executable = | 2503 UnlinkedExecutable executable = |
| 2481 findExecutable('f', executables: cls.executables, failIfAbsent: true); | 2504 findExecutable('f', executables: cls.executables, failIfAbsent: true); |
| 2482 expect(executable.kind, UnlinkedExecutableKind.getter); | 2505 expect(executable.kind, UnlinkedExecutableKind.getter); |
| 2483 expect(executable.hasImplicitReturnType, isFalse); | 2506 expect(executable.returnType, isNotNull); |
| 2484 expect(executable.isExternal, isFalse); | 2507 expect(executable.isExternal, isFalse); |
| 2485 expect(findVariable('f', variables: cls.fields), isNull); | 2508 expect(findVariable('f', variables: cls.fields), isNull); |
| 2486 expect(findExecutable('f=', executables: cls.executables), isNull); | 2509 expect(findExecutable('f=', executables: cls.executables), isNull); |
| 2487 } | 2510 } |
| 2488 | 2511 |
| 2489 test_executable_member_getter_external() { | 2512 test_executable_member_getter_external() { |
| 2490 UnlinkedClass cls = serializeClassText('class C { external int get f; }'); | 2513 UnlinkedClass cls = serializeClassText('class C { external int get f; }'); |
| 2491 UnlinkedExecutable executable = | 2514 UnlinkedExecutable executable = |
| 2492 findExecutable('f', executables: cls.executables, failIfAbsent: true); | 2515 findExecutable('f', executables: cls.executables, failIfAbsent: true); |
| 2493 expect(executable.isExternal, isTrue); | 2516 expect(executable.isExternal, isTrue); |
| 2494 } | 2517 } |
| 2495 | 2518 |
| 2496 test_executable_member_setter() { | 2519 test_executable_member_setter() { |
| 2497 UnlinkedClass cls = serializeClassText('class C { void set f(value) {} }'); | 2520 UnlinkedClass cls = serializeClassText('class C { void set f(value) {} }'); |
| 2498 UnlinkedExecutable executable = | 2521 UnlinkedExecutable executable = |
| 2499 findExecutable('f=', executables: cls.executables, failIfAbsent: true); | 2522 findExecutable('f=', executables: cls.executables, failIfAbsent: true); |
| 2500 expect(executable.kind, UnlinkedExecutableKind.setter); | 2523 expect(executable.kind, UnlinkedExecutableKind.setter); |
| 2501 expect(executable.hasImplicitReturnType, isFalse); | 2524 expect(executable.returnType, isNotNull); |
| 2502 expect(executable.isExternal, isFalse); | 2525 expect(executable.isExternal, isFalse); |
| 2503 expect(findVariable('f', variables: cls.fields), isNull); | 2526 expect(findVariable('f', variables: cls.fields), isNull); |
| 2504 expect(findExecutable('f', executables: cls.executables), isNull); | 2527 expect(findExecutable('f', executables: cls.executables), isNull); |
| 2505 } | 2528 } |
| 2506 | 2529 |
| 2507 test_executable_member_setter_external() { | 2530 test_executable_member_setter_external() { |
| 2508 UnlinkedClass cls = | 2531 UnlinkedClass cls = |
| 2509 serializeClassText('class C { external void set f(value); }'); | 2532 serializeClassText('class C { external void set f(value); }'); |
| 2510 UnlinkedExecutable executable = | 2533 UnlinkedExecutable executable = |
| 2511 findExecutable('f=', executables: cls.executables, failIfAbsent: true); | 2534 findExecutable('f=', executables: cls.executables, failIfAbsent: true); |
| 2512 expect(executable.isExternal, isTrue); | 2535 expect(executable.isExternal, isTrue); |
| 2513 } | 2536 } |
| 2514 | 2537 |
| 2515 test_executable_member_setter_implicit_return() { | 2538 test_executable_member_setter_implicit_return() { |
| 2516 UnlinkedClass cls = serializeClassText('class C { set f(value) {} }'); | 2539 UnlinkedClass cls = serializeClassText('class C { set f(value) {} }'); |
| 2517 UnlinkedExecutable executable = | 2540 UnlinkedExecutable executable = |
| 2518 findExecutable('f=', executables: cls.executables, failIfAbsent: true); | 2541 findExecutable('f=', executables: cls.executables, failIfAbsent: true); |
| 2519 expect(executable.hasImplicitReturnType, isTrue); | 2542 expect(executable.returnType, isNull); |
| 2520 checkDynamicTypeRef(executable.returnType); | |
| 2521 } | 2543 } |
| 2522 | 2544 |
| 2523 test_executable_name() { | 2545 test_executable_name() { |
| 2524 UnlinkedExecutable executable = serializeExecutableText('f() {}'); | 2546 UnlinkedExecutable executable = serializeExecutableText('f() {}'); |
| 2525 expect(executable.name, 'f'); | 2547 expect(executable.name, 'f'); |
| 2526 } | 2548 } |
| 2527 | 2549 |
| 2528 test_executable_no_flags() { | 2550 test_executable_no_flags() { |
| 2529 UnlinkedExecutable executable = serializeExecutableText('f() {}'); | 2551 UnlinkedExecutable executable = serializeExecutableText('f() {}'); |
| 2530 expect(executable.isAbstract, isFalse); | 2552 expect(executable.isAbstract, isFalse); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 2544 UnlinkedExecutable executable = serializeExecutableText('f() {}'); | 2566 UnlinkedExecutable executable = serializeExecutableText('f() {}'); |
| 2545 expect(executable.isStatic, isFalse); | 2567 expect(executable.isStatic, isFalse); |
| 2546 } | 2568 } |
| 2547 | 2569 |
| 2548 test_executable_operator() { | 2570 test_executable_operator() { |
| 2549 UnlinkedExecutable executable = | 2571 UnlinkedExecutable executable = |
| 2550 serializeClassText('class C { C operator+(C c) => null; }').executables[ | 2572 serializeClassText('class C { C operator+(C c) => null; }').executables[ |
| 2551 0]; | 2573 0]; |
| 2552 expect(executable.kind, UnlinkedExecutableKind.functionOrMethod); | 2574 expect(executable.kind, UnlinkedExecutableKind.functionOrMethod); |
| 2553 expect(executable.name, '+'); | 2575 expect(executable.name, '+'); |
| 2554 expect(executable.hasImplicitReturnType, false); | 2576 expect(executable.returnType, isNotNull); |
| 2555 expect(executable.isAbstract, false); | 2577 expect(executable.isAbstract, false); |
| 2556 expect(executable.isConst, false); | 2578 expect(executable.isConst, false); |
| 2557 expect(executable.isFactory, false); | 2579 expect(executable.isFactory, false); |
| 2558 expect(executable.isStatic, false); | 2580 expect(executable.isStatic, false); |
| 2559 expect(executable.parameters, hasLength(1)); | 2581 expect(executable.parameters, hasLength(1)); |
| 2560 checkTypeRef(executable.returnType, null, null, 'C'); | 2582 checkTypeRef(executable.returnType, null, null, 'C'); |
| 2561 expect(executable.typeParameters, isEmpty); | 2583 expect(executable.typeParameters, isEmpty); |
| 2562 expect(executable.isExternal, false); | 2584 expect(executable.isExternal, false); |
| 2563 } | 2585 } |
| 2564 | 2586 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 2581 .executables[0]; | 2603 .executables[0]; |
| 2582 expect(executable.name, '>='); | 2604 expect(executable.name, '>='); |
| 2583 } | 2605 } |
| 2584 | 2606 |
| 2585 test_executable_operator_index() { | 2607 test_executable_operator_index() { |
| 2586 UnlinkedExecutable executable = | 2608 UnlinkedExecutable executable = |
| 2587 serializeClassText('class C { bool operator[](int i) => null; }') | 2609 serializeClassText('class C { bool operator[](int i) => null; }') |
| 2588 .executables[0]; | 2610 .executables[0]; |
| 2589 expect(executable.kind, UnlinkedExecutableKind.functionOrMethod); | 2611 expect(executable.kind, UnlinkedExecutableKind.functionOrMethod); |
| 2590 expect(executable.name, '[]'); | 2612 expect(executable.name, '[]'); |
| 2591 expect(executable.hasImplicitReturnType, false); | 2613 expect(executable.returnType, isNotNull); |
| 2592 expect(executable.isAbstract, false); | 2614 expect(executable.isAbstract, false); |
| 2593 expect(executable.isConst, false); | 2615 expect(executable.isConst, false); |
| 2594 expect(executable.isFactory, false); | 2616 expect(executable.isFactory, false); |
| 2595 expect(executable.isStatic, false); | 2617 expect(executable.isStatic, false); |
| 2596 expect(executable.parameters, hasLength(1)); | 2618 expect(executable.parameters, hasLength(1)); |
| 2597 checkTypeRef(executable.returnType, 'dart:core', 'dart:core', 'bool'); | 2619 checkTypeRef(executable.returnType, 'dart:core', 'dart:core', 'bool'); |
| 2598 expect(executable.typeParameters, isEmpty); | 2620 expect(executable.typeParameters, isEmpty); |
| 2599 } | 2621 } |
| 2600 | 2622 |
| 2601 test_executable_operator_index_set() { | 2623 test_executable_operator_index_set() { |
| 2602 UnlinkedExecutable executable = serializeClassText( | 2624 UnlinkedExecutable executable = serializeClassText( |
| 2603 'class C { void operator[]=(int i, bool v) => null; }') | 2625 'class C { void operator[]=(int i, bool v) => null; }').executables[0]; |
| 2604 .executables[0]; | |
| 2605 expect(executable.kind, UnlinkedExecutableKind.functionOrMethod); | 2626 expect(executable.kind, UnlinkedExecutableKind.functionOrMethod); |
| 2606 expect(executable.name, '[]='); | 2627 expect(executable.name, '[]='); |
| 2607 expect(executable.hasImplicitReturnType, false); | 2628 expect(executable.returnType, isNotNull); |
| 2608 expect(executable.isAbstract, false); | 2629 expect(executable.isAbstract, false); |
| 2609 expect(executable.isConst, false); | 2630 expect(executable.isConst, false); |
| 2610 expect(executable.isFactory, false); | 2631 expect(executable.isFactory, false); |
| 2611 expect(executable.isStatic, false); | 2632 expect(executable.isStatic, false); |
| 2612 expect(executable.parameters, hasLength(2)); | 2633 expect(executable.parameters, hasLength(2)); |
| 2613 checkVoidTypeRef(executable.returnType); | 2634 checkVoidTypeRef(executable.returnType); |
| 2614 expect(executable.typeParameters, isEmpty); | 2635 expect(executable.typeParameters, isEmpty); |
| 2615 } | 2636 } |
| 2616 | 2637 |
| 2617 test_executable_operator_less_equal() { | 2638 test_executable_operator_less_equal() { |
| 2618 UnlinkedExecutable executable = | 2639 UnlinkedExecutable executable = |
| 2619 serializeClassText('class C { bool operator<=(C other) => false; }') | 2640 serializeClassText('class C { bool operator<=(C other) => false; }') |
| 2620 .executables[0]; | 2641 .executables[0]; |
| 2621 expect(executable.name, '<='); | 2642 expect(executable.name, '<='); |
| 2622 } | 2643 } |
| 2623 | 2644 |
| 2624 test_executable_param_function_typed() { | 2645 test_executable_param_function_typed() { |
| 2646 if (!checkAstDerivedData) { | |
| 2647 // TODO(paulberry): this test fails when building the summary from the | |
| 2648 // element model because the elment model doesn't record whether a | |
| 2649 // function-typed parameter's return type is implicit. | |
| 2650 return; | |
| 2651 } | |
| 2625 UnlinkedExecutable executable = serializeExecutableText('f(g()) {}'); | 2652 UnlinkedExecutable executable = serializeExecutableText('f(g()) {}'); |
| 2626 expect(executable.parameters[0].isFunctionTyped, isTrue); | 2653 expect(executable.parameters[0].isFunctionTyped, isTrue); |
| 2627 // Since the parameter is function-typed it is considered to have an | 2654 expect(executable.parameters[0].type, isNull); |
| 2628 // explicit type, even though that explicit type itself has an implicit | |
| 2629 // return type. | |
| 2630 expect(executable.parameters[0].hasImplicitType, isFalse); | |
| 2631 } | 2655 } |
| 2632 | 2656 |
| 2633 test_executable_param_function_typed_explicit_return_type() { | 2657 test_executable_param_function_typed_explicit_return_type() { |
| 2634 UnlinkedExecutable executable = | 2658 UnlinkedExecutable executable = |
| 2635 serializeExecutableText('f(dynamic g()) {}'); | 2659 serializeExecutableText('f(dynamic g()) {}'); |
| 2636 expect(executable.parameters[0].hasImplicitType, isFalse); | 2660 expect(executable.parameters[0].type, isNotNull); |
| 2637 } | 2661 } |
| 2638 | 2662 |
| 2639 test_executable_param_function_typed_param() { | 2663 test_executable_param_function_typed_param() { |
| 2640 UnlinkedExecutable executable = serializeExecutableText('f(g(x)) {}'); | 2664 UnlinkedExecutable executable = serializeExecutableText('f(g(x)) {}'); |
| 2641 expect(executable.parameters[0].parameters, hasLength(1)); | 2665 expect(executable.parameters[0].parameters, hasLength(1)); |
| 2642 } | 2666 } |
| 2643 | 2667 |
| 2644 test_executable_param_function_typed_param_none() { | 2668 test_executable_param_function_typed_param_none() { |
| 2645 UnlinkedExecutable executable = serializeExecutableText('f(g()) {}'); | 2669 UnlinkedExecutable executable = serializeExecutableText('f(g()) {}'); |
| 2646 expect(executable.parameters[0].parameters, isEmpty); | 2670 expect(executable.parameters[0].parameters, isEmpty); |
| 2647 } | 2671 } |
| 2648 | 2672 |
| 2649 test_executable_param_function_typed_param_order() { | 2673 test_executable_param_function_typed_param_order() { |
| 2650 UnlinkedExecutable executable = serializeExecutableText('f(g(x, y)) {}'); | 2674 UnlinkedExecutable executable = serializeExecutableText('f(g(x, y)) {}'); |
| 2651 expect(executable.parameters[0].parameters, hasLength(2)); | 2675 expect(executable.parameters[0].parameters, hasLength(2)); |
| 2652 expect(executable.parameters[0].parameters[0].name, 'x'); | 2676 expect(executable.parameters[0].parameters[0].name, 'x'); |
| 2653 expect(executable.parameters[0].parameters[1].name, 'y'); | 2677 expect(executable.parameters[0].parameters[1].name, 'y'); |
| 2654 } | 2678 } |
| 2655 | 2679 |
| 2656 test_executable_param_function_typed_return_type() { | 2680 test_executable_param_function_typed_return_type() { |
| 2657 UnlinkedExecutable executable = serializeExecutableText('f(int g()) {}'); | 2681 UnlinkedExecutable executable = serializeExecutableText('f(int g()) {}'); |
| 2658 checkTypeRef( | 2682 checkTypeRef( |
| 2659 executable.parameters[0].type, 'dart:core', 'dart:core', 'int'); | 2683 executable.parameters[0].type, 'dart:core', 'dart:core', 'int'); |
| 2660 } | 2684 } |
| 2661 | 2685 |
| 2662 test_executable_param_function_typed_return_type_implicit() { | 2686 test_executable_param_function_typed_return_type_implicit() { |
| 2687 if (!checkAstDerivedData) { | |
| 2688 // TODO(paulberry): this test fails when building the summary from the | |
| 2689 // element model because the elment model doesn't record whether a | |
| 2690 // function-typed parameter's return type is implicit. | |
| 2691 return; | |
| 2692 } | |
| 2663 UnlinkedExecutable executable = serializeExecutableText('f(g()) {}'); | 2693 UnlinkedExecutable executable = serializeExecutableText('f(g()) {}'); |
| 2664 checkDynamicTypeRef(executable.parameters[0].type); | 2694 expect(executable.parameters[0].isFunctionTyped, isTrue); |
| 2695 expect(executable.parameters[0].type, isNull); | |
| 2665 } | 2696 } |
| 2666 | 2697 |
| 2667 test_executable_param_function_typed_return_type_void() { | 2698 test_executable_param_function_typed_return_type_void() { |
| 2668 UnlinkedExecutable executable = serializeExecutableText('f(void g()) {}'); | 2699 UnlinkedExecutable executable = serializeExecutableText('f(void g()) {}'); |
| 2669 checkVoidTypeRef(executable.parameters[0].type); | 2700 checkVoidTypeRef(executable.parameters[0].type); |
| 2670 } | 2701 } |
| 2671 | 2702 |
| 2672 test_executable_param_kind_named() { | 2703 test_executable_param_kind_named() { |
| 2673 UnlinkedExecutable executable = serializeExecutableText('f({x}) {}'); | 2704 UnlinkedExecutable executable = serializeExecutableText('f({x}) {}'); |
| 2674 expect(executable.parameters[0].kind, UnlinkedParamKind.named); | 2705 expect(executable.parameters[0].kind, UnlinkedParamKind.named); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2711 test_executable_param_order() { | 2742 test_executable_param_order() { |
| 2712 UnlinkedExecutable executable = serializeExecutableText('f(x, y) {}'); | 2743 UnlinkedExecutable executable = serializeExecutableText('f(x, y) {}'); |
| 2713 expect(executable.parameters, hasLength(2)); | 2744 expect(executable.parameters, hasLength(2)); |
| 2714 expect(executable.parameters[0].name, 'x'); | 2745 expect(executable.parameters[0].name, 'x'); |
| 2715 expect(executable.parameters[1].name, 'y'); | 2746 expect(executable.parameters[1].name, 'y'); |
| 2716 } | 2747 } |
| 2717 | 2748 |
| 2718 test_executable_param_type_explicit() { | 2749 test_executable_param_type_explicit() { |
| 2719 UnlinkedExecutable executable = serializeExecutableText('f(dynamic x) {}'); | 2750 UnlinkedExecutable executable = serializeExecutableText('f(dynamic x) {}'); |
| 2720 checkDynamicTypeRef(executable.parameters[0].type); | 2751 checkDynamicTypeRef(executable.parameters[0].type); |
| 2721 expect(executable.parameters[0].hasImplicitType, isFalse); | |
| 2722 } | 2752 } |
| 2723 | 2753 |
| 2724 test_executable_param_type_implicit() { | 2754 test_executable_param_type_implicit() { |
| 2725 UnlinkedExecutable executable = serializeExecutableText('f(x) {}'); | 2755 UnlinkedExecutable executable = serializeExecutableText('f(x) {}'); |
| 2726 checkDynamicTypeRef(executable.parameters[0].type); | 2756 expect(executable.parameters[0].type, isNull); |
| 2727 expect(executable.parameters[0].hasImplicitType, isTrue); | |
| 2728 } | 2757 } |
| 2729 | 2758 |
| 2730 test_executable_return_type() { | 2759 test_executable_return_type() { |
| 2731 UnlinkedExecutable executable = serializeExecutableText('int f() => 1;'); | 2760 UnlinkedExecutable executable = serializeExecutableText('int f() => 1;'); |
| 2732 checkTypeRef(executable.returnType, 'dart:core', 'dart:core', 'int'); | 2761 checkTypeRef(executable.returnType, 'dart:core', 'dart:core', 'int'); |
| 2733 expect(executable.hasImplicitReturnType, isFalse); | |
| 2734 } | 2762 } |
| 2735 | 2763 |
| 2736 test_executable_return_type_implicit() { | 2764 test_executable_return_type_implicit() { |
| 2737 UnlinkedExecutable executable = serializeExecutableText('f() {}'); | 2765 UnlinkedExecutable executable = serializeExecutableText('f() {}'); |
| 2738 checkDynamicTypeRef(executable.returnType); | 2766 expect(executable.returnType, isNull); |
| 2739 expect(executable.hasImplicitReturnType, isTrue); | |
| 2740 } | 2767 } |
| 2741 | 2768 |
| 2742 test_executable_return_type_void() { | 2769 test_executable_return_type_void() { |
| 2743 UnlinkedExecutable executable = serializeExecutableText('void f() {}'); | 2770 UnlinkedExecutable executable = serializeExecutableText('void f() {}'); |
| 2744 checkVoidTypeRef(executable.returnType); | 2771 checkVoidTypeRef(executable.returnType); |
| 2745 } | 2772 } |
| 2746 | 2773 |
| 2747 test_executable_setter() { | 2774 test_executable_setter() { |
| 2748 String text = 'void set f(value) {}'; | 2775 String text = 'void set f(value) {}'; |
| 2749 UnlinkedExecutable executable = serializeExecutableText(text, 'f='); | 2776 UnlinkedExecutable executable = serializeExecutableText(text, 'f='); |
| 2750 expect(executable.kind, UnlinkedExecutableKind.setter); | 2777 expect(executable.kind, UnlinkedExecutableKind.setter); |
| 2751 expect(executable.hasImplicitReturnType, isFalse); | 2778 expect(executable.returnType, isNotNull); |
| 2752 expect(executable.isExternal, isFalse); | 2779 expect(executable.isExternal, isFalse); |
| 2753 expect(executable.nameOffset, text.indexOf('f')); | 2780 expect(executable.nameOffset, text.indexOf('f')); |
| 2754 expect(findVariable('f'), isNull); | 2781 expect(findVariable('f'), isNull); |
| 2755 expect(findExecutable('f'), isNull); | 2782 expect(findExecutable('f'), isNull); |
| 2756 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1)); | 2783 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1)); |
| 2757 expect(unlinkedUnits[0].publicNamespace.names[0].kind, | 2784 expect(unlinkedUnits[0].publicNamespace.names[0].kind, |
| 2758 ReferenceKind.topLevelPropertyAccessor); | 2785 ReferenceKind.topLevelPropertyAccessor); |
| 2759 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'f='); | 2786 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'f='); |
| 2760 } | 2787 } |
| 2761 | 2788 |
| 2762 test_executable_setter_external() { | 2789 test_executable_setter_external() { |
| 2763 UnlinkedExecutable executable = | 2790 UnlinkedExecutable executable = |
| 2764 serializeExecutableText('external void set f(value);', 'f='); | 2791 serializeExecutableText('external void set f(value);', 'f='); |
| 2765 expect(executable.isExternal, isTrue); | 2792 expect(executable.isExternal, isTrue); |
| 2766 } | 2793 } |
| 2767 | 2794 |
| 2768 test_executable_setter_implicit_return() { | 2795 test_executable_setter_implicit_return() { |
| 2769 UnlinkedExecutable executable = | 2796 UnlinkedExecutable executable = |
| 2770 serializeExecutableText('set f(value) {}', 'f='); | 2797 serializeExecutableText('set f(value) {}', 'f='); |
| 2771 expect(executable.hasImplicitReturnType, isTrue); | 2798 expect(executable.returnType, isNull); |
| 2772 checkDynamicTypeRef(executable.returnType); | |
| 2773 } | 2799 } |
| 2774 | 2800 |
| 2775 test_executable_setter_private() { | 2801 test_executable_setter_private() { |
| 2776 serializeExecutableText('void set _f(value) {}', '_f='); | 2802 serializeExecutableText('void set _f(value) {}', '_f='); |
| 2777 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); | 2803 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); |
| 2778 } | 2804 } |
| 2779 | 2805 |
| 2780 test_executable_setter_type() { | 2806 test_executable_setter_type() { |
| 2781 UnlinkedExecutable executable = | 2807 UnlinkedExecutable executable = |
| 2782 serializeExecutableText('void set f(int value) {}', 'f='); | 2808 serializeExecutableText('void set f(int value) {}', 'f='); |
| (...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3412 checkUnresolvedTypeRef( | 3438 checkUnresolvedTypeRef( |
| 3413 serializeTypeText('dynamic.T', allowErrors: true), 'dynamic', 'T'); | 3439 serializeTypeText('dynamic.T', allowErrors: true), 'dynamic', 'T'); |
| 3414 } | 3440 } |
| 3415 | 3441 |
| 3416 test_invalid_prefix_type_parameter() { | 3442 test_invalid_prefix_type_parameter() { |
| 3417 if (checkAstDerivedData) { | 3443 if (checkAstDerivedData) { |
| 3418 // TODO(paulberry): get this to work properly. | 3444 // TODO(paulberry): get this to work properly. |
| 3419 return; | 3445 return; |
| 3420 } | 3446 } |
| 3421 checkUnresolvedTypeRef( | 3447 checkUnresolvedTypeRef( |
| 3422 serializeClassText('class C<T> { T.U x; }', allowErrors: true) | 3448 serializeClassText('class C<T> { T.U x; }', allowErrors: true).fields[0] |
| 3423 .fields[0] | |
| 3424 .type, | 3449 .type, |
| 3425 'T', | 3450 'T', |
| 3426 'U'); | 3451 'U'); |
| 3427 } | 3452 } |
| 3428 | 3453 |
| 3429 test_invalid_prefix_void() { | 3454 test_invalid_prefix_void() { |
| 3430 if (checkAstDerivedData) { | 3455 if (checkAstDerivedData) { |
| 3431 // TODO(paulberry): get this to work properly. | 3456 // TODO(paulberry): get this to work properly. |
| 3432 return; | 3457 return; |
| 3433 } | 3458 } |
| (...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4085 */ | 4110 */ |
| 4086 var v;'''; | 4111 var v;'''; |
| 4087 UnlinkedVariable variable = serializeVariableText(text); | 4112 UnlinkedVariable variable = serializeVariableText(text); |
| 4088 expect(variable.documentationComment, isNotNull); | 4113 expect(variable.documentationComment, isNotNull); |
| 4089 checkDocumentationComment(variable.documentationComment, text); | 4114 checkDocumentationComment(variable.documentationComment, text); |
| 4090 } | 4115 } |
| 4091 | 4116 |
| 4092 test_variable_explicit_dynamic() { | 4117 test_variable_explicit_dynamic() { |
| 4093 UnlinkedVariable variable = serializeVariableText('dynamic v;'); | 4118 UnlinkedVariable variable = serializeVariableText('dynamic v;'); |
| 4094 checkDynamicTypeRef(variable.type); | 4119 checkDynamicTypeRef(variable.type); |
| 4095 expect(variable.hasImplicitType, isFalse); | |
| 4096 } | 4120 } |
| 4097 | 4121 |
| 4098 test_variable_final_top_level() { | 4122 test_variable_final_top_level() { |
| 4099 UnlinkedVariable variable = | 4123 UnlinkedVariable variable = |
| 4100 serializeVariableText('final int i = 0;', variableName: 'i'); | 4124 serializeVariableText('final int i = 0;', variableName: 'i'); |
| 4101 expect(variable.isFinal, isTrue); | 4125 expect(variable.isFinal, isTrue); |
| 4102 } | 4126 } |
| 4103 | 4127 |
| 4104 test_variable_implicit_dynamic() { | 4128 test_variable_implicit_dynamic() { |
| 4105 UnlinkedVariable variable = serializeVariableText('var v;'); | 4129 UnlinkedVariable variable = serializeVariableText('var v;'); |
| 4106 checkDynamicTypeRef(variable.type); | 4130 expect(variable.type, isNull); |
| 4107 expect(variable.hasImplicitType, isTrue); | |
| 4108 } | 4131 } |
| 4109 | 4132 |
| 4110 test_variable_name() { | 4133 test_variable_name() { |
| 4111 UnlinkedVariable variable = | 4134 UnlinkedVariable variable = |
| 4112 serializeVariableText('int i;', variableName: 'i'); | 4135 serializeVariableText('int i;', variableName: 'i'); |
| 4113 expect(variable.name, 'i'); | 4136 expect(variable.name, 'i'); |
| 4114 } | 4137 } |
| 4115 | 4138 |
| 4116 test_variable_no_flags() { | 4139 test_variable_no_flags() { |
| 4117 UnlinkedVariable variable = | 4140 UnlinkedVariable variable = |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4227 expect(constExpr.operations, operators); | 4250 expect(constExpr.operations, operators); |
| 4228 expect(constExpr.ints, ints); | 4251 expect(constExpr.ints, ints); |
| 4229 expect(constExpr.doubles, doubles); | 4252 expect(constExpr.doubles, doubles); |
| 4230 expect(constExpr.strings, strings); | 4253 expect(constExpr.strings, strings); |
| 4231 expect(constExpr.references, hasLength(referenceValidators.length)); | 4254 expect(constExpr.references, hasLength(referenceValidators.length)); |
| 4232 for (int i = 0; i < referenceValidators.length; i++) { | 4255 for (int i = 0; i < referenceValidators.length; i++) { |
| 4233 referenceValidators[i](constExpr.references[i]); | 4256 referenceValidators[i](constExpr.references[i]); |
| 4234 } | 4257 } |
| 4235 } | 4258 } |
| 4236 } | 4259 } |
| OLD | NEW |