[BUG][FIX][TEST] TextFontChange>>hash

Mike Roberts mike at mjr104.co.uk
Sun Aug 17 19:43:23 UTC 2003


TextFontChange defines = but does not provide hash.  This causes various problems when using them with Sets.  This change set hopefully fixes this and supplies a simple test.

Cheers
Mike

--T4sUOijqQbZv57TR
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="TextFontChangeHashBugFixTest-mjr.1.cs"

'From Squeak3.6beta of ''4 July 2003'' [latest update: #5395] on 17 August 2003 at 8:37:16 pm'!
"Change Set:		TextFontChangeHashBugFixTest-mjr
Date:			17 August 2003
Author:			Mike Roberts

TextFontChange defines = but does not provide hash.  This causes various problems when using them with Sets.  This change set hopefully fixes this and supplies a simple test."!

TestCase subclass: #TextFontChangeTest
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Tests-Collections-Text'!

!TextFontChange methodsFor: 'as yet unclassified' stamp: 'mjr 8/17/2003 20:13'!
hash
	^ fontNumber hash! !


!TextFontChangeTest methodsFor: 'as yet unclassified' stamp: 'mjr 8/17/2003 20:29'!
testEquality
	"Check that different instances of the same TextFontChange are equal"
	self assert: TextFontChange defaultFontChange = TextFontChange defaultFontChange.
	self assert: TextFontChange font1 = TextFontChange font1.
	self assert: TextFontChange font2 = TextFontChange font2.
	self assert: TextFontChange font3 = TextFontChange font3.
	self assert: TextFontChange font4 = TextFontChange font4.
	self assert: (TextFontChange fontNumber: 6)
			= (TextFontChange fontNumber: 6)! !

!TextFontChangeTest methodsFor: 'as yet unclassified' stamp: 'mjr 8/17/2003 20:16'!
testHash
	"test that different instances of the same TextFontChange hash to the 
	same value"
	| hashes hash |
	hashes _ OrderedCollection new.
	1
		to: 100
		do: [:i | hashes add: TextFontChange defaultFontChange hash].
	hash _ hashes at: 1.
	2
		to: 100
		do: [:i | self assert: (hashes at: i)
					= hash]! !


More information about the Squeak-dev mailing list