RegressionTests__IntegerTest.st
author Claus Gittinger <cg@exept.de>
Sun, 06 Jun 1999 16:38:15 +0200
changeset 28 fca649220051
parent 27 8386e8469cdf
child 29 cedaa7d102d6
permissions -rw-r--r--
checkin from browser

Object subclass:#IntegerTest
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'Tests - Numbers'
!


!IntegerTest class methodsFor:'misc'!

testPlus1_a:arg
    ^ arg + 1

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

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

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

!IntegerTest class methodsFor:'private'!

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

test:aBlock
    aBlock value == true ifFalse:[
        self halt:'test failed'
    ]
! !

!IntegerTest class methodsFor:'tests'!

test1
    "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 test:[minVal == self num_smallInt_minVal].
    self test:[maxVal == self num_smallInt_maxVal].

    self test:[minVal == SmallInteger minVal].
    self test:[maxVal == SmallInteger maxVal].

    t := SmallInteger perform:('maxBytes' asSymbol).
    self test:[t == SmallInteger maxBytes].
    t := SmallInteger perform:('maxBits' asSymbol).
    self test:[t == SmallInteger maxBits].

    self testPrinting1.

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

    "arithmetic overFlow checks"

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

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

    "LargeInt op -> SmallInt result"
    t := maxVal + 1.
    self test:[t - 1 == maxVal].
    t := minVal - 1.
    self test:[t + 1 == minVal].

    self testSmallIntegerArithmetic.
    self testLiteralNumbers.
    self testLargeAddition.
    self testLargeMultiplication.
    self testLargeDivision.

    "
     self test1
    "

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

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 test:[(20 factorial + 20 factorial) printString = '4865804016353280000'].
    self test:[(20 factorial + 1) printString = '2432902008176640001'].
    self test:[(20 factorial + 1000) printString = '2432902008176641000'].

    "Large - Large addition"

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

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

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

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

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

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

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

    "
     self testLargeAddition
    "

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

testLargeDivision
    |t|

    t := 20 factorial.

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


    t := 20 factorial.

    self test:[t printString = '2432902008176640000'].
    self test:[t \\ 1000 == 0].
    t := t // 1000.
    self test:[t printString = '2432902008176640'].
    self test:[t \\ 1000 == 640].
    t := t // 1000.
    self test:[t printString = '2432902008176'].
    self test:[t \\ 1000 == 176].
    t := t // 1000.
    self test:[t printString = '2432902008'].
    self test:[t \\ 1000 == 8].
    t := t // 1000.
    self test:[t printString = '2432902'].
    self test:[t \\ 1000 == 902].
    t := t // 1000.
    self test:[t printString = '2432'].
    self test:[t \\ 1000 == 432].
    t := t // 1000.
    self test:[t == 2].
    self test:[t \\ 1000 == 2].


    t := 20 factorial.

    "Large // SmallInt division"
    t := t // 20.
    self test:[t printString = 19 factorial printString].
    t := t // 19.
    self test:[t printString = 18 factorial printString].
    t := t // 18.
    self test:[t printString = 17 factorial printString].
    t := t // 17.
    self test:[t printString = 16 factorial printString].
    t := t // 16.
    self test:[t printString = 15 factorial printString].
    t := t // 15.
    self test:[t printString = 14 factorial printString].
    t := t // 14.
    self test:[t printString = 13 factorial printString].
    t := t // 13.
    self test:[t printString = 12 factorial printString].
    t := t // 12.
    self test:[t printString = 11 factorial printString].
    t := t // 11.
    self test:[t printString = 10 factorial printString].
    self test:[t == 10 factorial].

    t := 20 factorial.
    t := t + 21 factorial.
    t absSubtract:21 factorial.
    self test:[t compressed = 20 factorial].

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

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

    "
     self testLargeDivision
    "

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

