RegressionTests__IntegerTest.st
changeset 46 cfc40ffac21a
parent 45 5d24d22a546b
child 51 0e665a7d77ea
equal deleted inserted replaced
45:5d24d22a546b 46:cfc40ffac21a
  1343     self test:[(n2 perform:'abs' asSymbol) = n2 negated].
  1343     self test:[(n2 perform:'abs' asSymbol) = n2 negated].
  1344 
  1344 
  1345     self testSmallIntegerMultiplication1.
  1345     self testSmallIntegerMultiplication1.
  1346     self testSmallIntegerMultiplication1b.
  1346     self testSmallIntegerMultiplication1b.
  1347     self testSmallIntegerMultiplication2.
  1347     self testSmallIntegerMultiplication2.
       
  1348     self testSmallIntegerDivision1.
  1348 
  1349 
  1349     "
  1350     "
  1350      self testSmallIntegerArithmetic
  1351      self testSmallIntegerArithmetic
  1351     "
  1352     "
  1352 
  1353 
  1353     "Created: / 6.6.1999 / 14:47:51 / cg"
  1354     "Created: / 6.6.1999 / 14:47:51 / cg"
  1354     "Modified: / 9.6.1999 / 17:49:57 / cg"
  1355     "Modified: / 9.6.1999 / 17:49:57 / cg"
       
  1356 !
       
  1357 
       
  1358 testSmallIntegerDivision1
       
  1359     "division tests.
       
  1360      Notice, the arithmetic tests are both performed via regular sends
       
  1361      and via constructed performs. The reason is to test both inlined
       
  1362      JIT-compiler code AND the regular methods code."
       
  1363 
       
  1364     |s n1 n2 t|
       
  1365 
       
  1366     n1 := 1000.
       
  1367 
       
  1368     "/ truncation towards...
       
  1369 
       
  1370     "/ ... negative infinity
       
  1371     n2 := 3.
       
  1372     self test:[(n1 // n2) == 333].
       
  1373     self test:[(n1 // n2) printString = '333'].
       
  1374     self test:[(n1 perform:'//' asSymbol with:n2) == 333].
       
  1375 
       
  1376     n2 := -3.
       
  1377     self test:[(n1 // n2) == -334].
       
  1378     self test:[(n1 // n2) printString = '-334'].
       
  1379     self test:[(n1 perform:'//' asSymbol with:n2) == -334].
       
  1380 
       
  1381     n2 := 3600000.
       
  1382     self test:[(n1 // n2) == 0].
       
  1383     self test:[(n1 // n2) printString = '0'].
       
  1384     self test:[(n1 perform:'//' asSymbol with:n2) == 0].
       
  1385 
       
  1386     n2 := -3600000.
       
  1387     self test:[(n1 // n2) == -1].
       
  1388     self test:[(n1 // n2) printString = '-1'].
       
  1389     self test:[(n1 perform:'//' asSymbol with:n2) == -1].
       
  1390 
       
  1391     "/ ... zero
       
  1392     n2 := 3.
       
  1393     self test:[(n1 quo: n2) == 333].
       
  1394     self test:[(n1 quo: n2) printString = '333'].
       
  1395     self test:[(n1 perform:'quo:' asSymbol with:n2) == 333].
       
  1396 
       
  1397     n2 := -3.
       
  1398     self test:[(n1 quo: n2) == -333].
       
  1399     self test:[(n1 quo: n2) printString = '-333'].
       
  1400     self test:[(n1 perform:'quo:' asSymbol with:n2) == -333].
       
  1401 
       
  1402     n2 := 3600000.
       
  1403     self test:[(n1 quo: n2) == 0].
       
  1404     self test:[(n1 quo: n2) printString = '0'].
       
  1405     self test:[(n1 perform:'quo:' asSymbol with:n2) == 0].
       
  1406 
       
  1407     n2 := -3600000.
       
  1408     self test:[(n1 quo: n2) == 0].
       
  1409     self test:[(n1 quo: n2) printString = '0'].
       
  1410     self test:[(n1 perform:'quo:' asSymbol with:n2) == 0].
       
  1411 
       
  1412     "
       
  1413      self testSmallIntegerDivision1
       
  1414     "
       
  1415 
       
  1416     "Modified: / 9.6.1999 / 17:47:56 / cg"
       
  1417     "Created: / 9.6.1999 / 17:49:45 / cg"
  1355 !
  1418 !
  1356 
  1419 
  1357 testSmallIntegerMultiplication1
  1420 testSmallIntegerMultiplication1
  1358     "multiply tests (var * const).
  1421     "multiply tests (var * const).
  1359      Notice, the arithmetic tests are both performed via regular sends
  1422      Notice, the arithmetic tests are both performed via regular sends