Changeset 13441
 Timestamp:
 Sep 10, 2019 2:54:47 PM (3 months ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/Compiler/ModelicaFrontEnd/test/modelica/OperatorRecordTests.mo
r13432 r13441 708 708 ")}))); 709 709 end OperatorOverload13; 710 711 712 model OperatorOverload14 713 operator record Cplx2 = Cplx; 714 Cplx c1 = Cplx(1, 2); 715 Cplx2 c2 = Cplx2(3, 4); 716 Cplx c3 = c1 + c2; 717 718 annotation(__JModelica(UnitTesting(tests={ 719 FlatteningTestCase( 720 name="OperatorOverload14", 721 description="Short class decls of operator records", 722 flatModel=" 723 fclass OperatorRecordTests.OperatorOverload14 724 OperatorRecordTests.Cplx c1 = OperatorRecordTests.Cplx.'constructor'(1, 2); 725 OperatorRecordTests.OperatorOverload14.Cplx2 c2 = OperatorRecordTests.Cplx.'constructor'(3, 4); 726 OperatorRecordTests.Cplx c3 = OperatorRecordTests.Cplx.'+'(c1, c2); 727 728 public 729 function OperatorRecordTests.Cplx.'constructor' 730 input Real re; 731 input Real im; 732 output OperatorRecordTests.Cplx c; 733 algorithm 734 c.re := re; 735 c.im := im; 736 return; 737 end OperatorRecordTests.Cplx.'constructor'; 738 739 function OperatorRecordTests.Cplx.'+' 740 input OperatorRecordTests.Cplx a; 741 input OperatorRecordTests.Cplx b; 742 output OperatorRecordTests.Cplx c; 743 algorithm 744 (c) := OperatorRecordTests.Cplx.'constructor'(a.re + b.re, a.im + b.im); 745 return; 746 end OperatorRecordTests.Cplx.'+'; 747 748 record OperatorRecordTests.Cplx 749 Real re; 750 Real im; 751 end OperatorRecordTests.Cplx; 752 753 record OperatorRecordTests.OperatorOverload14.Cplx2 754 Real re; 755 Real im; 756 end OperatorRecordTests.OperatorOverload14.Cplx2; 757 758 end OperatorRecordTests.OperatorOverload14; 759 ")}))); 760 end OperatorOverload14; 710 761 711 762 … … 1591 1642 1592 1643 1644 model OperatorRecordConnect3 1645 connector C = Cplx; 1646 1647 C c1, c2, c3; 1648 equation 1649 connect(c1, c2); 1650 c3 = c1 + c2; 1651 1652 annotation(__JModelica(UnitTesting(tests={ 1653 FlatteningTestCase( 1654 name="OperatorRecordConnect3", 1655 description="Connectors that are operator records", 1656 flatModel=" 1657 fclass OperatorRecordTests.OperatorRecordConnect3 1658 OperatorRecordTests.OperatorRecordConnect3.C c1; 1659 OperatorRecordTests.OperatorRecordConnect3.C c2; 1660 OperatorRecordTests.OperatorRecordConnect3.C c3; 1661 equation 1662 c3 = OperatorRecordTests.Cplx.'+'(c1, c2); 1663 c1 = c2; 1664 1665 public 1666 function OperatorRecordTests.Cplx.'+' 1667 input OperatorRecordTests.Cplx a; 1668 input OperatorRecordTests.Cplx b; 1669 output OperatorRecordTests.Cplx c; 1670 algorithm 1671 (c) := OperatorRecordTests.Cplx.'constructor'(a.re + b.re, a.im + b.im); 1672 return; 1673 end OperatorRecordTests.Cplx.'+'; 1674 1675 function OperatorRecordTests.Cplx.'constructor' 1676 input Real re; 1677 input Real im; 1678 output OperatorRecordTests.Cplx c; 1679 algorithm 1680 c.re := re; 1681 c.im := im; 1682 return; 1683 end OperatorRecordTests.Cplx.'constructor'; 1684 1685 record OperatorRecordTests.OperatorRecordConnect3.C 1686 Real re; 1687 Real im; 1688 end OperatorRecordTests.OperatorRecordConnect3.C; 1689 1690 record OperatorRecordTests.Cplx 1691 Real re; 1692 Real im; 1693 end OperatorRecordTests.Cplx; 1694 1695 end OperatorRecordTests.OperatorRecordConnect3; 1696 ")}))); 1697 end OperatorRecordConnect3; 1698 1593 1699 1594 1700 model OperatorRecordConnect4 … … 1636 1742 end OperatorRecordConnect4; 1637 1743 1744 1745 model OperatorRecordConnect5 1746 connector C = Cplx; 1747 1748 model A 1749 C c; 1750 end A; 1751 1752 A a[2]; 1753 C c[2]; 1754 equation 1755 connect(a.c, c); 1756 1757 annotation(__JModelica(UnitTesting(tests={ 1758 FlatteningTestCase( 1759 name="OperatorRecordConnect5", 1760 description="Test connecting to array of operator record", 1761 flatModel=" 1762 fclass OperatorRecordTests.OperatorRecordConnect5 1763 OperatorRecordTests.OperatorRecordConnect5.C a[1].c; 1764 OperatorRecordTests.OperatorRecordConnect5.C a[2].c; 1765 OperatorRecordTests.OperatorRecordConnect5.C c[2]; 1766 equation 1767 a[1].c = c[1]; 1768 a[2].c = c[2]; 1769 1770 public 1771 record OperatorRecordTests.OperatorRecordConnect5.C 1772 Real re; 1773 Real im; 1774 end OperatorRecordTests.OperatorRecordConnect5.C; 1775 1776 end OperatorRecordTests.OperatorRecordConnect5; 1777 ")}))); 1778 end OperatorRecordConnect5; 1638 1779 1639 1780
Note: See TracChangeset
for help on using the changeset viewer.