*** empty log message ***
authorClaus Gittinger <cg@exept.de>
Mon, 29 Mar 2004 18:33:43 +0200
changeset 238 41116eb0ebba
parent 237 9fab806f93ee
child 239 e5829ccc5a7a
*** empty log message ***
RegressionTests__IntegerTest.st
--- a/RegressionTests__IntegerTest.st	Wed Mar 03 22:55:42 2004 +0100
+++ b/RegressionTests__IntegerTest.st	Mon Mar 29 18:33:43 2004 +0200
@@ -2820,6 +2820,171 @@
 "
 self basicNew rack:1 subrack:3 board:5 port:33 channel:8 typeId:7
 "
+!
+
+test_gcdBug1
+| theBase theMersenne theRest theGcd theOldRest theOldGcd |
+theBase := 2.
+
+132 to: 135 do: 
+[: theOrder |
+ false    "<<<< here i replaced some piece of code by false just to
+reproduce the error without having to ship all my code >>>>"
+   ifFalse: [
+
+     theRest := ((theBase raisedTo: theOrder) - 1) / (theBase - 1).
+     30 to: 67 "theOrder - 1" do:
+ [:theFactorOrder |
+Transcript show:theOrder; space.
+Transcript showCR:theFactorOrder.
+     (theOrder \\ theFactorOrder) = 0
+        ifTrue: [       "<<<< is a divisor of the order >>>>"
+
+          theFactorOrder = 131 ifTrue: ['131 ist kein Teiler von 132'
+halt].
+          (theOrder / theFactorOrder) isFraction 
+             ifTrue: [
+               self halt "Fehler!!"      "<<<<<<<<< dieser Code wird
+                                        nicht ausgeführt!!!!!! >>>>>"
+             ].
+
+          theMersenne := ((theBase raisedTo: theFactorOrder) - 1) /
+(theBase - 1).
+
+          theGcd := theRest gcd: theMersenne.
+          [theGcd > 1]
+             whileTrue: [
+               theFactorOrder > 129 ifTrue: [self halt]."< no halt!! >"
+               theOldRest := theRest asString.
+               theOldGcd := theGcd asString.
+               theRest := theRest / theGcd.
+               theGcd := theGcd gcd: theRest. "<<<<<<<<< ERROR
+>>>>>>>"
+               ((theRest \\ theGcd) ~= 0) ifTrue: [self halt].
+               (theRest / theGcd) isFraction ifTrue: [self halt.].
+             ].
+          ].
+      ].
+    theRest = 1 ifTrue: [   "<<<< there is no prime factor of order
+theOrder >>>>"
+      theOrder halt
+   ].
+ ].
+].
+
+    "
+     self new test_gcdBug1
+    "
+!
+
+test_gcdBug2
+| theBase theMersenne theRest theGcd theOldRest theOldGcd |
+theBase := 2.
+
+132 to: 135 do: 
+[: theOrder |
+ false    "<<<< here i replaced some piece of code by false just to
+reproduce the error without having to ship all my code >>>>"
+   ifFalse: [
+
+     theRest := ((theBase raisedTo: theOrder) - 1) / (theBase - 1).
+     60 to: 67 "theOrder - 1" do:
+ [:theFactorOrder |
+Transcript show:theOrder; space.
+Transcript showCR:theFactorOrder.
+     (theOrder \\ theFactorOrder) = 0
+        ifTrue: [       "<<<< is a divisor of the order >>>>"
+
+          theFactorOrder = 131 ifTrue: ['131 ist kein Teiler von 132'
+halt].
+          (theOrder / theFactorOrder) isFraction 
+             ifTrue: [
+               self halt "Fehler!!"      "<<<<<<<<< dieser Code wird
+                                        nicht ausgeführt!!!!!! >>>>>"
+             ].
+
+          theMersenne := ((theBase raisedTo: theFactorOrder) - 1) /
+(theBase - 1).
+
+          theGcd := theRest gcd: theMersenne.
+          [theGcd > 1]
+             whileTrue: [
+               theFactorOrder > 129 ifTrue: [self halt]."< no halt!! >"
+               theOldRest := theRest asString.
+               theOldGcd := theGcd asString.
+               theRest := theRest / theGcd.
+               theGcd := theGcd gcd: theRest. "<<<<<<<<< ERROR
+>>>>>>>"
+               ((theRest \\ theGcd) ~= 0) ifTrue: [self halt].
+               (theRest / theGcd) isFraction ifTrue: [self halt.].
+             ].
+          ].
+      ].
+    theRest = 1 ifTrue: [   "<<<< there is no prime factor of order
+theOrder >>>>"
+      theOrder halt
+   ].
+ ].
+].
+
+    "
+     self new test_gcdBug2
+    "
+!
+
+test_gcdBug3
+| theBase theMersenne theRest theGcd theOldRest theOldGcd |
+theBase := 2.
+
+132 to: 135 do: 
+[: theOrder |
+ false    "<<<< here i replaced some piece of code by false just to
+reproduce the error without having to ship all my code >>>>"
+   ifFalse: [
+
+     theRest := ((theBase raisedTo: theOrder) - 1) / (theBase - 1).
+     2 to:theOrder - 1 do:
+ [:theFactorOrder |
+Transcript show:theOrder; space.
+Transcript showCR:theFactorOrder.
+     (theOrder \\ theFactorOrder) = 0
+        ifTrue: [       "<<<< is a divisor of the order >>>>"
+
+          theFactorOrder = 131 ifTrue: ['131 ist kein Teiler von 132'
+halt].
+          (theOrder / theFactorOrder) isFraction 
+             ifTrue: [
+               self halt "Fehler!!"      "<<<<<<<<< dieser Code wird
+                                        nicht ausgeführt!!!!!! >>>>>"
+             ].
+
+          theMersenne := ((theBase raisedTo: theFactorOrder) - 1) /
+(theBase - 1).
+
+          theGcd := theRest gcd: theMersenne.
+          [theGcd > 1]
+             whileTrue: [
+               theFactorOrder > 129 ifTrue: [self halt]."< no halt!! >"
+               theOldRest := theRest asString.
+               theOldGcd := theGcd asString.
+               theRest := theRest / theGcd.
+               theGcd := theGcd gcd: theRest. "<<<<<<<<< ERROR
+>>>>>>>"
+               ((theRest \\ theGcd) ~= 0) ifTrue: [self halt].
+               (theRest / theGcd) isFraction ifTrue: [self halt.].
+             ].
+          ].
+      ].
+    theRest = 1 ifTrue: [   "<<<< there is no prime factor of order
+theOrder >>>>"
+      theOrder halt
+   ].
+ ].
+].
+
+    "
+     self new test_gcdBug2
+    "
 ! !
 
 !IntegerTest class methodsFor:'documentation'!