testLargeMultiplication
    |t1|

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

    t1 := 1000.
    self test:[t1 * t1 == 1000000].
    self test:[(t1 perform:'*' asSymbol with:t1) == 1000000].
    self test:[(t1 * t1) printString = '1000000'].
    self test:[(t1 perform:'*' asSymbol with:t1) printString = '1000000'].

    t1 := 10000.
    self test:[t1 * t1 == 100000000].
    self test:[(t1 perform:'*' asSymbol with:t1) == 100000000].
    self test:[(t1 * t1) printString = '100000000'].
    self test:[(t1 perform:'*' asSymbol with:t1) printString = '100000000'].

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

    self test:[(t1 * t1) printString = '10000000000'].
    self test:[(t1 perform:'*' asSymbol with:t1) printString = '10000000000'].

    t1 := 1000000.
    self test:[(t1 * t1) printString = '1000000000000'].
    self test:[(t1 perform:'*' asSymbol with:t1) printString = '1000000000000'].

    t1 := 10000000.
    self test:[(t1 * t1) printString = '100000000000000'].
    self test:[(t1 perform:'*' asSymbol with:t1) printString = '100000000000000'].

    t1 := 100000000.
    self test:[(t1 * t1) printString = '10000000000000000'].
    self test:[(t1 perform:'*' asSymbol with:t1) printString = '10000000000000000'].

    t1 := 1000000000.
    self test:[(t1 * t1) printString = '1000000000000000000'].
    self test:[(t1 perform:'*' asSymbol with:t1) printString = '1000000000000000000'].


    "Large * SmallInt multiplication"
    self test:[10 factorial printString = '3628800'].
    self test:[20 factorial printString = '2432902008176640000'].
    self test:[100 factorial printString = '93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000'].
    self test:[1000 factorial printString = '402387260077093773543702433923003985719374864210714632543799910429938512398629020592044208486969404800479988610197196058631666872994808558901323829669944590997424504087073759918823627727188732519779505950995276120874975462497043601418278094646496291056393887437886487337119181045825783647849977012476632889835955735432513185323958463075557409114262417474349347553428646576611667797396668820291207379143853719588249808126867838374559731746136085379534524221586593201928090878297308431392844403281231558611036976801357304216168747609675871348312025478589320767169132448426236131412508780208000261683151027341827977704784635868170164365024153691398281264810213092761244896359928705114964975419909342221566832572080821333186116811553615836546984046708975602900950537616475847728421889679646244945160765353408198901385442487984959953319101723355556602139450399736280750137837615307127761926849034352625200015888535147331611702103968175921510907788019393178114194545257223865541461062892187960223838971476088506276862967146674697562911234082439208160153780889893964518263243671616762179168909779911903754031274622289988005195444414282012187361745992642956581746628302955570299024324153181617210465832036786906117260158783520751516284225540265170483304226143974286933061690897968482590125458327168226458066526769958652682272807075781391858178889652208164348344825993266043367660176999612831860788386150279465955131156552036093988180612138558600301435694527224206344631797460594682573103790084024432438465657245014402821885252470935190620929023136493273497565513958720559654228749774011413346962715422845862377387538230483865688976461927383814900140767310446640259899490222221765904339901886018566526485061799702356193897017860040811889729918311021171229845901641921068884387121855646124960798722908519296819372388642614839657382291123125024186649353143970137428531926649875337218940694281434118520158014123344828015051399694290153483077644569099073152433278288269864602789864321139083506217095002597389863554277196742822248757586765752344220207573630569498825087968928162753848863396909959826280956121450994871701244516461260379029309120889086942028510640182154399457156805941872748998094254742173582401063677404595741785160829230135358081840096996372524230560855903700624271243416909004153690105933983835777939410970027753472000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'].

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

    "
     self testLargeMultiplication
    "

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

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

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

    self test:[self num_00000FFFFFFFFFFFE hexPrintString = 'FFFFFFFFFFFE'].
    self test:[self num_00000FFFFFFFFFFFC hexPrintString = 'FFFFFFFFFFFC'].
    self test:[self num_00000FFFFFFFFFFF8 hexPrintString = 'FFFFFFFFFFF8'].
    self test:[self num_00000FFFFFFFFFFF0 hexPrintString = 'FFFFFFFFFFF0'].
    self test:[self num_00000FFFFFFFFFFE0 hexPrintString = 'FFFFFFFFFFE0'].
    self test:[self num_00000FFFFFFFFFFC0 hexPrintString = 'FFFFFFFFFFC0'].
    self test:[self num_00000FFFFFFFFFF80 hexPrintString = 'FFFFFFFFFF80'].
    self test:[self num_00000FFFFFFFFFF00 hexPrintString = 'FFFFFFFFFF00'].

    self test:[self num_0000000000FFF0000 hexPrintString = 'FFF0000'].

    "
     self testLiteralNumbers
    "

    "Modified: / 4.6.1999 / 18:41:09 / cg"
!

testPrinting1
    self test:[10 printString = '10'].
    self test:[100 printString = '100'].
    self test:[1000 printString = '1000'].
    self test:[10000 printString = '10000'].
    self test:[100000 printString = '100000'].
    self test:[1000000 printString = '1000000'].
    self test:[10000000 printString = '10000000'].
    self test:[100000000 printString = '100000000'].
    self test:[1000000000 printString = '1000000000'].
    self test:[10000000000 printString = '10000000000'].
    self test:[100000000000 printString = '100000000000'].
    self test:[1000000000000 printString = '1000000000000'].
    self test:[10000000000000 printString = '10000000000000'].
    self test:[100000000000000 printString = '100000000000000'].
    self test:[1000000000000000 printString = '1000000000000000'].
    self test:[10000000000000000 printString = '10000000000000000'].
    self test:[100000000000000000 printString = '100000000000000000'].

    "
     self testPrinting1
    "
!

testReading1
    |t|

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

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

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

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

    "
     self 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 test:[1 printString = '1'].
    self test:[10 printString = '10'].
    self test:[100 printString = '100'].
    self test:[1000 printString = '1000'].
    self test:[10000 printString = '10000'].
    self test:[100000 printString = '100000'].

    "addition with overflow"

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

    self test:[(n1 + 1) class == LargeInteger].
    t := n1 + 1.
    self test:[(t - 1) class == SmallInteger].

    self test:[(n2 - 1) class == LargeInteger].
    t := n2 - 1.
    self test:[(t + 1) class == SmallInteger].

    self test:[(n1 negated) class == SmallInteger].
    self test:[(n2 negated) class == LargeInteger].
    self test:[(n1 perform:'negated' asSymbol) class == SmallInteger].
    self test:[(n2 perform:'negated' asSymbol) class == LargeInteger].

    self test:[(n1 abs == n1)].
    self test:[(n2 abs = n2 negated)].
    self test:[(n1 perform:'abs' asSymbol) == n1].
    self test:[(n2 perform:'abs' asSymbol) = n2 negated].

    "
     self testSmallIntegerArithmetic
    "

    "Created: / 6.6.1999 / 14:47:51 / cg"
    "Modified: / 6.6.1999 / 16:36:44 / cg"
! !

!IntegerTest class methodsFor:'documentation'!

version
    ^ '$Header$'
! !