SystemOrganization addCategory: #'AST-Tests-Core'! TestCase subclass: #RBProgramNodeTest instanceVariableNames: 'node' classVariableNames: '' poolDictionaries: '' category: 'AST-Tests-Core'! !RBProgramNodeTest methodsFor: 'accessing' stamp: 'lr 12/29/2009 12:48'! node ^ node ifNil: [ node := RBProgramNode new ]! ! !RBProgramNodeTest methodsFor: 'testing-properties' stamp: 'lr 12/29/2009 12:49'! testHasProperty self deny: (self node hasProperty: #foo). self node propertyAt: #foo put: 123. self assert: (self node hasProperty: #foo)! ! !RBProgramNodeTest methodsFor: 'testing-properties' stamp: 'lr 12/29/2009 12:49'! testPropertyAt self should: [ self node propertyAt: #foo ] raise: Error. self node propertyAt: #foo put: true. self assert: (self node propertyAt: #foo)! ! !RBProgramNodeTest methodsFor: 'testing-properties' stamp: 'lr 12/29/2009 12:49'! testPropertyAtIfAbsent self assert: (self node propertyAt: #foo ifAbsent: [ true ]). self node propertyAt: #foo put: true. self assert: (self node propertyAt: #foo ifAbsent: [ false ])! ! !RBProgramNodeTest methodsFor: 'testing-properties' stamp: 'lr 12/29/2009 12:46'! testPropertyAtIfAbsentPut self assert: (self node propertyAt: #foo ifAbsentPut: [ true ]). self assert: (self node propertyAt: #foo ifAbsentPut: [ false ])! ! !RBProgramNodeTest methodsFor: 'testing-properties' stamp: 'lr 12/29/2009 12:47'! testRemoveProperty self should: [ self node removeProperty: #foo ] raise: Error. self node propertyAt: #foo put: true. self assert: (self node removeProperty: #foo)! ! !RBProgramNodeTest methodsFor: 'testing-properties' stamp: 'lr 12/29/2009 12:47'! testRemovePropertyIfAbsent self assert: (self node removeProperty: #foo ifAbsent: [ true ]). self node propertyAt: #foo put: true. self assert: (self node removeProperty: #foo ifAbsent: [ false ])! ! TestCase subclass: #RBSmallDictionaryTest instanceVariableNames: 'dict' classVariableNames: '' poolDictionaries: '' category: 'AST-Tests-Core'! !RBSmallDictionaryTest methodsFor: 'running' stamp: 'lr 12/29/2009 12:54'! setUp super setUp. dict := RBSmallDictionary new! ! !RBSmallDictionaryTest methodsFor: 'testing' stamp: 'lr 12/29/2009 12:56'! testAtError dict at: #a put: 1. self shouldnt: [ dict at: #a ] raise: Error. self should: [ dict at: #b ] raise: Error! ! !RBSmallDictionaryTest methodsFor: 'testing' stamp: 'lr 12/29/2009 12:56'! testAtIfAbsent dict at: #a put: 666. self assert: (dict at: #a ifAbsent: [ nil ]) = 666. self assert: (dict at: #b ifAbsent: [ nil ]) isNil! ! !RBSmallDictionaryTest methodsFor: 'testing' stamp: 'lr 12/29/2009 13:02'! testAtPut self assert: (dict at: #a put: 3) = 3. self assert: (dict at: #a) = 3. self assert: (dict at: #a put: 4) = 4. self assert: (dict at: #a) = 4. self assert: (dict at: nil put: 5) = 5. self assert: (dict at: nil) = 5 ! ! !RBSmallDictionaryTest methodsFor: 'testing' stamp: 'lr 12/29/2009 13:08'! testCopy | copy | dict at: 'France' put: 'Paris'. dict at: 'Italie' put: 'Rome'. copy := dict copy. copy at: 'Germany' put: 'Berlin'. dict at: 'Switzerland' put: 'Bern'. self assert: copy size = 3. self assert: (copy includesKey: 'Germany'). self deny: (copy includesKey: 'Switzerland'). self assert: dict size = 3. self assert: (dict includesKey: 'Switzerland'). self deny: (dict includesKey: 'Germany') ! ! !RBSmallDictionaryTest methodsFor: 'testing' stamp: 'lr 12/29/2009 13:01'! testEmpty dict at: 'France' put: 'Paris'. dict at: 'Italie' put: 'Rome'. dict empty. self assert: dict isEmpty. self deny: (dict includesKey: 'France'). self deny: (dict includesKey: 'Italie'). self assert: dict keys isEmpty. self assert: dict values isEmpty! ! !RBSmallDictionaryTest methodsFor: 'testing' stamp: 'lr 12/29/2009 12:56'! testIncludesKey dict at: 'Italie' put: nil. dict at: 'France' put: 'Paris'. self assert: (dict includesKey: 'Italie'). self assert: (dict includesKey: 'France'). self deny: (dict includesKey: 'Switzerland')! ! !RBSmallDictionaryTest methodsFor: 'testing' stamp: 'lr 12/29/2009 13:05'! testKeys dict at: 'France' put: 'Paris'. dict at: 'Italie' put: 'Rome'. self assert: dict keys = #('France' 'Italie')! ! !RBSmallDictionaryTest methodsFor: 'testing' stamp: 'lr 12/29/2009 13:04'! testKeysAndValuesDo | keys values | dict at: 'France' put: 'Paris'. dict at: 'Italie' put: 'Rome'. keys := OrderedCollection new. values := OrderedCollection new. dict keysAndValuesDo: [ :key :value | keys add: key. values add: value ]. self assert: keys asArray = #('France' 'Italie'). self assert: values asArray = #('Paris' 'Rome')! ! !RBSmallDictionaryTest methodsFor: 'testing' stamp: 'lr 12/29/2009 13:05'! testKeysDo | keys | dict at: 'France' put: 'Paris'. dict at: 'Italie' put: 'Rome'. keys := OrderedCollection new. dict keysDo: [ :each | keys add: each ]. self assert: keys asArray = #('France' 'Italie')! ! !RBSmallDictionaryTest methodsFor: 'testing' stamp: 'lr 12/29/2009 12:59'! testRemoveKey dict at: #a put: 1. dict at: #b put: 2. self assert: (dict keys size) = 2. self assert: (dict removeKey: #a) = 1. self assert: (dict keys size) = 1. self assert: (dict at: #a ifAbsent: [ true ]). self assert: (dict at: #b) = 2. self should: [ dict removeKey: #a ] raise: Error! ! !RBSmallDictionaryTest methodsFor: 'testing' stamp: 'lr 12/29/2009 13:00'! testRemoveKeyIfAbsent dict at: #a put: 1. dict at: #b put: 2. self assert: (dict keys size) = 2. self assert: (dict removeKey: #a ifAbsent: [ false ]) = 1. self assert: (dict keys size) = 1. self assert: (dict at: #a ifAbsent: [ true ]). self assert: (dict at: #b) = 2. self assert: (dict removeKey: #a ifAbsent: [ true ])! ! !RBSmallDictionaryTest methodsFor: 'testing' stamp: 'lr 12/29/2009 13:05'! testValues dict at: 'France' put: 'Paris'. dict at: 'Italie' put: 'Rome'. self assert: dict values = #('Paris' 'Rome')! ! !RBSmallDictionaryTest methodsFor: 'testing' stamp: 'lr 12/29/2009 13:04'! testValuesDo | values | dict at: 'France' put: 'Paris'. dict at: 'Italie' put: 'Rome'. values := OrderedCollection new. dict valuesDo: [ :each | values add: each ].. self assert: values asArray = #('Paris' 'Rome')! !