--- a/RegressionTests__IntegerTest.st Thu Jun 21 13:20:07 2001 +0200
+++ b/RegressionTests__IntegerTest.st Fri Jul 20 13:24:17 2001 +0200
@@ -645,6 +645,88 @@
"Modified: / 31.10.2000 / 20:23:20 / cg"
!
+testDivision
+ |a b op rslt|
+
+ op := #//.
+ a := -1.
+ b := 8.
+ self assert:(-1 // 8 == -1).
+ self assert:(a // 8 == -1).
+ self assert:(-1 // b == -1).
+ self assert:(a // b == -1).
+
+ self assert:((rslt := -1 perform:op with: 8) == -1).
+ self assert:((rslt := a perform:op with: 8) == -1).
+ self assert:((rslt := -1 perform:op with: b) == -1).
+ self assert:((rslt := a perform:op with: b) == -1).
+
+ a := 1.
+ b := -8.
+ self assert:(1 // -8 == -1).
+ self assert:(a // -8 == -1).
+ self assert:(1 // b == -1).
+ self assert:(a // b == -1).
+
+ self assert:((rslt := 1 perform:op with: -8) == -1).
+ self assert:((rslt := a perform:op with: -8) == -1).
+ self assert:((rslt := 1 perform:op with: b) == -1).
+ self assert:((rslt := a perform:op with: b) == -1).
+
+ a := -1.
+ b := -8.
+ self assert:(-1 // -8 == 0).
+ self assert:(a // -8 == 0).
+ self assert:(-1 // b == 0).
+ self assert:(a // b == 0).
+
+ self assert:((rslt := -1 perform:op with: -8) == 0).
+ self assert:((rslt := a perform:op with: -8) == 0).
+ self assert:((rslt := -1 perform:op with: b) == 0).
+ self assert:((rslt := a perform:op with: b) == 0).
+
+ op := #quo:.
+ a := -1.
+ b := 8.
+ self assert:((rslt := -1 quo: 8) == 0).
+ self assert:((rslt := a quo: 8) == 0).
+ self assert:((rslt := -1 quo: b) == 0).
+ self assert:((rslt := a quo: b) == 0).
+
+ self assert:((rslt := -1 perform:op with: -8) == 0).
+ self assert:((rslt := a perform:op with: -8) == 0).
+ self assert:((rslt := -1 perform:op with: b) == 0).
+ self assert:((rslt := a perform:op with: b) == 0).
+
+ a := 1.
+ b := -8.
+ self assert:((rslt := 1 quo: -8) == 0).
+ self assert:((rslt := a quo: -8) == 0).
+ self assert:((rslt := 1 quo: b) == 0).
+ self assert:((rslt := a quo: b) == 0).
+
+ self assert:((rslt := 1 perform:op with: -8) == 0).
+ self assert:((rslt := a perform:op with: -8) == 0).
+ self assert:((rslt := 1 perform:op with: b) == 0).
+ self assert:((rslt := a perform:op with: b) == 0).
+
+ a := -1.
+ b := -8.
+ self assert:((rslt := -1 quo: -8) == 0).
+ self assert:((rslt := a quo: -8) == 0).
+ self assert:((rslt := -1 quo: b) == 0).
+ self assert:((rslt := a quo: b) == 0).
+
+ self assert:((rslt := -1 perform:op with: -8) == 0).
+ self assert:((rslt := a perform:op with: -8) == 0).
+ self assert:((rslt := -1 perform:op with: b) == 0).
+ self assert:((rslt := a perform:op with: b) == 0).
+
+ "
+ self basicNew testDivision
+ "
+!
+
testEncodeDecode
self assert:(1 encodeAsBCD hexPrintString = '1').
self assert:(12 encodeAsBCD hexPrintString = '12').
@@ -1543,6 +1625,88 @@
"Modified: / 4.6.1999 / 18:41:09 / cg"
!
+testModulu
+ |a b op|
+
+ op := #\\.
+ a := -1.
+ b := 8.
+ self assert:(-1 \\ 8 == 7).
+ self assert:(a \\ 8 == 7).
+ self assert:(-1 \\ b == 7).
+ self assert:(a \\ b == 7).
+
+ self assert:((-1 perform:op with: 8) == 7).
+ self assert:((a perform:op with: 8) == 7).
+ self assert:((-1 perform:op with: b) == 7).
+ self assert:((a perform:op with: b) == 7).
+
+ a := 1.
+ b := -8.
+ self assert:(1 \\ -8 == -7).
+ self assert:(a \\ -8 == -7).
+ self assert:(1 \\ b == -7).
+ self assert:(a \\ b == -7).
+
+ self assert:((1 perform:op with: -8) == -7).
+ self assert:((a perform:op with: -8) == -7).
+ self assert:((1 perform:op with: b) == -7).
+ self assert:((a perform:op with: b) == -7).
+
+ a := -1.
+ b := -8.
+ self assert:(-1 \\ -8 == -1).
+ self assert:(a \\ -8 == -1).
+ self assert:(-1 \\ b == -1).
+ self assert:(a \\ b == -1).
+
+ self assert:((-1 perform:op with: -8) == -1).
+ self assert:((a perform:op with: -8) == -1).
+ self assert:((-1 perform:op with: b) == -1).
+ self assert:((a perform:op with: b) == -1).
+
+ op := #rem:.
+ a := -1.
+ b := 8.
+ self assert:((-1 rem: 8) == -1).
+ self assert:((a rem: 8) == -1).
+ self assert:((-1 rem: b) == -1).
+ self assert:((a rem: b) == -1).
+
+ self assert:((-1 perform:op with: -8) == -1).
+ self assert:((a perform:op with: -8) == -1).
+ self assert:((-1 perform:op with: b) == -1).
+ self assert:((a perform:op with: b) == -1).
+
+ a := 1.
+ b := -8.
+ self assert:((1 rem: -8) == 1).
+ self assert:((a rem: -8) == 1).
+ self assert:((1 rem: b) == 1).
+ self assert:((a rem: b) == 1).
+
+ self assert:((1 perform:op with: -8) == 1).
+ self assert:((a perform:op with: -8) == 1).
+ self assert:((1 perform:op with: b) == 1).
+ self assert:((a perform:op with: b) == 1).
+
+ a := -1.
+ b := -8.
+ self assert:((-1 rem: -8) == -1).
+ self assert:((a rem: -8) == -1).
+ self assert:((-1 rem: b) == -1).
+ self assert:((a rem: b) == -1).
+
+ self assert:((-1 perform:op with: -8) == -1).
+ self assert:((a perform:op with: -8) == -1).
+ self assert:((-1 perform:op with: b) == -1).
+ self assert:((a perform:op with: b) == -1).
+
+ "
+ self basicNew testModulu
+ "
+!
+
testPrinting1
self assert:(10 printString = '10').
self assert:(100 printString = '100').