RegressionTests__IntegerTest.st
author Claus Gittinger <cg@exept.de>
Wed, 16 Sep 2009 23:54:58 +0200
changeset 546 b441955005b8
parent 545 99ccb895860f
child 547 80bb15555bdf
permissions -rw-r--r--
*** empty log message ***

"{ Package: 'exept:regression' }"

"{ NameSpace: RegressionTests }"

TestCase subclass:#IntegerTest
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'tests-Regression'
!


!IntegerTest methodsFor:'misc'!

doMul0_a:arg
    ^ arg * 0

    "
     (self doMul0_a:0) ==   0   
     (self doMul0_a:1) ==   0   
     (self doMul0_a:SmallInteger maxVal) == 0  
     (self doMul0_a:SmallInteger minVal) == 0  
    "

    "Created: / 9.6.1999 / 15:50:48 / cg"
!

doMul1_a:arg
    ^ arg * 1

    "
     (self doMul1_a:0) ==   0  
     (self doMul1_a:1) ==   1  
     (self doMul1_a:SmallInteger maxVal) == SmallInteger maxVal  
     (self doMul1_a:SmallInteger minVal) == SmallInteger minVal  
    "

    "Created: / 9.6.1999 / 15:49:09 / cg"
!

doMul2_a:arg
    ^ arg * 2

    "
     (self doMul2_a:0) ==   0            
     (self doMul2_a:1) ==   2   
     (self doMul2_a:SmallInteger maxVal) = (SmallInteger maxVal + SmallInteger maxVal)  
     (self doMul2_a:SmallInteger minVal) = (SmallInteger minVal + SmallInteger minVal)  
    "

    "Modified: / 9.6.1999 / 16:57:20 / cg"
!

doMul3_a:arg
    ^ arg * 3

    "
     (self doMul3_a:0) ==   0            
     (self doMul3_a:1) ==   3   
     (self doMul3_a:-1) ==  -3   
     (self doMul3_a:10000) ==   30000   
     (self doMul3_a:SmallInteger maxVal) = (SmallInteger maxVal + SmallInteger maxVal + SmallInteger maxVal)  
     (self doMul3_a:SmallInteger minVal) = (SmallInteger minVal + SmallInteger minVal + SmallInteger minVal)  
    "

    "Created: / 9.6.1999 / 16:57:47 / cg"
    "Modified: / 9.6.1999 / 17:35:34 / cg"
!

