'From Squeak3.7alpha of ''11 September 2003'' [latest update: #5657] on 8 February 2004 at 10:50:53 pm'! "Change Set: TestInteger-bg Date: 2 February 2004 Author: Boris Gaertner Peter Wiliam Lount found a problem when he constructed integers from four bytes and Bert Freudenberg published a fix. This test case checks the correct construction of value around SmallInteger maxVal."! TestCase subclass: #IntegerTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Tests-Kernel-Numbers'! !IntegerTest methodsFor: 'testing' stamp: 'BG 2/8/2004 22:49'! 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 hex. hexString := hexString copyFrom:4 to: hexString size. self assert: hexString size = 8. 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: 'testing' stamp: 'BG 2/8/2004 22:49'! testCreationFromBytes2 "self run: #testCreationFromBytes2" " it is illegal for a LargeInteger to be less than SmallInteger maxVal." " here we test that Integer>>byte!!byte2:byte3:byte4: resconstructs (SmallInteger maxVal + 1) as an instance of LargePositiveInteger. " | maxSmallInt hexString byte1 byte2 byte3 byte4 builtInteger | maxSmallInt := SmallInteger maxVal. hexString := (maxSmallInt + 1) hex. hexString := hexString copyFrom:4 to: hexString size. self assert: hexString size = 8. 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 + 1). self deny: builtInteger class = SmallInteger ! ! !IntegerTest methodsFor: 'testing' stamp: 'BG 2/8/2004 22:49'! testCreationFromBytes3 "self run: #testCreationFromBytes3" " it is illegal for a LargeInteger to be less than SmallInteger maxVal." " here we test that Integer>>byte!!byte2:byte3:byte4: resconstructs (SmallInteger maxVal - 1) as an instance of SmallInteger. " | maxSmallInt hexString byte1 byte2 byte3 byte4 builtInteger | maxSmallInt := SmallInteger maxVal. hexString := (maxSmallInt - 1) hex. hexString := hexString copyFrom:4 to: hexString size. self assert: hexString size = 8. 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 - 1). self assert: builtInteger class = SmallInteger ! !