RegressionTests__DictionaryTest.st
changeset 296 ddacf68f6660
child 1055 0d0b2641d00b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RegressionTests__DictionaryTest.st	Mon Jan 23 22:32:59 2006 +0100
@@ -0,0 +1,85 @@
+"{ Package: 'exept:regression' }"
+
+"{ NameSpace: RegressionTests }"
+
+TestCase subclass:#DictionaryTest
+	instanceVariableNames:''
+	classVariableNames:''
+	poolDictionaries:''
+	category:'tests-Regression'
+!
+
+
+!DictionaryTest methodsFor:'testing'!
+
+testAddAll
+	"(self run: #testAddAll)"
+	
+	| dict1 dict2 |
+	dict1 := Dictionary new.
+	dict1 at: #a put:1 ; at: #b put: 2. 
+	dict2 := Dictionary new.
+	dict2 at: #a put: 3 ; at: #c put: 4.
+	dict1 addAll: dict2.
+	self assert: (dict1 at: #a) = 3.
+	self assert: (dict1 at: #b) = 2.
+	self assert: (dict1 at: #c) = 4.
+!
+
+testAssociationsSelect
+
+	"(self selector: #testAssociationsSelect) run"
+
+	| answer d|
+
+	d _ Dictionary new.
+	d at: (Array with: #hello with: #world) put: #fooBar.
+	d at: Smalltalk put: #'Smalltalk is the key'.
+	d at: #Smalltalk put: Smalltalk.
+
+	answer _ d associationsSelect:
+		[:assoc | (assoc key == #Smalltalk) and: [assoc value == Smalltalk]].
+	self should: [answer isKindOf: Dictionary].
+	self should: [answer size == 1].
+	self should: [(answer at: #Smalltalk) == Smalltalk].
+
+	answer _ d associationsSelect:
+		[:assoc | (assoc key == #NoSuchKey) and: [assoc value == #NoSuchValue]].
+	self should: [answer isKindOf: Dictionary].
+	self should: [answer size == 0]
+!
+
+testComma
+	"(self run: #testComma)"
+	
+	| dict1 dict2 dict3 |
+	dict1 := Dictionary new.
+	dict1 at: #a put:1 ; at: #b put: 2. 
+	dict2 := Dictionary new.
+	dict2 at: #a put: 3 ; at: #c put: 4.
+	dict3 := dict1, dict2.
+	self assert: (dict3 at: #a) = 3.
+	self assert: (dict3 at: #b) = 2.
+	self assert: (dict3 at: #c) = 4.
+!
+
+testIncludesAssociation
+	"self debug: #testIncludesAssociation"
+
+	| d |
+	d := Dictionary new 
+		at: #five put: 5; 
+		at: #givemefive put: 5;
+		at: #six put: 6;
+		yourself.
+		
+	self assert: (d includesAssociation: (d associationAt: #five)).
+	self assert: (d includesAssociation: (#five -> 5)).
+	self assert: (d includesAssociation: (#five -> 6)) not.
+! !
+
+!DictionaryTest class methodsFor:'documentation'!
+
+version
+    ^ '$Header$'
+! !