!STB 0 F Package6String Sample Testsr9C:\DEV\Dolphin Smalltalk 98 2.1\Packages\Sample Tests.pacrThis package contains some sample test case classes for use with Kent Beck's testing framework. The following test cases are included: ErrorTestCase - Deliberately creates both a 'Failure' and an 'Error' NoErrorTestCase - Has no errors OrderedCollectionTestCase - A subset of a test case for OrderedCollection, has deliberate errors. SetTestCase - A subset of a test case for Set, has deliberate errors.STBCollectionProxy STBClassProxyr IdentitySet&ArraySTBSymbolProxyr SetTestCase*r ErrorTestCase*rOrderedCollectionTestCase*rNoErrorTestCaserSet AssociationrTestSuite class*r errorExamplerTestSuite class*rrunErrorExamplerTestSuite class*rrunNoErrorExamplerTestSuite class*r runSetExamplerTestSuite class*rnoErrorExamplerTestSuite class*r setExamplerTestingFrameworkrDolphinSTBIdentityDictionaryProxyrIdentityDictionary*r preinstallr*r postinstallP*r postuninstallP*r preuninstallP TestCase subclass: #ErrorTestCase instanceVariableNames: 'full empty' classVariableNames: '' poolDictionaries: ''! TestCase subclass: #NoErrorTestCase instanceVariableNames: 'full empty' classVariableNames: '' poolDictionaries: ''! TestCase subclass: #OrderedCollectionTestCase instanceVariableNames: 'empty full' classVariableNames: '' poolDictionaries: ''! TestCase subclass: #SetTestCase instanceVariableNames: 'full empty' classVariableNames: '' poolDictionaries: ''! 'end-class-definition'! X ErrorTestCase class instanceVariableNames: ''! ErrorTestCase comment: ''! !ErrorTestCase categoriesForClass!Testing Framework! ! !ErrorTestCase methodsFor! setUp empty := Set new. full := Set with: 5 with: #abc! testAdd empty add: 5. self should: [empty includes: 5]! testError empty at: 2 put: 'foo'! testFailure "This case is here to test the testing machinery only." self should: [false]! testGrow empty addAll: (1 to: 100). self should: [empty size = 100]! testIllegal self should: [empty at: 5] raise: Error. self should: [empty at: 5 put: #abc] raise: Error! testIncludes self should: [full includes: 5]. self should: [full includes: #abc]! testOccurrences self should: [(empty occurrencesOf: 0) = 0]. self should: [(full occurrencesOf: 5) = 1]. full add: 5. self should: [(full occurrencesOf: 5) = 1]! testRemove full remove: 5. self should: [full includes: #abc]. self shouldnt: [full includes: 5]! ! !ErrorTestCase categoriesFor: #setUp!set up! ! !ErrorTestCase categoriesFor: #testAdd!running!tests! ! !ErrorTestCase categoriesFor: #testError!running!tests! ! !ErrorTestCase categoriesFor: #testFailure!running!tests! ! !ErrorTestCase categoriesFor: #testGrow!running!tests! ! !ErrorTestCase categoriesFor: #testIllegal!running!tests! ! !ErrorTestCase categoriesFor: #testIncludes!running!tests! ! !ErrorTestCase categoriesFor: #testOccurrences!running!tests! ! !ErrorTestCase categoriesFor: #testRemove!running!tests! ! NoErrorTestCase class instanceVariableNames: ''! NoErrorTestCase comment: ''! !NoErrorTestCase categoriesForClass!Testing Framework! ! !NoErrorTestCase methodsFor! setUp empty := Set new. full := Set with: 5 with: #abc! testAdd empty add: 5. self should: [empty includes: 5]! testGrow empty addAll: (1 to: 100). self should: [empty size = 100]! testIncludes self should: [full includes: 5]. self should: [full includes: #abc]! testOccurrences self should: [(empty occurrencesOf: 0) = 0]. self should: [(full occurrencesOf: 5) = 1]. full add: 5. self should: [(full occurrencesOf: 5) = 1]! testRemove full remove: 5. self should: [full includes: #abc]. self shouldnt: [full includes: 5]! ! !NoErrorTestCase categoriesFor: #setUp!set up! ! !NoErrorTestCase categoriesFor: #testAdd!running!tests! ! !NoErrorTestCase categoriesFor: #testGrow!running!tests! ! !NoErrorTestCase categoriesFor: #testIncludes!running!tests! ! !NoErrorTestCase categoriesFor: #testOccurrences!running!tests! ! !NoErrorTestCase categoriesFor: #testRemove!running!tests! ! OrderedCollectionTestCase class instanceVariableNames: ''! OrderedCollectionTestCase comment: ''! !OrderedCollectionTestCase categoriesForClass!No category! ! !OrderedCollectionTestCase methodsFor! setUp empty := OrderedCollection new. full := OrderedCollection with: 5 with: #abc! testAdd empty add: 5. self should: [empty includes: 5]! testError 2 + 'abc'! testFailure "This case is here to test the testing machinery only." self should: [false]! ! !OrderedCollectionTestCase categoriesFor: #setUp!set up! ! !OrderedCollectionTestCase categoriesFor: #testAdd!running!tests! ! !OrderedCollectionTestCase categoriesFor: #testError!running!tests! ! !OrderedCollectionTestCase categoriesFor: #testFailure!running!tests! ! SetTestCase class instanceVariableNames: ''! SetTestCase comment: ''! !SetTestCase categoriesForClass!Testing Framework! ! !SetTestCase methodsFor! setUp empty := Set new. full := Set with: 5 with: #abc! testAdd empty add: 5. self should: [empty includes: 5]! testError empty at: 2 put: 'foo'! testFailure "This case is here to test the testing machinery only." self should: [false]! testGrow empty addAll: (1 to: 100). self should: [empty size = 100]! testIllegal self should: [empty at: 5] raise: Error. self should: [empty at: 5 put: #abc] raise: Error! testIncludes self should: [full includes: 5]. self should: [full includes: #abc]! testOccurrences self should: [(empty occurrencesOf: 0) = 0]. self should: [(full occurrencesOf: 5) = 1]. full add: 5. self should: [(full occurrencesOf: 5) = 1]! testRemove full remove: 5. self should: [full includes: #abc]. self shouldnt: [full includes: 5]! ! !SetTestCase categoriesFor: #setUp!set up! ! !SetTestCase categoriesFor: #testAdd!running!tests! ! !SetTestCase categoriesFor: #testError!running!tests! ! !SetTestCase categoriesFor: #testFailure!running!tests! ! !SetTestCase categoriesFor: #testGrow!running!tests! ! !SetTestCase categoriesFor: #testIllegal!running!tests! ! !SetTestCase categoriesFor: #testIncludes!running!tests! ! !SetTestCase categoriesFor: #testOccurrences!running!tests! ! !SetTestCase categoriesFor: #testRemove!running!tests! ! !TestSuite class methodsFor! errorExample "TestSuite errorExample" | test | test := self named: 'Error Example'. test addTestCases: ErrorTestCase testCases. ^test! ! !TestSuite class categoriesFor: #errorExample!no category! ! !TestSuite class methodsFor! noErrorExample "TestSuite noErrorExample" | test | test := self named: 'No Error Example'. test addTestCases: NoErrorTestCase testCases. ^test! ! !TestSuite class categoriesFor: #noErrorExample!no category! ! !TestSuite class methodsFor! runErrorExample " TestSuite runErrorExample " ^ self errorExample run! ! !TestSuite class categoriesFor: #runErrorExample!no category! ! !TestSuite class methodsFor! runNoErrorExample " TestSuite runNoErrorExample " ^ self noErrorExample run! ! !TestSuite class categoriesFor: #runNoErrorExample!no category! ! !TestSuite class methodsFor! runSetExample ^self setExample run! ! !TestSuite class categoriesFor: #runSetExample!examples! ! !TestSuite class methodsFor! setExample "self setExample" | test | test := self named: 'Set Example'. test addTestCases: SetTestCase testCases. ^test! ! !TestSuite class categoriesFor: #setExample!examples! !