RegressionTests__IntegerTest.st
changeset 150 a57daf60d4f2
parent 112 e3bd6adcc7cf
child 151 56cceb5c0318
equal deleted inserted replaced
149:8115618b0874 150:a57daf60d4f2
   683     self assert:((rslt := -1 perform:op with: -8) == 0).
   683     self assert:((rslt := -1 perform:op with: -8) == 0).
   684     self assert:((rslt := a perform:op with: -8) == 0).
   684     self assert:((rslt := a perform:op with: -8) == 0).
   685     self assert:((rslt := -1 perform:op with: b) == 0).
   685     self assert:((rslt := -1 perform:op with: b) == 0).
   686     self assert:((rslt := a perform:op with: b) == 0).
   686     self assert:((rslt := a perform:op with: b) == 0).
   687 
   687 
       
   688     a := 1.
       
   689     b := 8.
       
   690     self assert:(1 // 8 == 0).
       
   691     self assert:(a // 8 == 0).
       
   692     self assert:(1 // b == 0).
       
   693     self assert:(a // b == 0).
       
   694 
       
   695     self assert:((rslt := 1 perform:op with: 8) == 0).
       
   696     self assert:((rslt := a perform:op with: 8) == 0).
       
   697     self assert:((rslt := 1 perform:op with: b) == 0).
       
   698     self assert:((rslt := a perform:op with: b) == 0).
       
   699 
       
   700     a := -16.
       
   701     b := 8.
       
   702     self assert:(-16 // 8 == -2).
       
   703     self assert:(a // 8 == -2).
       
   704     self assert:(-16 // b == -2).
       
   705     self assert:(a // b == -2).
       
   706 
       
   707     self assert:((rslt := -16 perform:op with: 8) == -2).
       
   708     self assert:((rslt := a perform:op with: 8) == -2).
       
   709     self assert:((rslt := -16 perform:op with: b) == -2).
       
   710     self assert:((rslt := a perform:op with: b) == -2).
       
   711 
       
   712     a := 16.
       
   713     b := -8.
       
   714     self assert:(16 // -8 == -2).
       
   715     self assert:(a // -8 == -2).
       
   716     self assert:(16 // b == -2).
       
   717     self assert:(a // b == -2).
       
   718 
       
   719     self assert:((rslt := 16 perform:op with: -8) == -2).
       
   720     self assert:((rslt := a perform:op with: -8) == -2).
       
   721     self assert:((rslt := 16 perform:op with: b) == -2).
       
   722     self assert:((rslt := a perform:op with: b) == -2).
       
   723 
       
   724     a := -16.
       
   725     b := -8.
       
   726     self assert:(-16 // -8 == 2).
       
   727     self assert:(a // -8 == 2).
       
   728     self assert:(-16 // b == 2).
       
   729     self assert:(a // b == 2).
       
   730 
       
   731     self assert:((rslt := -16 perform:op with: -8) == 2).
       
   732     self assert:((rslt := a perform:op with: -8) == 2).
       
   733     self assert:((rslt := -16 perform:op with: b) == 2).
       
   734     self assert:((rslt := a perform:op with: b) == 2).
       
   735 
       
   736     a := 16.
       
   737     b := 8.
       
   738     self assert:(16 // 8 == 2).
       
   739     self assert:(a // 8 == 2).
       
   740     self assert:(16 // b == 2).
       
   741     self assert:(a // b == 2).
       
   742 
       
   743     self assert:((rslt := 16 perform:op with: 8) == 2).
       
   744     self assert:((rslt := a perform:op with: 8) == 2).
       
   745     self assert:((rslt := 16 perform:op with: b) == 2).
       
   746     self assert:((rslt := a perform:op with: b) == 2).
       
   747 
   688     op := #quo:.
   748     op := #quo:.
   689     a := -1.
   749     a := -1.
   690     b := 8.
   750     b := 8.
   691     self assert:((rslt := -1 quo: 8) == 0).
   751     self assert:((rslt := -1 quo: 8) == 0).
   692     self assert:((rslt := a quo: 8) == 0).
   752     self assert:((rslt := a quo: 8) == 0).
   719 
   779 
   720     self assert:((rslt := -1 perform:op with: -8) == 0).
   780     self assert:((rslt := -1 perform:op with: -8) == 0).
   721     self assert:((rslt := a perform:op with: -8) == 0).
   781     self assert:((rslt := a perform:op with: -8) == 0).
   722     self assert:((rslt := -1 perform:op with: b) == 0).
   782     self assert:((rslt := -1 perform:op with: b) == 0).
   723     self assert:((rslt := a perform:op with: b) == 0).
   783     self assert:((rslt := a perform:op with: b) == 0).
       
   784 
       
   785     a := 1.
       
   786     b := 8.
       
   787     self assert:((rslt := 1 quo: 8) == 0).
       
   788     self assert:((rslt := a quo: 8) == 0).
       
   789     self assert:((rslt := 1 quo: b) == 0).
       
   790     self assert:((rslt := a quo: b) == 0).
       
   791 
       
   792     self assert:((rslt := 1 perform:op with: 8) == 0).
       
   793     self assert:((rslt := a perform:op with: 8) == 0).
       
   794     self assert:((rslt := 1 perform:op with: b) == 0).
       
   795     self assert:((rslt := a perform:op with: b) == 0).
       
   796 
       
   797     a := -16.
       
   798     b := 8.
       
   799     self assert:((rslt := -16 quo: 8) == -2).
       
   800     self assert:((rslt := a quo: 8) == -2).
       
   801     self assert:((rslt := -16 quo: b) == -2).
       
   802     self assert:((rslt := a quo: b) == -2).
       
   803 
       
   804     self assert:((rslt := -16 perform:op with: 8) == -2).
       
   805     self assert:((rslt := a perform:op with: 8) == -2).
       
   806     self assert:((rslt := -16 perform:op with: b) == -2).
       
   807     self assert:((rslt := a perform:op with: b) == -2).
       
   808 
       
   809     a := 16.
       
   810     b := -8.
       
   811     self assert:((rslt := 16 quo: -8) == -2).
       
   812     self assert:((rslt := a quo: -8) == -2).
       
   813     self assert:((rslt := 16 quo: b) == -2).
       
   814     self assert:((rslt := a quo: b) == -2).
       
   815 
       
   816     self assert:((rslt := 16 perform:op with: -8) == -2).
       
   817     self assert:((rslt := a perform:op with: -8) == -2).
       
   818     self assert:((rslt := 16 perform:op with: b) == -2).
       
   819     self assert:((rslt := a perform:op with: b) == -2).
       
   820 
       
   821     a := -16.
       
   822     b := -8.
       
   823     self assert:((rslt := -16 quo: -8) == 2).
       
   824     self assert:((rslt := a quo: -8) == 2).
       
   825     self assert:((rslt := -16 quo: b) == 2).
       
   826     self assert:((rslt := a quo: b) == 2).
       
   827 
       
   828     self assert:((rslt := -16 perform:op with: -8) == 2).
       
   829     self assert:((rslt := a perform:op with: -8) == 2).
       
   830     self assert:((rslt := -16 perform:op with: b) == 2).
       
   831     self assert:((rslt := a perform:op with: b) == 2).
       
   832 
       
   833     a := 16.
       
   834     b := 8.
       
   835     self assert:((rslt := 16 quo: 8) == 2).
       
   836     self assert:((rslt := a quo: 8) == 2).
       
   837     self assert:((rslt := 16 quo: b) == 2).
       
   838     self assert:((rslt := a quo: b) == 2).
       
   839 
       
   840     self assert:((rslt := 16 perform:op with: 8) == 2).
       
   841     self assert:((rslt := a perform:op with: 8) == 2).
       
   842     self assert:((rslt := 16 perform:op with: b) == 2).
       
   843     self assert:((rslt := a perform:op with: b) == 2).
   724 
   844 
   725     "
   845     "
   726      self basicNew testDivision
   846      self basicNew testDivision
   727     "
   847     "
   728 !
   848 !
  1663     self assert:((-1 perform:op with: -8) == -1).
  1783     self assert:((-1 perform:op with: -8) == -1).
  1664     self assert:((a perform:op with: -8) == -1).
  1784     self assert:((a perform:op with: -8) == -1).
  1665     self assert:((-1 perform:op with: b) == -1).
  1785     self assert:((-1 perform:op with: b) == -1).
  1666     self assert:((a perform:op with: b) == -1).
  1786     self assert:((a perform:op with: b) == -1).
  1667 
  1787 
       
  1788     a := 1.
       
  1789     b := 8.
       
  1790     self assert:(1 \\ 8 == 1).
       
  1791     self assert:(a \\ 8 == 1).
       
  1792     self assert:(1 \\ b == 1).
       
  1793     self assert:(a \\ b == 1).
       
  1794 
       
  1795     self assert:((1 perform:op with: 8) == 1).
       
  1796     self assert:((a perform:op with: 8) == 1).
       
  1797     self assert:((1 perform:op with: b) == 1).
       
  1798     self assert:((a perform:op with: b) == 1).
       
  1799 
       
  1800 
       
  1801     a := -17.
       
  1802     b := 8.
       
  1803     self assert:(-17 \\ 8 == 7).
       
  1804     self assert:(a \\ 8 == 7).
       
  1805     self assert:(-17 \\ b == 7).
       
  1806     self assert:(a \\ b == 7).
       
  1807 
       
  1808     self assert:((-17 perform:op with: 8) == 7).
       
  1809     self assert:((a perform:op with: 8) == 7).
       
  1810     self assert:((-17 perform:op with: b) == 7).
       
  1811     self assert:((a perform:op with: b) == 7).
       
  1812 
       
  1813     a := 17.
       
  1814     b := -8.
       
  1815     self assert:(17 \\ -8 == -7).
       
  1816     self assert:(a \\ -8 == -7).
       
  1817     self assert:(17 \\ b == -7).
       
  1818     self assert:(a \\ b == -7).
       
  1819 
       
  1820     self assert:((17 perform:op with: -8) == -7).
       
  1821     self assert:((a perform:op with: -8) == -7).
       
  1822     self assert:((17 perform:op with: b) == -7).
       
  1823     self assert:((a perform:op with: b) == -7).
       
  1824 
       
  1825     a := -17.
       
  1826     b := -8.
       
  1827     self assert:(-17 \\ -8 == -1).
       
  1828     self assert:(a \\ -8 == -1).
       
  1829     self assert:(-17 \\ b == -1).
       
  1830     self assert:(a \\ b == -1).
       
  1831 
       
  1832     self assert:((-17 perform:op with: -8) == -1).
       
  1833     self assert:((a perform:op with: -8) == -1).
       
  1834     self assert:((-17 perform:op with: b) == -1).
       
  1835     self assert:((a perform:op with: b) == -1).
       
  1836 
       
  1837     a := 17.
       
  1838     b := 8.
       
  1839     self assert:(17 \\ 8 == 1).
       
  1840     self assert:(a \\ 8 == 1).
       
  1841     self assert:(17 \\ b == 1).
       
  1842     self assert:(a \\ b == 1).
       
  1843 
       
  1844     self assert:((17 perform:op with: 8) == 1).
       
  1845     self assert:((a perform:op with: 8) == 1).
       
  1846     self assert:((17 perform:op with: b) == 1).
       
  1847     self assert:((a perform:op with: b) == 1).
       
  1848 
       
  1849 
  1668     op := #rem:.
  1850     op := #rem:.
  1669     a := -1.
  1851     a := -1.
  1670     b := 8.
  1852     b := 8.
  1671     self assert:((-1 rem: 8) == -1).
  1853     self assert:((-1 rem: 8) == -1).
  1672     self assert:((a rem: 8) == -1).
  1854     self assert:((a rem: 8) == -1).
  1699 
  1881 
  1700     self assert:((-1 perform:op with: -8) == -1).
  1882     self assert:((-1 perform:op with: -8) == -1).
  1701     self assert:((a perform:op with: -8) == -1).
  1883     self assert:((a perform:op with: -8) == -1).
  1702     self assert:((-1 perform:op with: b) == -1).
  1884     self assert:((-1 perform:op with: b) == -1).
  1703     self assert:((a perform:op with: b) == -1).
  1885     self assert:((a perform:op with: b) == -1).
       
  1886 
       
  1887     a := 1.
       
  1888     b := 8.
       
  1889     self assert:((1 rem: 8) == 1).
       
  1890     self assert:((a rem: 8) == 1).
       
  1891     self assert:((1 rem: b) == 1).
       
  1892     self assert:((a rem: b) == 1).
       
  1893 
       
  1894     self assert:((1 perform:op with: 8) == 1).
       
  1895     self assert:((a perform:op with: 8) == 1).
       
  1896     self assert:((1 perform:op with: b) == 1).
       
  1897     self assert:((a perform:op with: b) == 1).
       
  1898 
       
  1899     a := -17.
       
  1900     b := 8.
       
  1901     self assert:((-17 rem: 8) == -1).
       
  1902     self assert:((a rem: 8) == -1).
       
  1903     self assert:((-17 rem: b) == -1).
       
  1904     self assert:((a rem: b) == -1).
       
  1905 
       
  1906     self assert:((-17 perform:op with: -8) == -1).
       
  1907     self assert:((a perform:op with: -8) == -1).
       
  1908     self assert:((-17 perform:op with: b) == -1).
       
  1909     self assert:((a perform:op with: b) == -1).
       
  1910 
       
  1911     a := 17.
       
  1912     b := -8.
       
  1913     self assert:((17 rem: -8) == 1).
       
  1914     self assert:((a rem: -8) == 1).
       
  1915     self assert:((17 rem: b) == 1).
       
  1916     self assert:((a rem: b) == 1).
       
  1917 
       
  1918     self assert:((17 perform:op with: -8) == 1).
       
  1919     self assert:((a perform:op with: -8) == 1).
       
  1920     self assert:((17 perform:op with: b) == 1).
       
  1921     self assert:((a perform:op with: b) == 1).
       
  1922 
       
  1923     a := -17.
       
  1924     b := -8.
       
  1925     self assert:((-17 rem: -8) == -1).
       
  1926     self assert:((a rem: -8) == -1).
       
  1927     self assert:((-17 rem: b) == -1).
       
  1928     self assert:((a rem: b) == -1).
       
  1929 
       
  1930     self assert:((-17 perform:op with: -8) == -1).
       
  1931     self assert:((a perform:op with: -8) == -1).
       
  1932     self assert:((-17 perform:op with: b) == -1).
       
  1933     self assert:((a perform:op with: b) == -1).
       
  1934 
       
  1935     a := 17.
       
  1936     b := 8.
       
  1937     self assert:((17 rem: 8) == 1).
       
  1938     self assert:((a rem: 8) == 1).
       
  1939     self assert:((17 rem: b) == 1).
       
  1940     self assert:((a rem: b) == 1).
       
  1941 
       
  1942     self assert:((17 perform:op with: 8) == 1).
       
  1943     self assert:((a perform:op with: 8) == 1).
       
  1944     self assert:((17 perform:op with: b) == 1).
       
  1945     self assert:((a perform:op with: b) == 1).
  1704 
  1946 
  1705     "
  1947     "
  1706      self basicNew testModulu
  1948      self basicNew testModulu
  1707     "
  1949     "
  1708 !
  1950 !