doMul4_a:arg
    ^ arg * 4

    "
     (self doMul4_a:0) ==   0            
     (self doMul4_a:1) ==   4   
     (self doMul4_a:-1) ==  -4   
     (self doMul4_a:10000) ==   40000    
     (self doMul4_a:SmallInteger maxVal//4) == 4611686018427387900    
     (self doMul4_a:SmallInteger maxVal//4+1) = 4611686018427387904  
    "

    "Created: / 9.6.1999 / 16:57:47 / cg"
    "Modified: / 9.6.1999 / 17:37:36 / cg"
!

doMul5_a:arg
    ^ arg * 5

    "
     (self doMul5_a:0) ==   0            
     (self doMul5_a:1) ==   5   
     (self doMul5_a:-1) ==  -5   
     (self doMul5_a:10000) ==   50000    
     (self doMul5_a:SmallInteger maxVal//5) == 4611686018427387900    
     (self doMul5_a:SmallInteger maxVal//4+1) = 4611686018427387905  
    "

    "Created: / 9.6.1999 / 17:38:17 / cg"
!

doMulM1_a:arg
    ^ arg * -1

    "
     (self doMulM1_a:0) ==   0            
     (self doMulM1_a:1) ==   -1   
     (self doMulM1_a:SmallInteger maxVal) == (SmallInteger minVal + 1)  
     (self doMulM1_a:SmallInteger minVal) = (SmallInteger maxVal + 1)  
    "

    "Modified: / 9.6.1999 / 16:54:02 / cg"
!

doPlus1_a:arg
    ^ arg + 1

    "
     (self doPlus1_a:SmallInteger maxVal) =   1073741824  
    "
!

doPlus1_b:arg
    ^ arg perform:#+ with:1

    "
     (self doPlus1_b:SmallInteger maxVal) ==   1073741824  
    "
!

testMul0
    self assert: ( (self doMul0_a:0) == 0 ).
    self assert: ( (self doMul0_a:1) == 0 ).
    self assert: ( (self doMul0_a:SmallInteger maxVal) == 0 ).
    self assert: ( (self doMul0_a:SmallInteger minVal) == 0 ).
    self assert: ( (self doMul0_a:SmallInteger maxVal+1) == 0 ).
    self assert: ( (self doMul0_a:SmallInteger minVal-1) == 0 ).

    "
     self basicNew testMul0
    "

    "Created: / 9.6.1999 / 15:50:48 / cg"
!

testMul1
    self assert: ( (self doMul1_a:0) == 0 ).
    self assert: ( (self doMul1_a:1) == 1 ).
    self assert: ( (self doMul1_a:SmallInteger maxVal) == SmallInteger maxVal ).
    self assert: ( (self doMul1_a:SmallInteger minVal) == SmallInteger minVal ).
    self assert: ( (self doMul1_a:SmallInteger maxVal+1) = (SmallInteger maxVal+1) ).
    self assert: ( (self doMul1_a:SmallInteger minVal-1) = (SmallInteger minVal-1) ).

    "
     self basicNew testMul1
    "
!

testMul2
    self assert: ( (self doMul2_a:0) == 0 ).
    self assert: ( (self doMul2_a:1) == 2 ).
    self assert: ( (self doMul2_a:SmallInteger maxVal) = (SmallInteger maxVal + SmallInteger maxVal) ).
    self assert: ( (self doMul2_a:SmallInteger minVal) = (SmallInteger minVal + SmallInteger minVal) ).
    self assert: ( (self doMul2_a:SmallInteger maxVal+1) = ((SmallInteger maxVal+1)+(SmallInteger maxVal+1)) ).
    self assert: ( (self doMul2_a:SmallInteger minVal-1) = ((SmallInteger minVal-1)+(SmallInteger minVal-1)) ).

    "
     self basicNew testMul2
    "

    "Modified: / 9.6.1999 / 16:57:20 / cg"
!

testMul3
    self assert: ( (self doMul3_a:0) == 0 ).
    self assert: ( (self doMul3_a:1) == 3 ).
    self assert: ( (self doMul3_a:-1) == -3 ).
    self assert: ( (self doMul3_a:10000) == 30000 ).
    self assert: ( (self doMul3_a:SmallInteger maxVal) = (SmallInteger maxVal + SmallInteger maxVal + SmallInteger maxVal) ).
    self assert: ( (self doMul3_a:SmallInteger minVal) = (SmallInteger minVal + SmallInteger minVal + SmallInteger minVal) ).

    "
     self basicNew testMul3
    "
!

testMul4
    self assert: ( (self doMul4_a:0) == 0 ).
    self assert: ( (self doMul4_a:1) == 4 ).
    self assert: ( (self doMul4_a:-1) == -4 ).
    self assert: ( (self doMul4_a:10000) == 40000 ).
    self assert: ( (self doMul4_a:SmallInteger maxVal) = (SmallInteger maxVal + SmallInteger maxVal + SmallInteger maxVal + SmallInteger maxVal) ).
    self assert: ( (self doMul4_a:SmallInteger minVal) = (SmallInteger minVal + SmallInteger minVal + SmallInteger minVal + SmallInteger minVal) ).
    self assert: ( (self doMul4_a:SmallInteger maxVal+1//4) = (SmallInteger maxVal + 1) ).
    self assert: ( (self doMul4_a:SmallInteger minVal//4) = (SmallInteger minVal) ).

    "
     self basicNew testMul4
    "
!

testMul5
    self assert: ( (self doMul5_a:0) == 0 ).
    self assert: ( (self doMul5_a:1) == 5 ).
    self assert: ( (self doMul5_a:-1) == -5 ).
    self assert: ( (self doMul5_a:10000) == 50000 ).
    self assert: ( (self doMul5_a:SmallInteger maxVal) = (SmallInteger maxVal + SmallInteger maxVal + SmallInteger maxVal + SmallInteger maxVal + SmallInteger maxVal) ).
    self assert: ( (self doMul5_a:SmallInteger minVal) = (SmallInteger minVal + SmallInteger minVal + SmallInteger minVal + SmallInteger minVal + SmallInteger minVal) ).

    "
     self basicNew testMul5
    "
!

testMulM1
    self assert: ( (self doMulM1_a:0) == 0 ).
    self assert: ( (self doMulM1_a:1) == -1 ).
    self assert: ( (self doMulM1_a:-1) == 1 ).
    self assert: ( (self doMulM1_a:10000) == -10000 ).
    self assert: ( (self doMulM1_a:SmallInteger maxVal) = (SmallInteger minVal + 1) ).
    self assert: ( (self doMulM1_a:SmallInteger minVal) = (SmallInteger maxVal + 1) ).

    "
     self basicNew testMulM1   
    "
!

testPlus1
    self assert: ( (self doPlus1_a:0) = 1 ).
    self assert: ( (self doPlus1_a:1) = 2 ).
    self assert: ( (self doPlus1_a:-1) = 0 ).
    self assert: ( (self doPlus1_a:SmallInteger maxVal) = 1073741824).
    self assert: ( (self doPlus1_a:SmallInteger minVal) = -1073741823 ).

    "
     self basicNew testPlus1
    "
!

testPlus1perform
    self assert: ( (self doPlus1_b:0) = 1 ).
    self assert: ( (self doPlus1_b:1) = 2 ).
    self assert: ( (self doPlus1_b:-1) = 0 ).
    self assert: ( (self doPlus1_b:SmallInteger maxVal) = 1073741824).
    self assert: ( (self doPlus1_b:SmallInteger minVal) = -1073741823 ).

    "
     self basicNew testPlus1perform
    "
! !

!IntegerTest methodsFor:'private'!

absPlusOneOf:arg
                        |local1|

                        local1 := arg.
                        ^ local1 abs + 1


"
 self absPlusOneOf:-1      
 self absPlusOneOf:-1.0      
"

    "Created: / 31.10.2000 / 20:21:52 / cg"
!

alwaysTrue
    ^ true.
!

checkIsInteger:arg
    ^ arg isInteger
!

doConstantIntegerShift
    "arithmetic 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."

    |flags|

    flags := self flagsSlot.

    self alwaysTrue ifFalse:[self halt].
    ^ flags bitShift:-1.

    "
     self testIntegerShifts3
    "

    "Created: / 6.6.1999 / 14:47:51 / cg"
    "Modified: / 9.6.1999 / 17:49:57 / cg"
!

flagsSlot
    "arithmetic 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."

    ^ 2.

    "
     self testIntegerShifts3
    "

    "Created: / 6.6.1999 / 14:47:51 / cg"
    "Modified: / 9.6.1999 / 17:49:57 / cg"
!

num_00000000000007FFF
    ^ 16r00000000000007FFF

    "Modified: / 4.6.1999 / 15:29:31 / cg"
    "Created: / 4.6.1999 / 15:34:12 / cg"
!

num_00000000000008000
    ^ 16r00000000000008000

    "Modified: / 4.6.1999 / 15:29:31 / cg"
    "Created: / 4.6.1999 / 15:39:32 / cg"
!

num_0000000000000FFFF
    ^ 16r0000000000000FFFF

    "Modified: / 4.6.1999 / 15:29:31 / cg"
    "Created: / 4.6.1999 / 15:34:26 / cg"
!

num_00000000000010000
    ^ 16r00000000000010000

    "Modified: / 4.6.1999 / 15:29:31 / cg"
    "Created: / 4.6.1999 / 15:34:31 / cg"
!

num_00000000000100000
    ^ 16r00000000000100000

    "Modified: / 4.6.1999 / 15:29:31 / cg"
    "Created: / 4.6.1999 / 15:34:36 / cg"
!

num_000000000007FFFFF
    ^ 16r000000000007FFFFF

    "Modified: / 4.6.1999 / 15:29:31 / cg"
    "Created: / 4.6.1999 / 15:37:48 / cg"
!

num_00000000000800000
    ^ 16r00000000000800000

    "Modified: / 4.6.1999 / 15:29:31 / cg"
    "Created: / 4.6.1999 / 15:39:43 / cg"
!

num_00000000000FFFFFF
    ^ 16r00000000000FFFFFF

    "Modified: / 4.6.1999 / 15:29:31 / cg"
    "Created: / 4.6.1999 / 15:37:52 / cg"
!

num_00000000001000000
    ^ 16r00000000001000000

    "Modified: / 4.6.1999 / 15:29:31 / cg"
    "Created: / 4.6.1999 / 15:34:42 / cg"
!

num_0000000000FFF0000
    ^ 16r0000000000FFF0000

    "self num_0000000000FFF0000 hexPrintString"

    "Created: / 4.6.1999 / 17:44:26 / cg"
    "Modified: / 4.6.1999 / 18:40:47 / cg"
!

num_00000000010000000
    ^ 16r00000000010000000

    "Modified: / 4.6.1999 / 15:29:31 / cg"
    "Created: / 4.6.1999 / 15:34:46 / cg"
!

num_0000000007FFFFFFF
    ^ 16r0000000007FFFFFFF

    "Modified: / 4.6.1999 / 15:29:31 / cg"
    "Created: / 4.6.1999 / 15:37:31 / cg"
!

num_00000000080000000
    ^ 16r00000000080000000

    "Modified: / 4.6.1999 / 15:29:31 / cg"
    "Created: / 4.6.1999 / 15:39:56 / cg"
!

num_000000000FFFFFFFF
    ^ 16r000000000FFFFFFFF

    "Modified: / 4.6.1999 / 15:29:31 / cg"
    "Created: / 4.6.1999 / 15:36:16 / cg"
!

num_00000000100000000
    ^ 16r00000000100000000

    "Modified: / 4.6.1999 / 15:29:31 / cg"
    "Created: / 4.6.1999 / 15:34:51 / cg"
!

num_00000001000000000
    ^ 16r00000001000000000

    "Modified: / 4.6.1999 / 15:29:31 / cg"
    "Created: / 4.6.1999 / 15:34:57 / cg"
!

num_0000000FFFFFFFFFF
    ^ 16r0000000FFFFFFFFFF

    "Modified: / 4.6.1999 / 15:29:31 / cg"
    "Created: / 4.6.1999 / 17:41:08 / cg"
!

num_00000010000000000
    ^ 16r00000010000000000

    "Modified: / 4.6.1999 / 15:29:31 / cg"
    "Created: / 4.6.1999 / 15:35:03 / cg"
!

num_00000100000000000
    ^ 16r00000100000000000

    "Modified: / 4.6.1999 / 15:29:31 / cg"
    "Created: / 4.6.1999 / 15:35:07 / cg"
!

num_00000FFFFFFFFFF00
    ^ 16r00000FFFFFFFFFF00

    "self num_00000FFFFFFFFFF00"

    "Created: / 4.6.1999 / 17:44:26 / cg"
    "Modified: / 4.6.1999 / 17:46:20 / cg"
!

num_00000FFFFFFFFFF80
    ^ 16r00000FFFFFFFFFF80

    "Modified: / 4.6.1999 / 15:29:31 / cg"
    "Created: / 4.6.1999 / 17:44:23 / cg"
!

num_00000FFFFFFFFFFC0
    ^ 16r00000FFFFFFFFFFC0

    "Modified: / 4.6.1999 / 15:29:31 / cg"
    "Created: / 4.6.1999 / 17:44:20 / cg"
!

num_00000FFFFFFFFFFE0
    ^ 16r00000FFFFFFFFFFE0

    "Modified: / 4.6.1999 / 15:29:31 / cg"
    "Created: / 4.6.1999 / 17:44:16 / cg"
!

num_00000FFFFFFFFFFF0
    ^ 16r00000FFFFFFFFFFF0

    "Modified: / 4.6.1999 / 15:29:31 / cg"
    "Created: / 4.6.1999 / 17:44:12 / cg"
!

num_00000FFFFFFFFFFF8
    ^ 16r00000FFFFFFFFFFF8

    "Modified: / 4.6.1999 / 15:29:31 / cg"
    "Created: / 4.6.1999 / 17:44:09 / cg"
!

num_00000FFFFFFFFFFFC
    ^ 16r00000FFFFFFFFFFFC

    "Modified: / 4.6.1999 / 15:29:31 / cg"
    "Created: / 4.6.1999 / 17:44:05 / cg"
!

num_00000FFFFFFFFFFFE
    ^ 16r00000FFFFFFFFFFFE

    "Modified: / 4.6.1999 / 15:29:31 / cg"
    "Created: / 4.6.1999 / 17:45:12 / cg"
!

num_00000FFFFFFFFFFFF
    ^ 16r00000FFFFFFFFFFFF

    "Modified: / 4.6.1999 / 15:29:31 / cg"
    "Created: / 4.6.1999 / 17:41:22 / cg"
!

num_00001000000000000
    ^ 16r00001000000000000

    "Modified: / 4.6.1999 / 15:29:31 / cg"
    "Created: / 4.6.1999 / 15:35:13 / cg"
!

num_00010000000000000
    ^ 16r00010000000000000

    "Modified: / 4.6.1999 / 15:29:31 / cg"
    "Created: / 4.6.1999 / 15:35:18 / cg"
!

num_000FFFFFFFFFFFFFF
    ^ 16r000FFFFFFFFFFFFFF

    "Modified: / 4.6.1999 / 15:29:31 / cg"
    "Created: / 4.6.1999 / 17:41:26 / cg"
!

num_00100000000000000
    ^ 16r00100000000000000

    "Modified: / 4.6.1999 / 15:29:31 / cg"
    "Created: / 4.6.1999 / 15:35:22 / cg"
!

num_01000000000000000
    ^ 16r01000000000000000

    "Modified: / 4.6.1999 / 15:29:31 / cg"
    "Created: / 4.6.1999 / 15:35:27 / cg"
!

num_0FFFFFFFFFFFFFFFF
    ^ 16r0FFFFFFFFFFFFFFFF

    "Modified: / 4.6.1999 / 15:29:31 / cg"
    "Created: / 4.6.1999 / 17:41:30 / cg"
!

num_10000000000000000
    ^ 16r10000000000000000

    "Modified: / 4.6.1999 / 15:29:31 / cg"
    "Created: / 4.6.1999 / 15:35:32 / cg"
!

num_16r80000000
    ^ 16r80000000
!

num_1FFFFFFFFFFFFFFFF
    ^ 16r1FFFFFFFFFFFFFFFF

    "Modified: / 4.6.1999 / 15:29:31 / cg"
    "Created: / 4.6.1999 / 17:41:51 / cg"
!

num_20000000000000000
    ^ 16r20000000000000000

    "Modified: / 4.6.1999 / 15:29:31 / cg"
    "Created: / 4.6.1999 / 17:40:26 / cg"
!

num_3FFFFFFFFFFFFFFFF
    ^ 16r3FFFFFFFFFFFFFFFF

    "Modified: / 4.6.1999 / 15:29:31 / cg"
    "Created: / 4.6.1999 / 17:42:07 / cg"
!

num_40000000000000000
    ^ 16r40000000000000000

    "Modified: / 4.6.1999 / 15:29:31 / cg"
    "Created: / 4.6.1999 / 17:40:29 / cg"
!

num_7FFFFFFFFFFFFFFFF
    ^ 16r7FFFFFFFFFFFFFFFF

    "Modified: / 4.6.1999 / 15:29:31 / cg"
    "Created: / 4.6.1999 / 17:42:24 / cg"
!

num_80000000000000000
    ^ 16r80000000000000000

    "Modified: / 4.6.1999 / 15:29:31 / cg"
    "Created: / 4.6.1999 / 17:40:33 / cg"
!

num_smallInt_maxVal
    ^ SmallInteger maxVal

    "self num_smallInt_maxVal"

    "Modified: / 4.6.1999 / 17:33:22 / cg"
!

num_smallInt_minVal
    ^ SmallInteger minVal

    "self num_smallInt_minVal"

    "Created: / 4.6.1999 / 16:26:05 / cg"
    "Modified: / 4.6.1999 / 17:34:31 / cg"
! !

!IntegerTest methodsFor:'tests'!

doCompare:a againstEqual:b
    self assert:(a < b) not.
    self assert:(a <= b).
    self assert:(a = b).
    self assert:(a ~= b) not.
    self assert:(a > b) not.
    self assert:(a >= b).

    self assert:(a perform:#<   with:b) not.
    self assert:(a perform:#<=  with:b).
    self assert:(a perform:#=   with:b).
    self assert:(a perform:#~=  with:b) not.
    self assert:(a perform:#>   with:b) not.
    self assert:(a perform:#>=  with:b).

    "
     self basicNew doCompare:12 againstEqual:12
    "
!

doCompare:a againstGreater:b
    self assert:(a < b).
    self assert:(a <= b).
    self assert:(a = b) not.
    self assert:(a ~= b).
    self assert:(a == b) not.
    self assert:(a ~~ b).
    self assert:(a > b) not.
    self assert:(a >= b) not.

    self assert:(a perform:#<   with:b).
    self assert:(a perform:#<=  with:b).
    self assert:(a perform:#=   with:b) not.
    self assert:(a perform:#~=  with:b).
    self assert:(a perform:#==  with:b) not.
    self assert:(a perform:#~~  with:b).
    self assert:(a perform:#>   with:b) not.
    self assert:(a perform:#>=  with:b) not.

    "
     self basicNew doCompare:12 againstGreater:16r80000000
    "
!

doTestAll
    "general conversion & arithmetic 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."

    self testInteger1.
    self testILC.
    self testSmallIntegerArithmetic.
    self testLiteralNumbers.
    self testLargeAddition.
    self testLargeMultiplication.
    self testLargeDivision.
    self testLargeBitOperations.
    self testIntegerShifts.
    self testEncodeDecode.
    self testIntegerMisc.
    self testInline1

    "
     self basicNew doTestAll
    "

    "Modified: / 31.10.2000 / 20:23:20 / cg"
!

testComparing
    |a b|

    a := 12.
    b := 16r80000000.
    self doCompare:a againstGreater:b.

    a := 12.
    b := 16r80000000.
    self doCompare:a againstGreater:16r80000000.

    a := 0.
    self doCompare:a againstGreater:16r80000000.

    a := -1.
    self doCompare:a againstGreater:16r80000000.

    a := 16r-80000000.
    self doCompare:a againstGreater:16r80000000.

    a := 16r-40000000.
    self doCompare:a againstGreater:16r80000000.

    a := 16r-40000000.
    self doCompare:a againstGreater:16r40000000.

    a := 16r-3FFFFFFF.
    self doCompare:a againstGreater:16r3FFFFFFF.

    a := 16r-40000000.
    self doCompare:a againstGreater:16r3FFFFFFF.

    a := 16r-3FFFFFFF.
    self doCompare:a againstGreater:16r40000000.

    "/ smallint-largeInt boundaries

    a := 16r3FFFFFFE.
    self doCompare:a againstEqual:16r3FFFFFFE.

    a := 16r3FFFFFFE.
    self doCompare:a againstGreater:16r3FFFFFFF.

    a := 16r3FFFFFFE.
    self doCompare:a againstGreater:16r40000000.

    a := 16r3FFFFFFE.
    self doCompare:a againstGreater:16r80000000.

    a := 16r3FFFFFFE.
    self doCompare:a againstGreater:16rFFFFFFFF.

    a := 16r3FFFFFFF.
    self doCompare:a againstEqual:16r3FFFFFFF.

    a := 16r3FFFFFFF.
    self doCompare:a againstGreater:16r40000000.

    a := 16r3FFFFFFF.
    self doCompare:a againstGreater:16r80000000.

    a := 16r3FFFFFFF.
    self doCompare:a againstGreater:16rFFFFFFFF.

    a := 16r40000000.
    self doCompare:a againstEqual:16r40000000.

    a := 16r40000000.
    self doCompare:a againstGreater:16r80000000.

    a := 16r40000000.
    self doCompare:a againstGreater:16rFFFFFFFF.

    a := 16r7FFFFFFF.
    self doCompare:a againstEqual:16r7FFFFFFF.

    a := 16r7FFFFFFF.
    self doCompare:a againstGreater:16r80000000.

    a := 16r7FFFFFFF.
    self doCompare:a againstGreater:16rFFFFFFFF.

    a := 16r80000000.
    self doCompare:a againstEqual:16r80000000.

    a := 16r80000000.
    self doCompare:a againstGreater:16rFFFFFFFF.

    a := 16rFFFFFFFF.
    self doCompare:a againstEqual:16rFFFFFFFF.

    a := 16rFFFFFFFF.
    self doCompare:a againstGreater:16r100000000.

    "
     self basicNew testComparing
    "
!

testConstants
    |t|

    self assert:((t := self num_16r80000000) > 0).
    self assert:((t := self num_16r80000000) = 16r80000000).

    "
     self basicNew testConstants
    "
!

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).

    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).

    a := -16.
    b := 8.
    self assert:(-16 // 8 == -2).
    self assert:(a // 8 == -2).
    self assert:(-16 // b == -2).
    self assert:(a // b == -2).

    self assert:((rslt := -16 perform:op with: 8) == -2).
    self assert:((rslt := a perform:op with: 8) == -2).
    self assert:((rslt := -16 perform:op with: b) == -2).
    self assert:((rslt := a perform:op with: b) == -2).

    a := 16.
    b := -8.
    self assert:(16 // -8 == -2).
    self assert:(a // -8 == -2).
    self assert:(16 // b == -2).
    self assert:(a // b == -2).

    self assert:((rslt := 16 perform:op with: -8) == -2).
    self assert:((rslt := a perform:op with: -8) == -2).
    self assert:((rslt := 16 perform:op with: b) == -2).
    self assert:((rslt := a perform:op with: b) == -2).

    a := -16.
    b := -8.
    self assert:(-16 // -8 == 2).
    self assert:(a // -8 == 2).
    self assert:(-16 // b == 2).
    self assert:(a // b == 2).

    self assert:((rslt := -16 perform:op with: -8) == 2).
    self assert:((rslt := a perform:op with: -8) == 2).
    self assert:((rslt := -16 perform:op with: b) == 2).
    self assert:((rslt := a perform:op with: b) == 2).

    a := 16.
    b := 8.
    self assert:(16 // 8 == 2).
    self assert:(a // 8 == 2).
    self assert:(16 // b == 2).
    self assert:(a // b == 2).

    self assert:((rslt := 16 perform:op with: 8) == 2).
    self assert:((rslt := a perform:op with: 8) == 2).
    self assert:((rslt := 16 perform:op with: b) == 2).
    self assert:((rslt := a perform:op with: b) == 2).

    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).

    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 := -16.
    b := 8.
    self assert:((rslt := -16 quo: 8) == -2).
    self assert:((rslt := a quo: 8) == -2).
    self assert:((rslt := -16 quo: b) == -2).
    self assert:((rslt := a quo: b) == -2).

    self assert:((rslt := -16 perform:op with: 8) == -2).
    self assert:((rslt := a perform:op with: 8) == -2).
    self assert:((rslt := -16 perform:op with: b) == -2).
    self assert:((rslt := a perform:op with: b) == -2).

    a := 16.
    b := -8.
    self assert:((rslt := 16 quo: -8) == -2).
    self assert:((rslt := a quo: -8) == -2).
    self assert:((rslt := 16 quo: b) == -2).
    self assert:((rslt := a quo: b) == -2).

    self assert:((rslt := 16 perform:op with: -8) == -2).
    self assert:((rslt := a perform:op with: -8) == -2).
    self assert:((rslt := 16 perform:op with: b) == -2).
    self assert:((rslt := a perform:op with: b) == -2).

    a := -16.
    b := -8.
    self assert:((rslt := -16 quo: -8) == 2).
    self assert:((rslt := a quo: -8) == 2).
    self assert:((rslt := -16 quo: b) == 2).
    self assert:((rslt := a quo: b) == 2).

    self assert:((rslt := -16 perform:op with: -8) == 2).
    self assert:((rslt := a perform:op with: -8) == 2).
    self assert:((rslt := -16 perform:op with: b) == 2).
    self assert:((rslt := a perform:op with: b) == 2).

    a := 16.
    b := 8.
    self assert:((rslt := 16 quo: 8) == 2).
    self assert:((rslt := a quo: 8) == 2).
    self assert:((rslt := 16 quo: b) == 2).
    self assert:((rslt := a quo: b) == 2).

    self assert:((rslt := 16 perform:op with: 8) == 2).
    self assert:((rslt := a perform:op with: 8) == 2).
    self assert:((rslt := 16 perform:op with: b) == 2).
    self assert:((rslt := a perform:op with: b) == 2).

    "
     self basicNew testDivision
    "
!

testEncodeDecode
    self assert:(1 encodeAsBCD hexPrintString = '1').
    self assert:(12 encodeAsBCD hexPrintString = '12').
    self assert:(123 encodeAsBCD hexPrintString = '123').
    self assert:(1234 encodeAsBCD hexPrintString = '1234').
    self assert:(12345 encodeAsBCD hexPrintString = '12345').
    self assert:(123456 encodeAsBCD hexPrintString = '123456').
    self assert:(1234567 encodeAsBCD hexPrintString = '1234567').
    self assert:(12345678 encodeAsBCD hexPrintString = '12345678').
    self assert:(123456789 encodeAsBCD hexPrintString = '123456789').
    self assert:(1234567890 encodeAsBCD hexPrintString = '1234567890').
    self assert:(12345678901 encodeAsBCD hexPrintString = '12345678901').
    self assert:(123456789012 encodeAsBCD hexPrintString = '123456789012').
    self assert:(1234567890123 encodeAsBCD hexPrintString = '1234567890123').
    self assert:(12345678901234 encodeAsBCD hexPrintString = '12345678901234').
    self assert:(123456789012345 encodeAsBCD hexPrintString = '123456789012345').
    self assert:(1234567890123456 encodeAsBCD hexPrintString = '1234567890123456').
    self assert:(12345678901234567 encodeAsBCD hexPrintString = '12345678901234567').
    self assert:(123456789012345678 encodeAsBCD hexPrintString = '123456789012345678').
    self assert:(1234567890123456789 encodeAsBCD hexPrintString = '1234567890123456789').
    self assert:(12345678901234567890 encodeAsBCD hexPrintString = '12345678901234567890').
    self assert:(4611686018427387902 encodeAsBCD hexPrintString = '4611686018427387902').
    self assert:(4611686018427387903 encodeAsBCD hexPrintString = '4611686018427387903').
    self assert:(4611686018427387904 encodeAsBCD hexPrintString = '4611686018427387904').

    self assert:(16r1 decodeFromBCD = 1).
    self assert:(16r12 decodeFromBCD = 12).
    self assert:(16r123 decodeFromBCD = 123).
    self assert:(16r1234 decodeFromBCD = 1234).
    self assert:(16r12345 decodeFromBCD = 12345).
    self assert:(16r123456 decodeFromBCD = 123456).
    self assert:(16r1234567 decodeFromBCD = 1234567).
    self assert:(16r12345678 decodeFromBCD = 12345678).
    self assert:(16r123456789 decodeFromBCD = 123456789).
    self assert:(16r1234567890 decodeFromBCD = 1234567890).
    self assert:(16r12345678901 decodeFromBCD = 12345678901).
    self assert:(16r123456789012 decodeFromBCD = 123456789012).
    self assert:(16r1000000000000 decodeFromBCD = 1000000000000).
    self assert:(16r0000500000000 decodeFromBCD = 500000000).
    self assert:(16r1234500000000 decodeFromBCD = 1234500000000).
    self assert:(16r1234567890000 decodeFromBCD = 1234567890000).

    self assert:(16r1234567890123 decodeFromBCD = 1234567890123).
    self assert:(16r12345678901234 decodeFromBCD = 12345678901234).
    self assert:(16r123456789012345 decodeFromBCD = 123456789012345).
    self assert:(16r1234567890123456 decodeFromBCD = 1234567890123456).
    self assert:(16r12345678901234567 decodeFromBCD = 12345678901234567).
    self assert:(16r123456789012345678 decodeFromBCD = 123456789012345678).
    self assert:(16r1234567890123456789 decodeFromBCD = 1234567890123456789).
    self assert:(16r12345678901234567890 decodeFromBCD = 12345678901234567890).
    self assert:(16r4611686018427387902 decodeFromBCD = 4611686018427387902).
    self assert:(16r4611686018427387903 decodeFromBCD = 4611686018427387903).
    self assert:(16r4611686018427387904 decodeFromBCD = 4611686018427387904).

    "
     self basicNew testEncodeDecode
    "

    "Modified: / 26.10.1999 / 22:01:35 / stefan"
!

testILC
    "inline-cache"

    self assert:((self checkIsInteger:1) == true).
    self assert:((self checkIsInteger:nil) == false).
    self assert:((self checkIsInteger:1) == true).
    self assert:((self checkIsInteger:nil) == false).

    self assert:((self checkIsInteger:0) == true).
    self assert:((self checkIsInteger:nil) == false).
    self assert:((self checkIsInteger:0) == true).
    self assert:((self checkIsInteger:nil) == false).

    "
     self basicNew testILC
    "

    "Created: / 6.6.1999 / 14:47:51 / cg"
    "Modified: / 9.6.1999 / 17:49:57 / cg"
!

testInline1
    "inlined 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."

    self assert:( (self absPlusOneOf:1) = 2 ).
    self assert:( (self absPlusOneOf:-1) = 2 ).
    self assert:( (self absPlusOneOf:1.0) = 2 ).
    self assert:( (self absPlusOneOf:-1.0) = 2 ).

    "
     self basicNew testInline1
    "

    "Created: / 31.10.2000 / 20:22:48 / cg"
    "Modified: / 31.10.2000 / 20:23:06 / cg"
!

testInteger1
    "general conversion & arithmetic 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."

    |minVal maxVal maxValPlus1 minValMinus1 halfMin halfMax t t1 t2|

    minVal := SmallInteger perform:('minVal' asSymbol).
    maxVal := SmallInteger perform:('maxVal' asSymbol).

    self assert:(minVal == self num_smallInt_minVal).
    self assert:(maxVal == self num_smallInt_maxVal).

    self assert:(minVal == SmallInteger minVal).
    self assert:(maxVal == SmallInteger maxVal).

    t := SmallInteger perform:('maxBytes' asSymbol).
    self assert:(t == SmallInteger maxBytes).
    t := SmallInteger perform:('maxBits' asSymbol).
    self assert:(t == SmallInteger maxBits).

    self testPrinting1.

    SmallInteger maxBytes == 4 ifTrue:[
        self assert:(minVal hexPrintString = '-40000000').
        self assert:(maxVal hexPrintString = '3FFFFFFF').
        self assert:(minVal == -1073741824).
        self assert:(maxVal == 1073741823).
        maxValPlus1 := 1073741824.
        minValMinus1 := -1073741825.
        self assert:(minValMinus1 hexPrintString = '-40000001').
        self assert:(maxValPlus1 hexPrintString = '40000000').
        halfMin := -16r20000000.
        halfMax := 16r20000000.
    ].
    SmallInteger maxBytes == 8 ifTrue:[
        self assert:(minVal hexPrintString = '-4000000000000000').
        self assert:(maxVal hexPrintString = '3FFFFFFFFFFFFFFF').
        self assert:(minVal == -4611686018427387904).
        self assert:(maxVal == 4611686018427387903).
        maxValPlus1 := 4611686018427387904.
        minValMinus1 := -4611686018427387905.
        self assert:(minValMinus1 hexPrintString = '-4000000000000001').
        self assert:(maxValPlus1 hexPrintString = '4000000000000000').
        halfMin := -16r2000000000000000.
        halfMax := 16r2000000000000000.
    ].

    "arithmetic overFlow checks"

"/    self assert:((maxVal + 1) inspect.maxValPlus1 inspect. true).
    self assert:((maxVal perform:'+' asSymbol with:1) = maxValPlus1).
    self assert:((maxVal + 1) = maxValPlus1).
    self assert:((minVal perform:'-' asSymbol with:1) = minValMinus1).
    self assert:((minVal - 1) = minValMinus1).

    self assert:((halfMax perform:'+' asSymbol with:halfMax) = maxValPlus1).
    self assert:((halfMax + halfMax) = maxValPlus1).
    self assert:((halfMin perform:'+' asSymbol with:halfMin) == minVal).
    self assert:((halfMin + halfMin) == minVal).
    self assert:((halfMax perform:'*' asSymbol with:2) = maxValPlus1).
    self assert:((halfMax * 2) = maxValPlus1).
    self assert:((halfMin perform:'*' asSymbol with:2) == minVal).
    self assert:((halfMin * 2) == minVal).
    self assert:((maxValPlus1 perform:'//' asSymbol with:2) == halfMax).
    self assert:((maxValPlus1 // 2) == halfMax).
    self assert:((halfMax perform:'bitShift:' asSymbol with:1) = maxValPlus1).
    self assert:((halfMin perform:'bitShift:' asSymbol with:1) == minVal).
    self assert:((halfMax bitShift:1) = maxValPlus1).
    self assert:((halfMin bitShift:1) == minVal).

    "LargeInt op -> SmallInt result"
    t := maxVal + 1.
    self assert:(t - 1 == maxVal).
    t := minVal - 1.
    self assert:(t + 1 == minVal).

    "
     self basicNew testInteger1
    "

    "Modified: / 6.6.1999 / 14:46:11 / cg"
!

testIntegerMisc
    "misc 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."

    |n1 n2 s|

    n1 := 100000.
    n2 := n1 negated.
    s := 1.

    self assert:(n1 printString = '100000').

    self assert:(n1 negated printString = '-100000').
    self assert:((n1 perform:'negated' asSymbol) printString = '-100000').

    self assert:(n1 negated abs printString = '100000').
    self assert:((n1 perform:'negated' asSymbol) abs printString = '100000').

    self assert:(n1 abs negated printString = '-100000').
    self assert:((n1 perform:'abs' asSymbol) negated printString = '-100000').

    n1 := SmallInteger maxVal.
    self assert:(n1 negated class == SmallInteger).
    self assert:((n1 perform:'negated' asSymbol) class == SmallInteger).

    n1 := SmallInteger minVal.
    self assert:(n1 negated class == LargeInteger).
    self assert:((n1 perform:'negated' asSymbol) class == LargeInteger).

    n1 := SmallInteger minVal negated - 1.
    self assert:(n1 negated class == SmallInteger).
    self assert:((n1 perform:'negated' asSymbol) class == SmallInteger).
    self assert:(n1 == SmallInteger maxVal).

    "
     self basicNew testIntegerMisc
    "

    "Created: / 6.6.1999 / 14:47:51 / cg"
    "Modified: / 9.6.1999 / 17:49:57 / cg"
!

testIntegerMisc2
    "misc 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."

    |n sel|

    "/ fib is optional
    (0 respondsTo:#fib) ifFalse:[^ self].

    self assert:(0 fib == 0).
    self assert:(1 fib == 1).
    self assert:(2 fib == 1).
    self assert:(3 fib == 2).
    self assert:(4 fib == 3).
    self assert:(5 fib == 5).
    self assert:(6 fib == 8).
    self assert:(7 fib == 13).

    n := 0.
    self assert:(n fib == 0).
    n := 1.
    self assert:(n fib == 1).
    n := 2.
    self assert:(n fib == 1).
    n := 3.
    self assert:(n fib == 2).
    n := 4.
    self assert:(n fib == 3).
    n := 5.
    self assert:(n fib == 5).
    n := 6.
    self assert:(n fib == 8).
    n := 7.
    self assert:(n fib == 13).

    #(0 1 2 3 4 5 6 7) 
    with:#(0 1 1 2 3 5 8 13)
    do:[:n :rslt |
        self assert:(n fib == rslt).
    ].

"/    #(0 1 2 3 4 5 6 7) 
"/    with:#(0 1 1 2 3 5 8 13)
"/    do:[:n :rslt |
"/        self assert:(n fib_recursive == rslt).
"/    ].

    sel := #fib.
    self assert:((0 perform:sel) == 0).
    self assert:((1 perform:sel) == 1).
    self assert:((2 perform:sel) == 1).
    self assert:((3 perform:sel) == 2).
    self assert:((4 perform:sel) == 3).
    self assert:((5 perform:sel) == 5).
    self assert:((6 perform:sel) == 8).
    self assert:((7 perform:sel) == 13).

    "
     self basicNew testIntegerMisc2
    "
!

testIntegerShifts
    "arithmetic 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."

    self testIntegerShifts1.
    self testIntegerShifts2.

    self assert:(
     (((0 to:64) collect:[:s | 1 bitShift:s])
        collect:[:n | n highBit]) = (1 to:65)
    ).

    1 to:10000 do:[:s |
        self assert:( (1 bitShift:s) highBit == (s+1) )
    ].
    1 to:10000 do:[:s |
        self assert:( ((1 bitShift:s) - 1) highBit == s )
    ].

    "
     self basicNew testIntegerShifts
    "

    "Created: / 6.6.1999 / 14:47:51 / cg"
    "Modified: / 9.6.1999 / 17:49:57 / cg"
!

testIntegerShifts1
    "arithmetic 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."

    |n1 n2 s|

    n1 := 100000.
    n2 := n1 negated.
    s := 1.

    self assert:(n1 printString = '100000').
    self assert:(n2 printString = '-100000').

    self assert:((n1 bitShift:s) printString = '200000').
    self assert:((n1 bitShift:1) printString = '200000').
    self assert:((n1 perform:'bitShift:' asSymbol with:s) printString = '200000').
    self assert:((n1 perform:'bitShift:' asSymbol with:1) printString = '200000').

    s := s + 1.
    self assert:((n1 bitShift:s) printString = '400000').
    self assert:((n1 bitShift:2) printString = '400000').
    self assert:((n1 perform:'bitShift:' asSymbol with:s) printString = '400000').
    self assert:((n1 perform:'bitShift:' asSymbol with:2) printString = '400000').

    s := s + 1.
    self assert:((n1 bitShift:s) printString = '800000').
    self assert:((n1 bitShift:3) printString = '800000').
    self assert:((n1 perform:'bitShift:' asSymbol with:s) printString = '800000').
    self assert:((n1 perform:'bitShift:' asSymbol with:3) printString = '800000').

    s := s + 1.
    self assert:((n1 bitShift:s) printString = '1600000').
    self assert:((n1 bitShift:4) printString = '1600000').
    self assert:((n1 perform:'bitShift:' asSymbol with:s) printString = '1600000').
    self assert:((n1 perform:'bitShift:' asSymbol with:4) printString = '1600000').

    s := s + 1.
    self assert:((n1 bitShift:s) printString = '3200000').
    self assert:((n1 bitShift:5) printString = '3200000').
    self assert:((n1 perform:'bitShift:' asSymbol with:s) printString = '3200000').
    self assert:((n1 perform:'bitShift:' asSymbol with:5) printString = '3200000').

    s := s + 1.
    self assert:((n1 bitShift:s) printString = '6400000').
    self assert:((n1 bitShift:6) printString = '6400000').
    self assert:((n1 perform:'bitShift:' asSymbol with:s) printString = '6400000').
    self assert:((n1 perform:'bitShift:' asSymbol with:6) printString = '6400000').

    s := s + 1.
    self assert:((n1 bitShift:s) printString = '12800000').
    self assert:((n1 bitShift:7) printString = '12800000').
    self assert:((n1 perform:'bitShift:' asSymbol with:s) printString = '12800000').
    self assert:((n1 perform:'bitShift:' asSymbol with:7) printString = '12800000').

    "
     self basicNew testIntegerShifts1
    "

    "Created: / 6.6.1999 / 14:47:51 / cg"
    "Modified: / 9.6.1999 / 17:49:57 / cg"
!

testIntegerShifts2
    "arithmetic 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."

    |n1 s|

    n1 := 12800000.
    s := -1.
    self assert:((n1 bitShift:s) printString = '6400000').
    self assert:((n1 bitShift:-1) printString = '6400000').
    self assert:((n1 perform:'bitShift:' asSymbol with:s) printString = '6400000').
    self assert:((n1 perform:'bitShift:' asSymbol with:-1) printString = '6400000').

    s := s - 1.
    self assert:((n1 bitShift:s) printString = '3200000').
    self assert:((n1 bitShift:-2) printString = '3200000').
    self assert:((n1 perform:'bitShift:' asSymbol with:s) printString = '3200000').
    self assert:((n1 perform:'bitShift:' asSymbol with:-2) printString = '3200000').

    s := s - 1.
    self assert:((n1 bitShift:s) printString = '1600000').
    self assert:((n1 bitShift:-3) printString = '1600000').
    self assert:((n1 perform:'bitShift:' asSymbol with:s) printString = '1600000').
    self assert:((n1 perform:'bitShift:' asSymbol with:-3) printString = '1600000').

    s := s - 1.
    self assert:((n1 bitShift:s) printString = '800000').
    self assert:((n1 bitShift:-4) printString = '800000').
    self assert:((n1 perform:'bitShift:' asSymbol with:s) printString = '800000').
    self assert:((n1 perform:'bitShift:' asSymbol with:-4) printString = '800000').

    s := s - 1.
    self assert:((n1 bitShift:s) printString = '400000').
    self assert:((n1 bitShift:-5) printString = '400000').
    self assert:((n1 perform:'bitShift:' asSymbol with:s) printString = '400000').
    self assert:((n1 perform:'bitShift:' asSymbol with:-5) printString = '400000').

    s := s - 1.
    self assert:((n1 bitShift:s) printString = '200000').
    self assert:((n1 bitShift:-6) printString = '200000').
    self assert:((n1 perform:'bitShift:' asSymbol with:s) printString = '200000').
    self assert:((n1 perform:'bitShift:' asSymbol with:-6) printString = '200000').

    s := s - 1.
    self assert:((n1 bitShift:s) printString = '100000').
    self assert:((n1 bitShift:-7) printString = '100000').
    self assert:((n1 perform:'bitShift:' asSymbol with:s) printString = '100000').
    self assert:((n1 perform:'bitShift:' asSymbol with:-7) printString = '100000').

    s := s - 1.
    self assert:((n1 bitShift:s) printString = '50000').
    self assert:((n1 bitShift:-8) printString = '50000').
    self assert:((n1 perform:'bitShift:' asSymbol with:s) printString = '50000').
    self assert:((n1 perform:'bitShift:' asSymbol with:-8) printString = '50000').

    s := s - 1.
    self assert:((n1 bitShift:s) printString = '25000').
    self assert:((n1 bitShift:-9) printString = '25000').
    self assert:((n1 perform:'bitShift:' asSymbol with:s) printString = '25000').
    self assert:((n1 perform:'bitShift:' asSymbol with:-9) printString = '25000').

    s := s - 1.
    self assert:((n1 bitShift:s) printString = '12500').
    self assert:((n1 bitShift:-10) printString = '12500').
    self assert:((n1 perform:'bitShift:' asSymbol with:s) printString = '12500').
    self assert:((n1 perform:'bitShift:' asSymbol with:-10) printString = '12500').

    s := s - 1.
    self assert:((n1 bitShift:s) printString = '6250').
    self assert:((n1 bitShift:-11) printString = '6250').
    self assert:((n1 perform:'bitShift:' asSymbol with:s) printString = '6250').
    self assert:((n1 perform:'bitShift:' asSymbol with:-11) printString = '6250').

    "
     self basicNew testIntegerShifts2
    "

    "Created: / 6.6.1999 / 14:47:51 / cg"
    "Modified: / 9.6.1999 / 17:49:57 / cg"
!

testIntegerShifts3
    "arithmetic 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."

    self assert:( self doConstantIntegerShift == 1).

    "
     self basicNew testIntegerShifts3
    "
!

testIntegerShifts4
    "arithmetic 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."

    |a|

    a := 16r1234.

    self assert:( ((a bitShift:-4) bitAnd:16rFF) == 16r23 ).
    self assert:( ((a bitShift:-8) bitAnd:16rFF) == 16r12 ).
    self assert:( ((a bitShift:-12) bitAnd:16rFF) == 16r1 ).
    self assert:( ((a bitShift:-16) bitAnd:16rFF) == 0 ).

    "/ should not shift in any sign bits ...
    a := 16r1FFFFFFF.
    self assert:( (a bitShift:-4) == 16r1FFFFFF ).
    a := 16r3FFFFFFF.
    self assert:( (a bitShift:-4) == 16r3FFFFFF ).
    a := 16r7FFFFFFF.
    self assert:( (a bitShift:-4) == 16r7FFFFFF ).
    a := 16rFFFFFFFF.
    self assert:( (a bitShift:-4) == 16rFFFFFFF ).
    a := 16r1FFFFFFFF.
    self assert:( (a bitShift:-4) == 16r1FFFFFFF ).

    a := 16r1FFFFFFF.
    self assert:( (a bitShift:-8) == 16r1FFFFF ).
    a := 16r3FFFFFFF.
    self assert:( (a bitShift:-8) == 16r3FFFFF ).
    a := 16r7FFFFFFF.
    self assert:( (a bitShift:-8) == 16r7FFFFF ).
    a := 16rFFFFFFFF.
    self assert:( (a bitShift:-8) == 16rFFFFFF ).
    a := 16r1FFFFFFFF.
    self assert:( (a bitShift:-8) == 16r1FFFFFF ).

    "
     self basicNew testIntegerShifts4
    "
!

testLargeAddition
    "general conversion & arithmetic 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 x|

    "Large + Large addition"
    self testReading1.

    self assert:((20 factorial + 20 factorial) printString = '4865804016353280000').
    self assert:((20 factorial + 1) printString = '2432902008176640001').
    self assert:((20 factorial + 1000) printString = '2432902008176641000').

    "Large + Small addition"

    self testLargeAddition1.

    "Large + Large addition"

    self testLargeAddition2.

    "Large - small subtraction"

    self testLargeAddition3.

    "
     self basicNew testLargeAddition
    "

    "Modified: / 4.6.1999 / 15:26:55 / cg"
!

testLargeAddition1
    "general conversion & arithmetic 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 x|

    "Large + Small addition"

    n1 := 16r3FFFFFFF. n2 := 1.
    self assert:((n1 + n2 ) hexPrintString = '40000000').
    self assert:((n1 perform:'+' asSymbol with:n2 ) hexPrintString = '40000000').
    n1 := 16r3FFFFFFFF. n2 := 1.
    self assert:((n1 + n2 ) hexPrintString = '400000000').
    self assert:((n1 perform:'+' asSymbol with:n2 ) hexPrintString = '400000000').
    n1 := 16r3FFFFFFFFF. n2 := 1.
    self assert:((n1 + n2 ) hexPrintString = '4000000000').
    self assert:((n1 perform:'+' asSymbol with:n2 ) hexPrintString = '4000000000').
    n1 := 16r3FFFFFFFFFF. n2 := 1.
    self assert:((n1 + n2 ) hexPrintString = '40000000000').
    self assert:((n1 perform:'+' asSymbol with:n2 ) hexPrintString = '40000000000').
    n1 := 16r3FFFFFFFFFFF. n2 := 1.
    self assert:((n1 + n2 ) hexPrintString = '400000000000').
    self assert:((n1 perform:'+' asSymbol with:n2 ) hexPrintString = '400000000000').
    n1 := 16r3FFFFFFFFFFFF. n2 := 1.
    self assert:((n1 + n2 ) hexPrintString = '4000000000000').
    self assert:((n1 perform:'+' asSymbol with:n2 ) hexPrintString = '4000000000000').
    n1 := 16r3FFFFFFFFFFFFF. n2 := 1.
    self assert:((n1 + n2 ) hexPrintString = '40000000000000').
    self assert:((n1 perform:'+' asSymbol with:n2 ) hexPrintString = '40000000000000').
    n1 := 16r3FFFFFFFFFFFFFF. n2 := 1.
    self assert:((n1 + n2 ) hexPrintString = '400000000000000').
    self assert:((n1 perform:'+' asSymbol with:n2 ) hexPrintString = '400000000000000').
    n1 := 16r3FFFFFFFFFFFFFFF. n2 := 1.
    self assert:((n1 + n2 ) hexPrintString = '4000000000000000').
    self assert:((n1 perform:'+' asSymbol with:n2 ) hexPrintString = '4000000000000000').

    "
     self basicNew testLargeAddition1
    "

    "Modified: / 4.6.1999 / 15:26:55 / cg"
!

testLargeAddition2
    "general conversion & arithmetic 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 x|

    "Large + Large addition"

    n1 := 16r100000000. n2 := 16r7FFFFFFF.
    self assert:((n1 - n2 ) hexPrintString = '80000001').
    self assert:((16r100000000 - n2 ) hexPrintString = '80000001').
    self assert:((n1 - 16r7FFFFFFF ) hexPrintString = '80000001').
    self assert:((16r100000000 - 16r7FFFFFFF ) hexPrintString = '80000001').
    self assert:((n1 perform:'-' asSymbol with:n2 ) hexPrintString = '80000001').
    self assert:((16r100000000 perform:'-' asSymbol with:n2 ) hexPrintString = '80000001').
    self assert:((n1 perform:'-' asSymbol with:16r7FFFFFFF ) hexPrintString = '80000001').
    self assert:((16r100000000 perform:'-' asSymbol with:16r7FFFFFFF ) hexPrintString = '80000001').

    n1 := 16r100000000. n2 := 16r80000000.
    self assert:((n1 - n2 ) hexPrintString = '80000000').
    self assert:((16r100000000 - n2 ) hexPrintString = '80000000').
    self assert:((n1 - 16r80000000 ) hexPrintString = '80000000').
    self assert:((16r100000000 - 16r80000000 ) hexPrintString = '80000000').
    self assert:((n1 perform:'-' asSymbol with:n2 ) hexPrintString = '80000000').
    self assert:((16r100000000 perform:'-' asSymbol with:n2 ) hexPrintString = '80000000').
    self assert:((n1 perform:'-' asSymbol with:16r80000000 ) hexPrintString = '80000000').
    self assert:((16r100000000 perform:'-' asSymbol with:16r80000000 ) hexPrintString = '80000000').

    n1 := 16r100000000. n2 := 16rFFFFFFFF.
    self assert:((n1 - n2 ) hexPrintString = '1').
    self assert:((16r100000000 - n2 ) hexPrintString = '1').
    self assert:((x := n1 - 16rFFFFFFFF) == 1).

    self assert:((n1 - 16rFFFFFFFF ) hexPrintString = '1').
    self assert:((16r100000000 - 16rFFFFFFFF ) hexPrintString = '1').
    self assert:((n1 perform:'-' asSymbol with:n2 ) hexPrintString = '1').
    self assert:((16r100000000 perform:'-' asSymbol with:n2 ) hexPrintString = '1').
    self assert:((n1 perform:'-' asSymbol with:16rFFFFFFFF ) hexPrintString = '1').
    self assert:((16r100000000 perform:'-' asSymbol with:16rFFFFFFFF ) hexPrintString = '1').

    n1 := 16r100000000. n2 := 1.
    self assert:((n1 - n2) hexPrintString = 'FFFFFFFF').
    self assert:((n1 - n2) hexPrintString = 'FFFFFFFF').
    self assert:((16r100000000 - n2) hexPrintString = 'FFFFFFFF').
    self assert:((n1 - 1) hexPrintString = 'FFFFFFFF').
    self assert:((16r100000000 - 1) hexPrintString = 'FFFFFFFF').
    self assert:((n1 perform:'-' asSymbol with:n2) hexPrintString = 'FFFFFFFF').
    self assert:((16r100000000 perform:'-' asSymbol with:n2) hexPrintString = 'FFFFFFFF').
    self assert:((n1 perform:'-' asSymbol with:1) hexPrintString = 'FFFFFFFF').
    self assert:((16r100000000 perform:'-' asSymbol with:1) hexPrintString = 'FFFFFFFF').

    n1 := 16r100000000. n2 := 16r10000000.
    self assert:((n1 - n2) hexPrintString = 'F0000000').
    self assert:((16r100000000 - n2) hexPrintString = 'F0000000').
    self assert:((n1 - 16r10000000) hexPrintString = 'F0000000').
    self assert:((16r100000000 - 16r10000000) hexPrintString = 'F0000000').
    self assert:((n1 perform:'-' asSymbol with:n2) hexPrintString = 'F0000000').
    self assert:((16r100000000 perform:'-' asSymbol with:n2) hexPrintString = 'F0000000').
    self assert:((n1 perform:'-' asSymbol with:16r10000000) hexPrintString = 'F0000000').
    self assert:((16r100000000 perform:'-' asSymbol with:16r10000000) hexPrintString = 'F0000000').

    "
     self basicNew testLargeAddition2
    "
!

testLargeAddition3
    "general conversion & arithmetic 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 x|

    "Large - small subtraction"
    self assert:((20 factorial + 20 factorial - 1) printString = '4865804016353279999').
    self assert:((20 factorial - 10 factorial + 3628800) printString = '2432902008176640000').
    self assert:((20 factorial - 11 factorial + 39916800) printString = '2432902008176640000').
    self assert:((20 factorial - 12 factorial + 479001600) printString = '2432902008176640000').
    self assert:((20 factorial - 13 factorial + 6227020800) printString = '2432902008176640000').
    self assert:((20 factorial - 14 factorial + 87178291200) printString = '2432902008176640000').
    self assert:((20 factorial - 15 factorial + 1307674368000) printString = '2432902008176640000').
    self assert:((20 factorial - 16 factorial + 20922789888000) printString = '2432902008176640000').
    self assert:((20 factorial + 10 factorial - 3628800) printString = '2432902008176640000').

    self assert:(1000 factorial printString = '402387260077093773543702433923003985719374864210714632543799910429938512398629020592044208486969404800479988610197196058631666872994808558901323829669944590997424504087073759918823627727188732519779505950995276120874975462497043601418278094646496291056393887437886487337119181045825783647849977012476632889835955735432513185323958463075557409114262417474349347553428646576611667797396668820291207379143853719588249808126867838374559731746136085379534524221586593201928090878297308431392844403281231558611036976801357304216168747609675871348312025478589320767169132448426236131412508780208000261683151027341827977704784635868170164365024153691398281264810213092761244896359928705114964975419909342221566832572080821333186116811553615836546984046708975602900950537616475847728421889679646244945160765353408198901385442487984959953319101723355556602139450399736280750137837615307127761926849034352625200015888535147331611702103968175921510907788019393178114194545257223865541461062892187960223838971476088506276862967146674697562911234082439208160153780889893964518263243671616762179168909779911903754031274622289988005195444414282012187361745992642956581746628302955570299024324153181617210465832036786906117260158783520751516284225540265170483304226143974286933061690897968482590125458327168226458066526769958652682272807075781391858178889652208164348344825993266043367660176999612831860788386150279465955131156552036093988180612138558600301435694527224206344631797460594682573103790084024432438465657245014402821885252470935190620929023136493273497565513958720559654228749774011413346962715422845862377387538230483865688976461927383814900140767310446640259899490222221765904339901886018566526485061799702356193897017860040811889729918311021171229845901641921068884387121855646124960798722908519296819372388642614839657382291123125024186649353143970137428531926649875337218940694281434118520158014123344828015051399694290153483077644569099073152433278288269864602789864321139083506217095002597389863554277196742822248757586765752344220207573630569498825087968928162753848863396909959826280956121450994871701244516461260379029309120889086942028510640182154399457156805941872748998094254742173582401063677404595741785160829230135358081840096996372524230560855903700624271243416909004153690105933983835777939410970027753472000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000').

    n1 := n2 := 1.
    self assert:((1000 factorial + n1 - n2) = 1000 factorial).
    n1 := n2 := 1000.
    self assert:((1000 factorial + n1 - n2) = 1000 factorial).
    n1 := n2 := 16rFFFFFFFF.
    self assert:((1000 factorial + n1 - n2) = 1000 factorial).
    n1 := n2 := 16rFFFFFFFFFFFF.
    self assert:((1000 factorial + n1 - n2) = 1000 factorial).
    n1 := n2 := 16rFFFFFFFFFFFFFFFF.
    self assert:((1000 factorial + n1 - n2) = 1000 factorial).
    n1 := n2 := 1000 factorial.
    self assert:((1000 factorial + n1 - n2) = 1000 factorial).


    "
     self basicNew testLargeAddition3
    "

    "Modified: / 27.11.1999 / 16:41:54 / cg"
!

testLargeBitOperations
    "large bit operations test."

     self assert:(16rFFEEDDCCBBAA998877665544332211 bitAnd:16rFFFF) hexPrintString = '2211'.
     self assert:(16rFFEEDDCCBBAA998877665544332211 bitAnd:16rFFFFFF) hexPrintString  = '332211'.
     self assert:(16rFFEEDDCCBBAA998877665544332211 bitAnd:16rFFFFFFFF) hexPrintString = '44332211'.
     self assert:(16rFFEEDDCCBBAA998877665544332211 bitAnd:16rFFFFFFFFFF) hexPrintString = '5544332211'.
     self assert:(16rFFEEDDCCBBAA998877665544332211 bitAnd:16rFFFFFFFFFFFF) hexPrintString = '665544332211'.
     self assert:(16rFFEEDDCCBBAA998877665544332211 bitAnd:16rFFFFFFFFFFFFFF) hexPrintString = '77665544332211'.
     self assert:(16rFFEEDDCCBBAA998877665544332211 bitAnd:16rFFFFFFFFFFFFFFFF) hexPrintString = '8877665544332211'.
     self assert:(16rFFEEDDCCBBAA998877665544332211 bitAnd:16rFFFFFFFFFFFFFFFFFF) hexPrintString = '998877665544332211'.
     self assert:(16rFFEEDDCCBBAA998877665544332211 bitAnd:16rFFFFFFFFFFFFFFFFFFFF) hexPrintString = 'AA998877665544332211'.
     self assert:(16rFFEEDDCCBBAA998877665544332211 bitAnd:16rFFFFFFFFFFFFFFFFFFFFFF) hexPrintString = 'BBAA998877665544332211'.
     self assert:(16rFFEEDDCCBBAA998877665544332211 bitAnd:16rFFFFFFFFFFFFFFFFFFFFFFFF) hexPrintString = 'CCBBAA998877665544332211'.

     self assert:(16rFFEEDDCCBBAA998877665544332211 bitOr:16rFFFF) hexPrintString = 'FFEEDDCCBBAA99887766554433FFFF'.
     self assert:(16rFFEEDDCCBBAA998877665544332211 bitOr:16rFFFFFF) hexPrintString  = 'FFEEDDCCBBAA998877665544FFFFFF'.
     self assert:(16rFFEEDDCCBBAA998877665544332211 bitOr:16rFFFFFFFF) hexPrintString = 'FFEEDDCCBBAA9988776655FFFFFFFF'.
     self assert:(16rFFEEDDCCBBAA998877665544332211 bitOr:16rFFFFFFFFFF) hexPrintString = 'FFEEDDCCBBAA99887766FFFFFFFFFF'.
     self assert:(16rFFEEDDCCBBAA998877665544332211 bitOr:16rFFFFFFFFFFFF) hexPrintString = 'FFEEDDCCBBAA998877FFFFFFFFFFFF'.
     self assert:(16rFFEEDDCCBBAA998877665544332211 bitOr:16rFFFFFFFFFFFFFF) hexPrintString = 'FFEEDDCCBBAA9988FFFFFFFFFFFFFF'.
     self assert:(16rFFEEDDCCBBAA998877665544332211 bitOr:16rFFFFFFFFFFFFFFFF) hexPrintString = 'FFEEDDCCBBAA99FFFFFFFFFFFFFFFF'.
     self assert:(16rFFEEDDCCBBAA998877665544332211 bitOr:16rFFFFFFFFFFFFFFFFFF) hexPrintString = 'FFEEDDCCBBAAFFFFFFFFFFFFFFFFFF'.
     self assert:(16rFFEEDDCCBBAA998877665544332211 bitOr:16rFFFFFFFFFFFFFFFFFFFF) hexPrintString = 'FFEEDDCCBBFFFFFFFFFFFFFFFFFFFF'.
     self assert:(16rFFEEDDCCBBAA998877665544332211 bitOr:16rFFFFFFFFFFFFFFFFFFFFFF) hexPrintString = 'FFEEDDCCFFFFFFFFFFFFFFFFFFFFFF'.
     self assert:(16rFFEEDDCCBBAA998877665544332211 bitOr:16rFFFFFFFFFFFFFFFFFFFFFFFF) hexPrintString = 'FFEEDDFFFFFFFFFFFFFFFFFFFFFFFF'.

    Time millisecondsToRun:[
        100000 timesRepeat:[
            (16rFFEEDDCCBBAA998877665544332211 bitAnd:16rFFFFFFFFFFFFFFFFFFFFFFFF)
        ]
    ]

    "
     self basicNew testLargeBitOperations
    "

    "Modified: / 4.6.1999 / 15:26:55 / cg"
!

testLargeDivision
    |t v|

    t := 20 factorial.

    self assert:(t printString = '2432902008176640000').
    self assert:(t \\ 10 == 0).
    t := t // 10.
    self assert:(t printString = '243290200817664000').
    self assert:(t \\ 10 == 0).
    t := t // 10.
    self assert:(t printString = '24329020081766400').
    self assert:(t \\ 10 == 0).
    t := t // 10.
    self assert:(t printString = '2432902008176640').
    self assert:(t \\ 10 == 0).
    t := t // 10.
    self assert:(t printString = '243290200817664').
    self assert:(t \\ 10 == 4).
    t := t // 10.
    self assert:(t printString = '24329020081766').
    self assert:(t \\ 10 == 6).
    t := t // 10.
    self assert:(t printString = '2432902008176').
    self assert:(t \\ 10 == 6).
    t := t // 10.
    self assert:(t printString = '243290200817').
    self assert:(t \\ 10 == 7).
    t := t // 10.
    self assert:(t printString = '24329020081').
    self assert:(t \\ 10 == 1).
    t := t // 10.
    self assert:(t printString = '2432902008').
    self assert:(t \\ 10 == 8).
    t := t // 10.
    self assert:(t printString = '243290200').
    self assert:(t \\ 10 == 0).


    t := 20 factorial.

    self assert:(t printString = '2432902008176640000').
    self assert:(t \\ 1000 == 0).
    t := t // 1000.
    self assert:(t printString = '2432902008176640').
    self assert:(t \\ 1000 == 640).
    t := t // 1000.
    self assert:(t printString = '2432902008176').
    self assert:(t \\ 1000 == 176).
    t := t // 1000.
    self assert:(t printString = '2432902008').
    self assert:(t \\ 1000 == 8).
    t := t // 1000.
    self assert:(t printString = '2432902').
    self assert:(t \\ 1000 == 902).
    t := t // 1000.
    self assert:(t printString = '2432').
    self assert:(t \\ 1000 == 432).
    t := t // 1000.
    self assert:(t == 2).
    self assert:(t \\ 1000 == 2).


    t := 20 factorial.

    "Large // SmallInt division"
    t := t // 20.
    self assert:(t printString = 19 factorial printString).
    t := t // 19.
    self assert:(t printString = 18 factorial printString).
    t := t // 18.
    self assert:(t printString = 17 factorial printString).
    t := t // 17.
    self assert:(t printString = 16 factorial printString).
    t := t // 16.
    self assert:(t printString = 15 factorial printString).
    t := t // 15.
    self assert:(t printString = 14 factorial printString).
    t := t // 14.
    self assert:(t printString = 13 factorial printString).
    t := t // 13.
    self assert:(t printString = 12 factorial printString).
    t := t // 12.
    self assert:(t printString = 11 factorial printString).
    t := t // 11.
    self assert:(t printString = 10 factorial printString).
    self assert:(t == 10 factorial).

    t := 20 factorial.
    t := t + 21 factorial.
    t absSubtract:21 factorial.
    self assert:(t compressed = 20 factorial).

    self assert:(
             [   
               |v| 
               v := 100 factorial copy.
               v absSubtract:99 factorial.   
               v compressed = (100 factorial - 99 factorial).
             ] value).

    "Large // Large division"
    self assert:((20 factorial // 19 factorial) == 20).
    self assert:((20 factorial * 21 // 20 // 21) = (19 factorial)).
    self assert:((10000 factorial // 9999 factorial) == 10000).
    self assert:((10000 factorial // 9999 factorial) == (10000 factorial / 9999 factorial)).

    "
     self basicNew testLargeDivision
    "

    "Modified: / 4.6.1999 / 23:54:57 / cg"
!

testLargeIntegerHelpers
    |t1 t2 t|

    "mul2"

    t1 := 16r12345678901234567890.
    t2 := t1 deepCopy.
    self assert:(t1 mul2 = (t2 * 2)).

    t1 := 16r1234567890123456789012345678901234567890.
    t2 := t1 deepCopy.
    self assert:(t1 mul2 = (t2 * 2)).

    t1 := 16r123456789012345678901234567890123456789012345678901234567890.
    t2 := t1 deepCopy.
    self assert:(t1 mul2 = (t2 * 2)).

    t1 := 16r12345678901234567890123456789012345678901234567890123456789012345678901234567890.
    t2 := t1 deepCopy.
    self assert:(t1 mul2 = (t2 * 2)).

    t1 := 10000 factorial.
    t2 := t1 deepCopy.
    self assert:(t1 mul2 = (t2 * 2)).

"/    t1 := 1000 factorial.
"/    t := Time millisecondsToRun:[ 100000 timesRepeat:[ t1 mul2. ] ].
"/    Transcript showCR:t.

    "
     self basicNew testLargeIntegerHelpers
    "

    "Modified: / 20.5.1999 / 09:41:19 / cg"
!

testLargeMultiplication
    |t1|

    "multiplication"
    t1 := 100.
    self assert:(t1 * t1 == 10000).
    self assert:((t1 perform:'*' asSymbol with:t1) == 10000).
    self assert:((t1 * t1) printString = '10000').
    self assert:((t1 perform:'*' asSymbol with:t1) printString = '10000').

    t1 := 1000.
    self assert:(t1 * t1 == 1000000).
    self assert:((t1 perform:'*' asSymbol with:t1) == 1000000).
    self assert:((t1 * t1) printString = '1000000').
    self assert:((t1 perform:'*' asSymbol with:t1) printString = '1000000').

    t1 := 10000.
    self assert:(t1 * t1 == 100000000).
    self assert:((t1 perform:'*' asSymbol with:t1) == 100000000).
    self assert:((t1 * t1) printString = '100000000').
    self assert:((t1 perform:'*' asSymbol with:t1) printString = '100000000').

    t1 := 100000.
    SmallInteger maxBytes == 4 ifTrue:[
        self assert:(t1 * t1 = 10000000000).
        self assert:((t1 perform:'*' asSymbol with:t1) = 10000000000).
    ].
    SmallInteger maxBytes == 8 ifTrue:[
        self assert:(t1 * t1 == 10000000000).
        self assert:((t1 perform:'*' asSymbol with:t1) == 10000000000).
    ].

    self assert:((t1 * t1) printString = '10000000000').
    self assert:((t1 perform:'*' asSymbol with:t1) printString = '10000000000').

    t1 := 1000000.
    self assert:((t1 * t1) printString = '1000000000000').
    self assert:((t1 perform:'*' asSymbol with:t1) printString = '1000000000000').

    t1 := 10000000.
    self assert:((t1 * t1) printString = '100000000000000').
    self assert:((t1 perform:'*' asSymbol with:t1) printString = '100000000000000').

    t1 := 100000000.
    self assert:((t1 * t1) printString = '10000000000000000').
    self assert:((t1 perform:'*' asSymbol with:t1) printString = '10000000000000000').

    t1 := 1000000000.
    self assert:((t1 * t1) printString = '1000000000000000000').
    self assert:((t1 perform:'*' asSymbol with:t1) printString = '1000000000000000000').


    "Large * SmallInt multiplication"
    self assert:(10 factorial printString = '3628800').
    self assert:(20 factorial printString = '2432902008176640000').
    self assert:(100 factorial printString = '93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000').
    self assert:(1000 factorial printString = '402387260077093773543702433923003985719374864210714632543799910429938512398629020592044208486969404800479988610197196058631666872994808558901323829669944590997424504087073759918823627727188732519779505950995276120874975462497043601418278094646496291056393887437886487337119181045825783647849977012476632889835955735432513185323958463075557409114262417474349347553428646576611667797396668820291207379143853719588249808126867838374559731746136085379534524221586593201928090878297308431392844403281231558611036976801357304216168747609675871348312025478589320767169132448426236131412508780208000261683151027341827977704784635868170164365024153691398281264810213092761244896359928705114964975419909342221566832572080821333186116811553615836546984046708975602900950537616475847728421889679646244945160765353408198901385442487984959953319101723355556602139450399736280750137837615307127761926849034352625200015888535147331611702103968175921510907788019393178114194545257223865541461062892187960223838971476088506276862967146674697562911234082439208160153780889893964518263243671616762179168909779911903754031274622289988005195444414282012187361745992642956581746628302955570299024324153181617210465832036786906117260158783520751516284225540265170483304226143974286933061690897968482590125458327168226458066526769958652682272807075781391858178889652208164348344825993266043367660176999612831860788386150279465955131156552036093988180612138558600301435694527224206344631797460594682573103790084024432438465657245014402821885252470935190620929023136493273497565513958720559654228749774011413346962715422845862377387538230483865688976461927383814900140767310446640259899490222221765904339901886018566526485061799702356193897017860040811889729918311021171229845901641921068884387121855646124960798722908519296819372388642614839657382291123125024186649353143970137428531926649875337218940694281434118520158014123344828015051399694290153483077644569099073152433278288269864602789864321139083506217095002597389863554277196742822248757586765752344220207573630569498825087968928162753848863396909959826280956121450994871701244516461260379029309120889086942028510640182154399457156805941872748998094254742173582401063677404595741785160829230135358081840096996372524230560855903700624271243416909004153690105933983835777939410970027753472000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000').

    "Large * Large multiplication"
    self assert:((16r3FFF * 16r3FFF) hexPrintString = 'FFF8001').
    self assert:((16r7FFF * 16r7FFF) hexPrintString = '3FFF0001').
    self assert:((16rFFFF * 16rFFFF) hexPrintString = 'FFFE0001').
    self assert:((16r3FFFFF * 16r3FFFFF) hexPrintString = 'FFFFF800001').
    self assert:((16r7FFFFF * 16r7FFFFF) hexPrintString = '3FFFFF000001').
    self assert:((16rFFFFFF * 16rFFFFFF) hexPrintString = 'FFFFFE000001').
    self assert:((16r3FFFFFFF * 16r3FFFFFFF) hexPrintString = 'FFFFFFF80000001').
    self assert:((16r7FFFFFFF * 16r7FFFFFFF) hexPrintString = '3FFFFFFF00000001').
    self assert:((16rFFFFFFFF * 16rFFFFFFFF) hexPrintString = 'FFFFFFFE00000001').
    self assert:((16r3FFFFFFFFF * 16r3FFFFFFFFF) hexPrintString = 'FFFFFFFFF8000000001').
    self assert:((16r7FFFFFFFFF * 16r7FFFFFFFFF) hexPrintString = '3FFFFFFFFF0000000001').
    self assert:((16rFFFFFFFFFF * 16rFFFFFFFFFF) hexPrintString = 'FFFFFFFFFE0000000001').
    self assert:((20 factorial * 20 factorial) printString = '5919012181389927685417441689600000000').

    "
     self basicNew testLargeMultiplication
    "

    "Modified: / 20.5.1999 / 09:41:19 / cg"
!

testLargeSubtraction1
    |a1 a2 a b1 b2 b c1 c2 c|

    self assert:((2770568 + 2770568) printString = '5541136').
    self assert:((2770568 - 2770568) printString = '0').
    self assert:((2770568 negated + 2770568 negated) printString = '-5541136').
    self assert:((5541136 negated - 2770568 negated) printString = '-2770568').

    "Large - small subtraction"

    self assert:((2770568900 + 2770568900) printString = '5541137800').
    self assert:((2770568900 - 2770568900) printString = '0').
    self assert:((2770568900 negated + 2770568900 negated) printString = '-5541137800').
    self assert:((5541137800 negated - 2770568900 negated) printString = '-2770568900').
    self assert:((2770568900 negated - 5541137800 negated) printString = '2770568900').

    a1 := -2770568900. a2 := 59049.
    a := (a1 / a2) negated.
    b1 := -5872025600. b2 := 59049.
    b := (b1 / b2) negated.
    c1 := 344606300. c2 := 6561.
    c := (c1 / c2) negated.
    self assert:(a - b closeTo: c).
    self assert:((a - b) asFloat closeTo: c asFloat).
    self assert:((a asFloat - b) closeTo: c asFloat).
    self assert:((a - b asFloat) closeTo: c asFloat).

    a := -10.
    b := -12.
    self assert:(a - b = 2).

    a := -10000000.
    b := -12000000.
    self assert:(a - b = 2000000).

    a := -100000000000000.
    b := -120000000000000.
    self assert:(a - b = 20000000000000).

    "smallInteger - largeInteger"
    self assert:(-1000000000 - -2000000000 = 1000000000).
    "largeInteger - smallInteger"
    self assert:(-2000000000 - -1000000000 = -1000000000).

    "
     self basicNew testLargeSubtraction1
    "

    "Modified: / 27.11.1999 / 16:41:54 / cg"
!

testLiteralNumbers
    self assert:(self num_00000000000010000 hexPrintString = '10000').
    self assert:(self num_00000000000100000 hexPrintString = '100000').
    self assert:(self num_00000000001000000 hexPrintString = '1000000').
    self assert:(self num_00000000010000000 hexPrintString = '10000000').
    self assert:(self num_00000000100000000 hexPrintString = '100000000').
    self assert:(self num_00000001000000000 hexPrintString = '1000000000').
    self assert:(self num_00000010000000000 hexPrintString = '10000000000').
    self assert:(self num_00000100000000000 hexPrintString = '100000000000').
    self assert:(self num_00001000000000000 hexPrintString = '1000000000000').
    self assert:(self num_00010000000000000 hexPrintString = '10000000000000').
    self assert:(self num_00100000000000000 hexPrintString = '100000000000000').
    self assert:(self num_01000000000000000 hexPrintString = '1000000000000000').
    self assert:(self num_10000000000000000 hexPrintString = '10000000000000000').

    self assert:(self num_00000000000007FFF hexPrintString = '7FFF').
    self assert:(self num_00000000000008000 hexPrintString = '8000').
    self assert:(self num_0000000000000FFFF hexPrintString = 'FFFF').
    self assert:(self num_000000000007FFFFF hexPrintString = '7FFFFF').
    self assert:(self num_00000000000800000 hexPrintString = '800000').
    self assert:(self num_00000000000FFFFFF hexPrintString = 'FFFFFF').
    self assert:(self num_0000000007FFFFFFF hexPrintString = '7FFFFFFF').
    self assert:(self num_00000000080000000 hexPrintString = '80000000').
    self assert:(self num_000000000FFFFFFFF hexPrintString = 'FFFFFFFF').
    self assert:(self num_0000000FFFFFFFFFF hexPrintString = 'FFFFFFFFFF').
    self assert:(self num_00000FFFFFFFFFFFF hexPrintString = 'FFFFFFFFFFFF').
    self assert:(self num_000FFFFFFFFFFFFFF hexPrintString = 'FFFFFFFFFFFFFF').
    self assert:(self num_0FFFFFFFFFFFFFFFF hexPrintString = 'FFFFFFFFFFFFFFFF').
    self assert:(self num_1FFFFFFFFFFFFFFFF hexPrintString = '1FFFFFFFFFFFFFFFF').
    self assert:(self num_20000000000000000 hexPrintString = '20000000000000000').
    self assert:(self num_3FFFFFFFFFFFFFFFF hexPrintString = '3FFFFFFFFFFFFFFFF').
    self assert:(self num_40000000000000000 hexPrintString = '40000000000000000').
    self assert:(self num_7FFFFFFFFFFFFFFFF hexPrintString = '7FFFFFFFFFFFFFFFF').
    self assert:(self num_80000000000000000 hexPrintString = '80000000000000000').

    self assert:(self num_00000FFFFFFFFFFFE hexPrintString = 'FFFFFFFFFFFE').
    self assert:(self num_00000FFFFFFFFFFFC hexPrintString = 'FFFFFFFFFFFC').
    self assert:(self num_00000FFFFFFFFFFF8 hexPrintString = 'FFFFFFFFFFF8').
    self assert:(self num_00000FFFFFFFFFFF0 hexPrintString = 'FFFFFFFFFFF0').
    self assert:(self num_00000FFFFFFFFFFE0 hexPrintString = 'FFFFFFFFFFE0').
    self assert:(self num_00000FFFFFFFFFFC0 hexPrintString = 'FFFFFFFFFFC0').
    self assert:(self num_00000FFFFFFFFFF80 hexPrintString = 'FFFFFFFFFF80').
    self assert:(self num_00000FFFFFFFFFF00 hexPrintString = 'FFFFFFFFFF00').

    self assert:(self num_0000000000FFF0000 hexPrintString = 'FFF0000').

    "
     self basicNew testLiteralNumbers
    "

    "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).

    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).


    a := -17.
    b := 8.
    self assert:(-17 \\ 8 == 7).
    self assert:(a \\ 8 == 7).
    self assert:(-17 \\ b == 7).
    self assert:(a \\ b == 7).

    self assert:((-17 perform:op with: 8) == 7).
    self assert:((a perform:op with: 8) == 7).
    self assert:((-17 perform:op with: b) == 7).
    self assert:((a perform:op with: b) == 7).

    a := 17.
    b := -8.
    self assert:(17 \\ -8 == -7).
    self assert:(a \\ -8 == -7).
    self assert:(17 \\ b == -7).
    self assert:(a \\ b == -7).

    self assert:((17 perform:op with: -8) == -7).
    self assert:((a perform:op with: -8) == -7).
    self assert:((17 perform:op with: b) == -7).
    self assert:((a perform:op with: b) == -7).

    a := -17.
    b := -8.
    self assert:(-17 \\ -8 == -1).
    self assert:(a \\ -8 == -1).
    self assert:(-17 \\ b == -1).
    self assert:(a \\ b == -1).

    self assert:((-17 perform:op with: -8) == -1).
    self assert:((a perform:op with: -8) == -1).
    self assert:((-17 perform:op with: b) == -1).
    self assert:((a perform:op with: b) == -1).

    a := 17.
    b := 8.
    self assert:(17 \\ 8 == 1).
    self assert:(a \\ 8 == 1).
    self assert:(17 \\ b == 1).
    self assert:(a \\ b == 1).

    self assert:((17 perform:op with: 8) == 1).
    self assert:((a perform:op with: 8) == 1).
    self assert:((17 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).

    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 := -17.
    b := 8.
    self assert:((-17 rem: 8) == -1).
    self assert:((a rem: 8) == -1).
    self assert:((-17 rem: b) == -1).
    self assert:((a rem: b) == -1).

    self assert:((-17 perform:op with: -8) == -1).
    self assert:((a perform:op with: -8) == -1).
    self assert:((-17 perform:op with: b) == -1).
    self assert:((a perform:op with: b) == -1).

    a := 17.
    b := -8.
    self assert:((17 rem: -8) == 1).
    self assert:((a rem: -8) == 1).
    self assert:((17 rem: b) == 1).
    self assert:((a rem: b) == 1).

    self assert:((17 perform:op with: -8) == 1).
    self assert:((a perform:op with: -8) == 1).
    self assert:((17 perform:op with: b) == 1).
    self assert:((a perform:op with: b) == 1).

    a := -17.
    b := -8.
    self assert:((-17 rem: -8) == -1).
    self assert:((a rem: -8) == -1).
    self assert:((-17 rem: b) == -1).
    self assert:((a rem: b) == -1).

    self assert:((-17 perform:op with: -8) == -1).
    self assert:((a perform:op with: -8) == -1).
    self assert:((-17 perform:op with: b) == -1).
    self assert:((a perform:op with: b) == -1).

    a := 17.
    b := 8.
    self assert:((17 rem: 8) == 1).
    self assert:((a rem: 8) == 1).
    self assert:((17 rem: b) == 1).
    self assert:((a rem: b) == 1).

    self assert:((17 perform:op with: 8) == 1).
    self assert:((a perform:op with: 8) == 1).
    self assert:((17 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').
    self assert:(1000 printString = '1000').
    self assert:(10000 printString = '10000').
    self assert:(100000 printString = '100000').
    self assert:(1000000 printString = '1000000').
    self assert:(10000000 printString = '10000000').
    self assert:(100000000 printString = '100000000').
    self assert:(1000000000 printString = '1000000000').
    self assert:(10000000000 printString = '10000000000').
    self assert:(100000000000 printString = '100000000000').
    self assert:(1000000000000 printString = '1000000000000').
    self assert:(10000000000000 printString = '10000000000000').
    self assert:(100000000000000 printString = '100000000000000').
    self assert:(1000000000000000 printString = '1000000000000000').
    self assert:(10000000000000000 printString = '10000000000000000').
    self assert:(100000000000000000 printString = '100000000000000000').

    self assert:(16rF hexPrintString = 'F').
    self assert:(16rFF hexPrintString = 'FF').
    self assert:(16rFFF hexPrintString = 'FFF').
    self assert:(16rFFFF hexPrintString = 'FFFF').
    self assert:(16rFFFFF hexPrintString = 'FFFFF').
    self assert:(16rFFFFFF hexPrintString = 'FFFFFF').
    self assert:(16rFFFFFFF hexPrintString = 'FFFFFFF').
    self assert:(16rFFFFFFFF hexPrintString = 'FFFFFFFF').
    self assert:(16rFFFFFFFFF hexPrintString = 'FFFFFFFFF').
    self assert:(16rFFFFFFFFFF hexPrintString = 'FFFFFFFFFF').
    self assert:(16rFFFFFFFFFFF hexPrintString = 'FFFFFFFFFFF').
    self assert:(16rFFFFFFFFFFFF hexPrintString = 'FFFFFFFFFFFF').
    self assert:(16rFFFFFFFFFFFFF hexPrintString = 'FFFFFFFFFFFFF').
    self assert:(16rFFFFFFFFFFFFFF hexPrintString = 'FFFFFFFFFFFFFF').
    self assert:(16rFFFFFFFFFFFFFFF hexPrintString = 'FFFFFFFFFFFFFFF').
    self assert:(16rFFFFFFFFFFFFFFFF hexPrintString = 'FFFFFFFFFFFFFFFF').
    self assert:(16rFFFFFFFFFFFFFFFFF hexPrintString = 'FFFFFFFFFFFFFFFFF').
    self assert:(16rFFFFFFFFFFFFFFFFFF hexPrintString = 'FFFFFFFFFFFFFFFFFF').
    self assert:(16rFFFFFFFFFFFFFFFFFFF hexPrintString = 'FFFFFFFFFFFFFFFFFFF').
    self assert:(16rFFFFFFFFFFFFFFFFFFFF hexPrintString = 'FFFFFFFFFFFFFFFFFFFF').

    self assert:(16r10 hexPrintString = '10').
    self assert:(16r100 hexPrintString = '100').
    self assert:(16r1000 hexPrintString = '1000').
    self assert:(16r10000 hexPrintString = '10000').
    self assert:(16r100000 hexPrintString = '100000').
    self assert:(16r1000000 hexPrintString = '1000000').
    self assert:(16r10000000 hexPrintString = '10000000').
    self assert:(16r100000000 hexPrintString = '100000000').
    self assert:(16r1000000000 hexPrintString = '1000000000').
    self assert:(16r10000000000 hexPrintString = '10000000000').
    self assert:(16r100000000000 hexPrintString = '100000000000').
    self assert:(16r1000000000000 hexPrintString = '1000000000000').
    self assert:(16r10000000000000 hexPrintString = '10000000000000').
    self assert:(16r100000000000000 hexPrintString = '100000000000000').
    self assert:(16r1000000000000000 hexPrintString = '1000000000000000').
    self assert:(16r10000000000000000 hexPrintString = '10000000000000000').
    self assert:(16r100000000000000000 hexPrintString = '100000000000000000').

    "
     self basicNew testPrinting1
    "

    "Modified: / 26.10.1999 / 22:01:35 / stefan"
!

testReading1
    |t|

    self assert:((Integer readFrom:'4865804016353280000') printString = '4865804016353280000').
    self assert:((Integer readFrom:'FFFFFFFF' radix:16) hexPrintString = 'FFFFFFFF').
    self assert:((Integer readFrom:'FFFFFFFFF' radix:16) hexPrintString = 'FFFFFFFFF').
    self assert:((Integer readFrom:'FFFFFFFFFF' radix:16) hexPrintString = 'FFFFFFFFFF').
    self assert:((Integer readFrom:'FFFFFFFFFFF' radix:16) hexPrintString = 'FFFFFFFFFFF').
    self assert:((Integer readFrom:'FFFFFFFFFFFF' radix:16) hexPrintString = 'FFFFFFFFFFFF').
    self assert:((Integer readFrom:'FFFFFFFFFFFFF' radix:16) hexPrintString = 'FFFFFFFFFFFFF').
    self assert:((Integer readFrom:'FFFFFFFFFFFFFF' radix:16) hexPrintString = 'FFFFFFFFFFFFFF').

    self assert:((Integer readFrom:'10000000' radix:16) hexPrintString = '10000000').
    self assert:((Integer readFrom:'100000000' radix:16) hexPrintString = '100000000').
    self assert:((Integer readFrom:'1000000000' radix:16) hexPrintString = '1000000000').
    self assert:((Integer readFrom:'10000000000' radix:16) hexPrintString = '10000000000').
    self assert:((Integer readFrom:'100000000000' radix:16) hexPrintString = '100000000000').
    self assert:((Integer readFrom:'1000000000000' radix:16) hexPrintString = '1000000000000').
    self assert:((Integer readFrom:'10000000000000' radix:16) hexPrintString = '10000000000000').

    t := Integer readFrom:'FFFFFFFF' radix:16.
    self assert:((t + 1) hexPrintString = '100000000').
    t := Integer readFrom:'FFFFFFFFF' radix:16.
    self assert:((t + 1) hexPrintString = '1000000000').
    t := Integer readFrom:'FFFFFFFFFF' radix:16.
    self assert:((t + 1) hexPrintString = '10000000000').
    t := Integer readFrom:'FFFFFFFFFFF' radix:16.
    self assert:((t + 1) hexPrintString = '100000000000').

    t := Integer readFrom:'10000000' radix:16.
    self assert:((t + 1) hexPrintString = '10000001').
    t := Integer readFrom:'100000000' radix:16.
    self assert:((t + 1) hexPrintString = '100000001').
    t := Integer readFrom:'1000000000' radix:16.
    self assert:((t + 1) hexPrintString = '1000000001').
    t := Integer readFrom:'10000000000' radix:16.
    self assert:((t + 1) hexPrintString = '10000000001').

    "
     self basicNew testReading1
    "
!

testSmallIntegerArithmetic
    "arithmetic 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|

    "/ test division and modulu ...
    self assert:(1 printString = '1').
    self assert:(10 printString = '10').
    self assert:(100 printString = '100').
    self assert:(1000 printString = '1000').
    self assert:(10000 printString = '10000').
    self assert:(100000 printString = '100000').

    "addition with overflow"

    SmallInteger maxBytes == 4 ifTrue:[
        n1 := 16r3FFFFFFF.
        n2 := -16r40000000.
    ] ifFalse:[
        n1 := 16r3FFFFFFFFFFFFFFF.
        n2 := -16r4000000000000000.
    ].
    self assert:(n1 class == SmallInteger).
    self assert:(n2 class == SmallInteger).

    self assert:((n1 + 1) class == LargeInteger).
    t := n1 + 1.
    self assert:((t - 1) class == SmallInteger).

    self assert:((n2 - 1) class == LargeInteger).
    t := n2 - 1.
    self assert:((t + 1) class == SmallInteger).

    self assert:((n1 negated) class == SmallInteger).
    self assert:((n2 negated) class == LargeInteger).
    self assert:((n1 perform:'negated' asSymbol) class == SmallInteger).
    self assert:((n2 perform:'negated' asSymbol) class == LargeInteger).

    self assert:((n1 abs == n1)).
    self assert:((n2 abs = n2 negated)).
    self assert:((n1 perform:'abs' asSymbol) == n1).
    self assert:((n2 perform:'abs' asSymbol) = n2 negated).

    self testSmallIntegerMultiplication1.
    self testSmallIntegerMultiplication1b.
    self testSmallIntegerMultiplication2.
    self testSmallIntegerDivision1.

    "
     self basicNew testSmallIntegerArithmetic
    "

    "Created: / 6.6.1999 / 14:47:51 / cg"
    "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 assert:((n1 // n2) == 333).
    self assert:((n1 // n2) printString = '333').
    self assert:((n1 perform:'//' asSymbol with:n2) == 333).

    n2 := -3.
    self assert:((n1 // n2) == -334).
    self assert:((n1 // n2) printString = '-334').
    self assert:((n1 perform:'//' asSymbol with:n2) == -334).

    n2 := 3600000.
    self assert:((n1 // n2) == 0).
    self assert:((n1 // n2) printString = '0').
    self assert:((n1 perform:'//' asSymbol with:n2) == 0).

    n2 := -3600000.
    self assert:((n1 // n2) == -1).
    self assert:((n1 // n2) printString = '-1').
    self assert:((n1 perform:'//' asSymbol with:n2) == -1).

    "/ ... zero
    n2 := 3.
    self assert:((n1 quo: n2) == 333).
    self assert:((n1 quo: n2) printString = '333').
    self assert:((n1 perform:'quo:' asSymbol with:n2) == 333).

    n2 := -3.
    self assert:((n1 quo: n2) == -333).
    self assert:((n1 quo: n2) printString = '-333').
    self assert:((n1 perform:'quo:' asSymbol with:n2) == -333).

    n2 := 3600000.
    self assert:((n1 quo: n2) == 0).
    self assert:((n1 quo: n2) printString = '0').
    self assert:((n1 perform:'quo:' asSymbol with:n2) == 0).

    n2 := -3600000.
    self assert:((n1 quo: n2) == 0).
    self assert:((n1 quo: n2) printString = '0').
    self assert:((n1 perform:'quo:' asSymbol with:n2) == 0).

    "
     self basicNew 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
     and via constructed performs. The reason is to test both inlined
     JIT-compiler code AND the regular methods code."

    |s n1 n2 t|

    n1 := 100000.
    n2 := n1 negated.

    self assert:(n1 printString = '100000').
    self assert:(n2 printString = '-100000').

    self assert:((n1 * 0) printString = '0').
    self assert:((n1 perform:'*' asSymbol with:0) printString = '0').

    self assert:((n1 * 1) printString = '100000').
    self assert:((n1 perform:'*' asSymbol with:1) printString = '100000').
    self assert:((n2 * 1) printString = '-100000').
    self assert:((n2 perform:'*' asSymbol with:1) printString = '-100000').

    self assert:((n1 * -1) printString = '-100000').
    self assert:((n1 perform:'*' asSymbol with:-1) printString = '-100000').
    self assert:((n2 * -1) printString = '100000').
    self assert:((n2 perform:'*' asSymbol with:-1) printString = '100000').

    self assert:((n1 * 2) printString = '200000').
    self assert:((n1 perform:'*' asSymbol with:2) printString = '200000').
    self assert:((n1 * 3) printString = '300000').
    self assert:((n1 perform:'*' asSymbol with:3) printString = '300000').
    self assert:((n1 * 4) printString = '400000').
    self assert:((n1 perform:'*' asSymbol with:4) printString = '400000').
    self assert:((n1 * 5) printString = '500000').
    self assert:((n1 perform:'*' asSymbol with:5) printString = '500000').
    self assert:((n1 * 6) printString = '600000').
    self assert:((n1 perform:'*' asSymbol with:6) printString = '600000').
    self assert:((n1 * 7) printString = '700000').
    self assert:((n1 perform:'*' asSymbol with:7) printString = '700000').
    self assert:((n1 * 8) printString = '800000').
    self assert:((n1 perform:'*' asSymbol with:8) printString = '800000').
    self assert:((n1 * 9) printString = '900000').
    self assert:((n1 perform:'*' asSymbol with:9) printString = '900000').
    self assert:((n1 * 10) printString = '1000000').
    self assert:((n1 perform:'*' asSymbol with:10) printString = '1000000').
    self assert:((n1 * 11) printString = '1100000').
    self assert:((n1 perform:'*' asSymbol with:11) printString = '1100000').
    self assert:((n1 * 12) printString = '1200000').
    self assert:((n1 perform:'*' asSymbol with:12) printString = '1200000').
    self assert:((n1 * 13) printString = '1300000').
    self assert:((n1 perform:'*' asSymbol with:13) printString = '1300000').
    self assert:((n1 * 14) printString = '1400000').
    self assert:((n1 perform:'*' asSymbol with:14) printString = '1400000').
    self assert:((n1 * 15) printString = '1500000').
    self assert:((n1 perform:'*' asSymbol with:15) printString = '1500000').
    self assert:((n1 * 16) printString = '1600000').
    self assert:((n1 perform:'*' asSymbol with:16) printString = '1600000').

    n1 := 1.
    n2 := 10.
    self assert:((n1 * n2) printString = '10').
    self assert:((n1 perform:'*' asSymbol with:n2) printString = '10').
    n2 := n2 * 10.
    self assert:((n1 * n2) printString = '100').
    self assert:((n1 perform:'*' asSymbol with:n2) printString = '100').
    n2 := n2 * 10.
    self assert:((n1 * n2) printString = '1000').
    self assert:((n1 perform:'*' asSymbol with:n2) printString = '1000').
    n2 := n2 * 10.
    self assert:((n1 * n2) printString = '10000').
    self assert:((n1 perform:'*' asSymbol with:n2) printString = '10000').
    n2 := n2 * 10.
    self assert:((n1 * n2) printString = '100000').
    self assert:((n1 perform:'*' asSymbol with:n2) printString = '100000').
    n2 := n2 * 10.
    self assert:((n1 * n2) printString = '1000000').
    self assert:((n1 perform:'*' asSymbol with:n2) printString = '1000000').
    n2 := n2 * 10.
    self assert:((n1 * n2) printString = '10000000').
    self assert:((n1 perform:'*' asSymbol with:n2) printString = '10000000').
    n2 := n2 * 10.
    self assert:((n1 * n2) printString = '100000000').
    self assert:((n1 perform:'*' asSymbol with:n2) printString = '100000000').
    n2 := n2 * 10.
    self assert:((n1 * n2) printString = '1000000000').
    self assert:((n1 perform:'*' asSymbol with:n2) printString = '1000000000').
    n2 := n2 * 10.
    self assert:((n1 * n2) printString = '10000000000').
    self assert:((n1 perform:'*' asSymbol with:n2) printString = '10000000000').
    n2 := n2 * 10.
    self assert:((n1 * n2) printString = '100000000000').
    self assert:((n1 perform:'*' asSymbol with:n2) printString = '100000000000').
    n2 := n2 * 10.
    self assert:((n1 * n2) printString = '1000000000000').
    self assert:((n1 perform:'*' asSymbol with:n2) printString = '1000000000000').
    n2 := n2 * 10.
    self assert:((n1 * n2) printString = '10000000000000').
    self assert:((n1 perform:'*' asSymbol with:n2) printString = '10000000000000').

    n1 := 1.
    n2 := 10.
    self assert:((n1 * n2) printString = '10').
    self assert:((n1 perform:'*' asSymbol with:n2) printString = '10').
    n1 := n1 * 10.
    self assert:((n1 * n2) printString = '100').
    self assert:((n1 perform:'*' asSymbol with:n2) printString = '100').
    n1 := n1 * 10.
    self assert:((n1 * n2) printString = '1000').
    self assert:((n1 perform:'*' asSymbol with:n2) printString = '1000').
    n1 := n1 * 10.
    self assert:((n1 * n2) printString = '10000').
    self assert:((n1 perform:'*' asSymbol with:n2) printString = '10000').
    n1 := n1 * 10.
    self assert:((n1 * n2) printString = '100000').
    self assert:((n1 perform:'*' asSymbol with:n2) printString = '100000').
    n1 := n1 * 10.
    self assert:((n1 * n2) printString = '1000000').
    self assert:((n1 perform:'*' asSymbol with:n2) printString = '1000000').
    n1 := n1 * 10.
    self assert:((n1 * n2) printString = '10000000').
    self assert:((n1 perform:'*' asSymbol with:n2) printString = '10000000').
    n1 := n1 * 10.
    self assert:((n1 * n2) printString = '100000000').
    self assert:((n1 perform:'*' asSymbol with:n2) printString = '100000000').
    n1 := n1 * 10.
    self assert:((n1 * n2) printString = '1000000000').
    self assert:((n1 perform:'*' asSymbol with:n2) printString = '1000000000').
    n1 := n1 * 10.
    self assert:((n1 * n2) printString = '10000000000').
    self assert:((n1 perform:'*' asSymbol with:n2) printString = '10000000000').
    n1 := n1 * 10.
    self assert:((n1 * n2) printString = '100000000000').
    self assert:((n1 perform:'*' asSymbol with:n2) printString = '100000000000').
    n1 := n1 * 10.
    self assert:((n1 * n2) printString = '1000000000000').
    self assert:((n1 perform:'*' asSymbol with:n2) printString = '1000000000000').
    n1 := n1 * 10.
    self assert:((n1 * n2) printString = '10000000000000').
    self assert:((n1 perform:'*' asSymbol with:n2) printString = '10000000000000').

    n1 := 10.
    n2 := 10.
    self assert:((n1 * n2) printString = '100').
    self assert:((n1 perform:'*' asSymbol with:n2) printString = '100').
    n1 := n1 * 10.
    n2 := n2 * 10.
    self assert:((n1 * n2) printString = '10000').
    self assert:((n1 perform:'*' asSymbol with:n2) printString = '10000').
    n1 := n1 * 10.
    n2 := n2 * 10.
    self assert:((n1 * n2) printString = '1000000').
    self assert:((n1 perform:'*' asSymbol with:n2) printString = '1000000').
    n1 := n1 * 10.
    n2 := n2 * 10.
    self assert:((n1 * n2) printString = '100000000').
    self assert:((n1 perform:'*' asSymbol with:n2) printString = '100000000').
    n1 := n1 * 10.
    n2 := n2 * 10.
    self assert:((n1 * n2) printString = '10000000000').
    self assert:((n1 perform:'*' asSymbol with:n2) printString = '10000000000').
    n1 := n1 * 10.
    n2 := n2 * 10.
    self assert:((n1 * n2) printString = '1000000000000').
    self assert:((n1 perform:'*' asSymbol with:n2) printString = '1000000000000').
    n1 := n1 * 10.
    n2 := n2 * 10.
    self assert:((n1 * n2) printString = '100000000000000').
    self assert:((n1 perform:'*' asSymbol with:n2) printString = '100000000000000').
    n1 := n1 * 10.
    n2 := n2 * 10.
    self assert:((n1 * n2) printString = '10000000000000000').
    self assert:((n1 perform:'*' asSymbol with:n2) printString = '10000000000000000').
    n1 := n1 * 10.
    n2 := n2 * 10.
    self assert:((n1 * n2) printString = '1000000000000000000').
    self assert:((n1 perform:'*' asSymbol with:n2) printString = '1000000000000000000').
    n1 := n1 * 10.
    n2 := n2 * 10.
    self assert:((n1 * n2) printString = '100000000000000000000').
    self assert:((n1 perform:'*' asSymbol with:n2) printString = '100000000000000000000').
    n1 := n1 * 10.
    n2 := n2 * 10.
    self assert:((n1 * n2) printString = '10000000000000000000000').
    self assert:((n1 perform:'*' asSymbol with:n2) printString = '10000000000000000000000').
    n1 := n1 * 10.
    n2 := n2 * 10.
    self assert:((n1 * n2) printString = '1000000000000000000000000').
    self assert:((n1 perform:'*' asSymbol with:n2) printString = '1000000000000000000000000').
    n1 := n1 * 10.
    n2 := n2 * 10.
    self assert:((n1 * n2) printString = '100000000000000000000000000').
    self assert:((n1 perform:'*' asSymbol with:n2) printString = '100000000000000000000000000').

    "
     self basicNew testSmallIntegerMultiplication1
    "

    "Modified: / 9.6.1999 / 17:47:56 / cg"
    "Created: / 9.6.1999 / 17:49:45 / cg"
!

testSmallIntegerMultiplication1b
    "multiply tests (const * var).
     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 := 100000.
    n2 := n1 negated.

    self assert:((0 * n1) printString = '0').
    self assert:((0 perform:'*' asSymbol with:n1) printString = '0').

    self assert:((1 * n1) printString = '100000').
    self assert:((1 perform:'*' asSymbol with:n1) printString = '100000').
    self assert:((1 * n2) printString = '-100000').
    self assert:((1 perform:'*' asSymbol with:n2) printString = '-100000').

    self assert:((-1 * n1) printString = '-100000').
    self assert:((-1 perform:'*' asSymbol with:n1) printString = '-100000').
    self assert:((-1 * n2) printString = '100000').
    self assert:((-1 perform:'*' asSymbol with:n2) printString = '100000').

    self assert:((2 * n1) printString = '200000').
    self assert:((2 perform:'*' asSymbol with:n1) printString = '200000').
    self assert:((3 * n1) printString = '300000').
    self assert:((3 perform:'*' asSymbol with:n1) printString = '300000').
    self assert:((4 * n1) printString = '400000').
    self assert:((4 perform:'*' asSymbol with:n1) printString = '400000').
    self assert:((5 * n1) printString = '500000').
    self assert:((5 perform:'*' asSymbol with:n1) printString = '500000').
    self assert:((6 * n1) printString = '600000').
    self assert:((6 perform:'*' asSymbol with:n1) printString = '600000').
    self assert:((7 * n1) printString = '700000').
    self assert:((7 perform:'*' asSymbol with:n1) printString = '700000').
    self assert:((8 * n1) printString = '800000').
    self assert:((8 perform:'*' asSymbol with:n1) printString = '800000').
    self assert:((9 * n1) printString = '900000').
    self assert:((9 perform:'*' asSymbol with:n1) printString = '900000').
    self assert:((10 * n1) printString = '1000000').
    self assert:((10 perform:'*' asSymbol with:n1) printString = '1000000').
    self assert:((11 * n1) printString = '1100000').
    self assert:((11 perform:'*' asSymbol with:n1) printString = '1100000').

    "
     self basicNew testSmallIntegerMultiplication1b
    "

    "Modified: / 9.6.1999 / 17:47:56 / cg"
    "Created: / 9.6.1999 / 17:49:45 / cg"
!

testSmallIntegerMultiplication2
    "multiply 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 := 100000.
    n2 := n1 negated.

    self assert:((n1 * 2) printString = '200000').
    self assert:((n1 perform:'*' asSymbol with:2) printString = '200000').
    self assert:((n1 * 3) printString = '300000').
    self assert:((n1 perform:'*' asSymbol with:3) printString = '300000').
    self assert:((n1 * 4) printString = '400000').
    self assert:((n1 perform:'*' asSymbol with:4) printString = '400000').
    self assert:((n1 * 5) printString = '500000').
    self assert:((n1 perform:'*' asSymbol with:5) printString = '500000').
    self assert:((n1 * 6) printString = '600000').
    self assert:((n1 perform:'*' asSymbol with:6) printString = '600000').
    self assert:((n1 * 7) printString = '700000').
    self assert:((n1 perform:'*' asSymbol with:7) printString = '700000').
    self assert:((n1 * 8) printString = '800000').
    self assert:((n1 perform:'*' asSymbol with:8) printString = '800000').
    self assert:((n1 * 9) printString = '900000').
    self assert:((n1 perform:'*' asSymbol with:9) printString = '900000').
    self assert:((n1 * 10) printString = '1000000').
    self assert:((n1 perform:'*' asSymbol with:10) printString = '1000000').
    self assert:((n1 * 11) printString = '1100000').
    self assert:((n1 perform:'*' asSymbol with:11) printString = '1100000').
    self assert:((n1 * 12) printString = '1200000').
    self assert:((n1 perform:'*' asSymbol with:12) printString = '1200000').
    self assert:((n1 * 13) printString = '1300000').
    self assert:((n1 perform:'*' asSymbol with:13) printString = '1300000').
    self assert:((n1 * 14) printString = '1400000').
    self assert:((n1 perform:'*' asSymbol with:14) printString = '1400000').
    self assert:((n1 * 15) printString = '1500000').
    self assert:((n1 perform:'*' asSymbol with:15) printString = '1500000').
    self assert:((n1 * 16) printString = '1600000').
    self assert:((n1 perform:'*' asSymbol with:16) printString = '1600000').
    self assert:((n1 * 17) printString = '1700000').
    self assert:((n1 perform:'*' asSymbol with:17) printString = '1700000').
    self assert:((n1 * 18) printString = '1800000').
    self assert:((n1 perform:'*' asSymbol with:18) printString = '1800000').
    self assert:((n1 * 19) printString = '1900000').
    self assert:((n1 perform:'*' asSymbol with:19) printString = '1900000').

    "
     self basicNew testSmallIntegerMultiplication2
    "

    "Modified: / 9.6.1999 / 17:47:56 / cg"
    "Created: / 9.6.1999 / 17:49:45 / cg"
!

testSmallIntegerMultiplication3
    "multiply 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 := 16rFFFF.
    n2 := n1 negated.

    self assert:((n1 * 2) printString = '131070').
    self assert:((n1 perform:'*' asSymbol with:2) printString = '131070').
    self assert:((n2 * 2) printString = '-131070').
    self assert:((n2 perform:'*' asSymbol with:2) printString = '-131070').

    n1 := 16rFFFFFF.
    n2 := n1 negated.

    self assert:((n1 * 2) printString = '33554430').
    self assert:((n1 perform:'*' asSymbol with:2) printString = '33554430').
    self assert:((n2 * 2) printString = '-33554430').
    self assert:((n2 perform:'*' asSymbol with:2) printString = '-33554430').

    n1 := 16r3FFFFFFF.
    n2 := n1 negated.

    self assert:((n1 * 2) printString = '2147483646').
    self assert:((n1 perform:'*' asSymbol with:2) printString = '2147483646').
    self assert:((n2 * 2) printString = '-2147483646').
    self assert:((n2 perform:'*' asSymbol with:2) printString = '-2147483646').

    SmallInteger maxBytes == 4 ifTrue:[
        n1 := 16r3FFFFFFF.
    ] ifFalse:[
        n1 := 16r3FFFFFFFFFFFFFFF.
    ].
    self assert:(n1 class == SmallInteger).
    self assert:((n1 * 2) class == LargeInteger).
    self assert:((n1 perform:'*' asSymbol with:2) class == LargeInteger).

    n1 := SmallInteger maxVal // 11.
    self assert:((n1 * 11) class == SmallInteger).

    n1 := n1 + 1.
    self assert:((n1 * 11) class == LargeInteger).

    "
     self basicNew testSmallIntegerMultiplication3
    "

    "Modified: / 9.6.1999 / 17:47:56 / cg"
    "Created: / 9.6.1999 / 17:49:45 / cg"
! !

!IntegerTest methodsFor:'tests-class protocol'!

testCreationFromBytes1
  "self run: #testCreationFromBytes1"

  " it is illegal for a LargeInteger to be less than SmallInteger maxVal." 
  " here we test that Integer>>byte!!byte2:byte3:byte4: resconstructs SmallInteger maxVal as an instance of SmallInteger. "

   | maxSmallInt hexString byte1 byte2 byte3 byte4 builtInteger |

    maxSmallInt := SmallInteger maxVal.
    hexString := maxSmallInt printStringHex.
    self assert: hexString size = 8.
    Smalltalk isSmalltalkX ifTrue:[
        "/ only Integers support radix-reading
        byte4 := Integer readFrom: (hexString copyFrom: 1 to: 2) base: 16.
        byte3 := Integer readFrom: (hexString copyFrom: 3 to: 4) base: 16.
        byte2 := Integer readFrom: (hexString copyFrom: 5 to: 6) base: 16.
        byte1 := Integer readFrom: (hexString copyFrom: 7 to: 8) base: 16.
    ] ifFalse:[
        byte4 := Number readFrom: (hexString copyFrom: 1 to: 2) base: 16.
        byte3 := Number readFrom: (hexString copyFrom: 3 to: 4) base: 16.
        byte2 := Number readFrom: (hexString copyFrom: 5 to: 6) base: 16.
        byte1 := Number readFrom: (hexString copyFrom: 7 to: 8) base: 16.
    ].
    builtInteger := Integer byte1: byte1 byte2: byte2 byte3: byte3 byte4: byte4.
    self assert: builtInteger = maxSmallInt.
    self assert: builtInteger class = SmallInteger
! !

!IntegerTest methodsFor:'tests-concrete bugs'!

a_rack:rack subrack:subr board:slot port:port channel:chn typeId:aTypeOrSymbol
    "create an Idn from the given arguments
    "
    |hgEnc typ idn
     eqEnc "{ Class:SmallInteger }"
     oid   "{ Class:SmallInteger }"
     IDN|

    IDN := self class.

    eqEnc := rack.

    eqEnc > 0 ifFalse:[
                 eqEnc < 0    ifTrue:[idn := #Dontcare]
        ifFalse:[port == 256  ifTrue:[idn := #NWNode]
        ifFalse:[ idn := #Unspecified ]].

      ^ idn
    ].

    eqEnc >= 255 ifTrue:[       "/ is a logical resource
        eqEnc > 255 ifTrue:[ ^ #Unspecified ].

        slot == 0 ifTrue:[
            subr == 1 ifTrue:[ ^ #ConnectManager ].
            subr == 2 ifTrue:[ ^ #ClockManager   ].
        ].
        oid := 4.                               "/ logical resource
    ] ifFalse:[
        oid := 2.                               "/ equipment
    ].
    hgEnc := 0.
    typ   := aTypeOrSymbol.

    subr ~~ 0 ifTrue:[
        subr > 16r0f  ifTrue:[ ^ #Unspecified ].
        eqEnc := eqEnc bitOr:(subr bitShift: 8).

        slot ~~ 0 ifTrue:[
            slot > 16rff  ifTrue:[ ^ #Unspecified ].
            eqEnc := eqEnc bitOr:(slot bitShift:12).

            port ~~ 0 ifTrue:[
                port > 16rff  ifTrue:[ ^ #Unspecified ].
                eqEnc := eqEnc bitOr:(port bitShift:20).

                chn ~~ 0 ifTrue:[
                    chn > 16rfff  ifTrue:[ ^ #Unspecified ].
                    oid   := 3.
                    typ   := aTypeOrSymbol ? 0.
                    hgEnc := chn.    
                ]
            ]
        ]
    ].

    typ notNil ifTrue:[
        typ isSymbol ifTrue:[
            typ := 0
        ]. 
        hgEnc := hgEnc bitOr:(typ bitShift:12).    
        hgEnc := hgEnc bitOr:(oid bitShift:20).    
    ].            
    ^ #ok.

"
self basicNew rack:1 subrack:3 board:5 port:33 channel:8 typeId:7
"
!

rack:rack subrack:subr board:slot port:port channel:chn typeId:aTypeOrSymbol
    "create an Idn from the given arguments
    "
    |hgEnc typ idn
     eqEnc "{ Class:SmallInteger }"
     oid   "{ Class:SmallInteger }"|

    eqEnc := rack.

"/    eqEnc > 0 ifFalse:[
"/                 eqEnc < 0    ifTrue:[idn := IDN Dontcare]
"/        ifFalse:[port == 256  ifTrue:[idn := IDN NWNode]
"/        ifFalse:[ idn := IDN Unspecified ]].
"/
"/      ^ self fromIdn:idn
"/    ].

"/    eqEnc >= 255 ifTrue:[       "/ is a logical resource
"/        eqEnc > 255 ifTrue:[ ^ self fromIdn:(IDN Unspecified) ].
"/
"/        slot == 0 ifTrue:[
"/            subr == 1 ifTrue:[ ^ self fromIdn:(IDN ConnectManager) ].
"/            subr == 2 ifTrue:[ ^ self fromIdn:(IDN ClockManager)   ].
"/        ].
"/        oid := 4.                               "/ logical resource
"/    ] ifFalse:[
"/        oid := 2.                               "/ equipment
"/    ].
"/    hgEnc := 0.
"/    typ   := aTypeOrSymbol.

    subr ~~ 0 ifTrue:[
        subr > 16r0f  ifTrue:[ ^ nil "self fromIdn:(IDN Unspecified)" ].
        eqEnc := eqEnc bitOr:(subr bitShift: 8).

        slot ~~ 0 ifTrue:[
            slot > 16rff  ifTrue:[ ^ nil "self fromIdn:(IDN Unspecified)" ].
            eqEnc := eqEnc bitOr:(slot bitShift:12).

            port ~~ 0 ifTrue:[
                port > 16rff  ifTrue:[ ^ self fromIdn:(IDN Unspecified) ].
                eqEnc := eqEnc bitOr:(port bitShift:20).

                chn ~~ 0 ifTrue:[
                    chn > 16rfff  ifTrue:[ ^ self fromIdn:(IDN Unspecified) ].
                    oid   := 3.
                    typ   := aTypeOrSymbol ? 0.
                    hgEnc := chn.    
                ]
            ]
        ]
    ].

    typ notNil ifTrue:[
        typ isSymbol ifTrue:[
            typ := (MDT::MDTCType asNumberType:typ) ? 0
        ]. 
        hgEnc := hgEnc bitOr:(typ bitShift:12).    
        hgEnc := hgEnc bitOr:(oid bitShift:20).    
    ].            
    ^ self basicNew eqEncode:eqEnc hgEncode:hgEnc.

"
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'!

version
    ^ '$Header$'
! !