RegressionTests__IntegerTest.st
changeset 46 cfc40ffac21a
parent 45 5d24d22a546b
child 51 0e665a7d77ea
--- a/RegressionTests__IntegerTest.st	Wed Oct 27 00:14:22 1999 +0200
+++ b/RegressionTests__IntegerTest.st	Mon Nov 08 10:57:51 1999 +0100
@@ -1345,6 +1345,7 @@
     self testSmallIntegerMultiplication1.
     self testSmallIntegerMultiplication1b.
     self testSmallIntegerMultiplication2.
+    self testSmallIntegerDivision1.
 
     "
      self testSmallIntegerArithmetic
@@ -1354,6 +1355,68 @@
     "Modified: / 9.6.1999 / 17:49:57 / cg"
 !
 
+testSmallIntegerDivision1
+    "division tests.
+     Notice, the arithmetic tests are both performed via regular sends
+     and via constructed performs. The reason is to test both inlined
+     JIT-compiler code AND the regular methods code."
+
+    |s n1 n2 t|
+
+    n1 := 1000.
+
+    "/ truncation towards...
+
+    "/ ... negative infinity
+    n2 := 3.
+    self test:[(n1 // n2) == 333].
+    self test:[(n1 // n2) printString = '333'].
+    self test:[(n1 perform:'//' asSymbol with:n2) == 333].
+
+    n2 := -3.
+    self test:[(n1 // n2) == -334].
+    self test:[(n1 // n2) printString = '-334'].
+    self test:[(n1 perform:'//' asSymbol with:n2) == -334].
+
+    n2 := 3600000.
+    self test:[(n1 // n2) == 0].
+    self test:[(n1 // n2) printString = '0'].
+    self test:[(n1 perform:'//' asSymbol with:n2) == 0].
+
+    n2 := -3600000.
+    self test:[(n1 // n2) == -1].
+    self test:[(n1 // n2) printString = '-1'].
+    self test:[(n1 perform:'//' asSymbol with:n2) == -1].
+
+    "/ ... zero
+    n2 := 3.
+    self test:[(n1 quo: n2) == 333].
+    self test:[(n1 quo: n2) printString = '333'].
+    self test:[(n1 perform:'quo:' asSymbol with:n2) == 333].
+
+    n2 := -3.
+    self test:[(n1 quo: n2) == -333].
+    self test:[(n1 quo: n2) printString = '-333'].
+    self test:[(n1 perform:'quo:' asSymbol with:n2) == -333].
+
+    n2 := 3600000.
+    self test:[(n1 quo: n2) == 0].
+    self test:[(n1 quo: n2) printString = '0'].
+    self test:[(n1 perform:'quo:' asSymbol with:n2) == 0].
+
+    n2 := -3600000.
+    self test:[(n1 quo: n2) == 0].
+    self test:[(n1 quo: n2) printString = '0'].
+    self test:[(n1 perform:'quo:' asSymbol with:n2) == 0].
+
+    "
+     self testSmallIntegerDivision1
+    "
+
+    "Modified: / 9.6.1999 / 17:47:56 / cg"
+    "Created: / 9.6.1999 / 17:49:45 / cg"
+!
+
 testSmallIntegerMultiplication1
     "multiply tests (var * const).
      Notice, the arithmetic tests are both performed via regular sends