Andreas Raab uploaded a new version of CollectionsTests to project The Trunk:
http://source.squeak.org/trunk/CollectionsTests-ar.138.mcz ==================== Summary ==================== Name: CollectionsTests-ar.138 Author: ar Time: 2 February 2010, 1:07:16.819 am UUID: 5f83525f-df0c-5d4a-a7b0-c0a1ede3c8f3 Ancestors: CollectionsTests-ar.137 Remove unnecessary use of traits in ReadStreamTest. Makes it possible to load CollectionTests into images w/o traits support. =============== Diff against CollectionsTests-ar.137 =============== Item was added: + ----- Method: ReadStreamTest>>testUpTo (in category 'tests - accessing') ----- + testUpTo + | returnValue stream | + returnValue := (self emptyStream upTo: nil). + self assert: returnValue isCollection. + self assert: returnValue isEmpty. + + stream := self streamOnArray. + returnValue := stream upTo: #(a b c). + self assert: returnValue = #(1). + self assert: stream peek = false. + + stream := self streamOnArray. + returnValue := stream upTo: true. + self assert: returnValue = #(1 #(a b c) false). + self assert: stream atEnd.! Item was added: + ----- Method: ReadStreamTest>>testReset (in category 'tests - positioning') ----- + testReset + | stream | + + stream := self emptyStream. + stream reset. + self assert: stream position = 0. + + stream := self streamOnArray. + stream reset. + self assert: stream position = 0. + self deny: stream atEnd. + stream position: 3. + self assert: stream atEnd. + stream reset. + self assert: stream position = 0.! Item was added: + ----- Method: ReadStreamTest>>testBackUpToEmptyPattern1 (in category 'tests - positioning') ----- + testBackUpToEmptyPattern1 + "This test represents the current behavior which is not clearly defined and could be revised." + |stream| + stream := ReadStream on: 'abcdabg'. + stream setToEnd. + self should: [stream backUpTo: ''] raise: Error.! Item was added: + ----- Method: ReadStreamTest>>testBackUpTo1 (in category 'tests - positioning') ----- + testBackUpTo1 + |stream| + stream := ReadStream on: 'abcdabg'. + stream setToEnd. + self assert: (stream backUpTo: 'ab'). + self assert: stream peek = $g! Item was added: + ----- Method: ReadStreamTest>>testPeek2 (in category 'tests - accessing') ----- + testPeek2 + | stream | + stream := self streamOn: #(nil nil nil). + + self assert: stream peek isNil. + stream next. + self assert: stream peek isNil. + stream next. + self assert: stream peek isNil. + stream next. + + "Yes, #peek answers nil when there is no more element to read." + self assert: stream peek isNil.! Item was added: + ----- Method: ReadStreamTest>>testNext (in category 'tests - accessing') ----- + testNext + |stream| + + stream := self streamOnArray. + self assert: stream next = 1. + self assert: stream next = #(a b c). + self assert: stream next = false. + + stream := self streamOnString. + self assert: stream next = $a. + self assert: stream next = $b. + self assert: stream next = $c. + self assert: stream next = $d. + self assert: stream next = $e. + ! Item was added: + ----- Method: ReadStreamTest>>testNextMatchFor (in category 'tests - testing') ----- + testNextMatchFor + | stream | + stream := self streamOnArray. + self assert: (stream nextMatchFor: 1). + self assert: (stream nextMatchFor: #(a b c)). + self assert: (stream nextMatchFor: false). + + stream := self streamOnArray. + self deny: (stream nextMatchFor: false). + self assert: (stream nextMatchFor: #(a b c)). + self assert: (stream nextMatchFor: false). + ! Item was added: + ----- Method: ReadStreamTest>>testDo (in category 'tests - enumerating') ----- + testDo + self emptyStream do: [:value | self fail]! Item was added: + ----- Method: ReadStreamTest>>streamOn: (in category 'helpers') ----- + streamOn: aCollection + ^ self classUnderTest on: aCollection! Item was added: + ----- Method: ReadStreamTest>>testDo2 (in category 'tests - enumerating') ----- + testDo2 + | stream string | + stream := self streamOnArray. + string := String new. + + stream do: [:value | string := string, ' ', value asString]. + + self assert: string = (' ', 1 asString, ' ', #(a b c) asString, ' ', false asString)! Item was added: + ----- Method: ReadStreamTest>>testSkipTo (in category 'tests - positionning') ----- + testSkipTo + | stream | + stream := self emptyStream. + self deny: (stream skipTo: nil). + + stream := self streamOnArray. + self deny: stream atEnd. + self deny: (stream skipTo: nil). + self assert: stream atEnd. + + stream := self streamOnArray. + self assert: stream peek = 1. + self assert: (stream skipTo: #(a b c)). + self assert: stream peek = false. + self assert: (stream skipTo: false). + self assert: stream atEnd.! Item was added: + ----- Method: ReadStreamTest>>testPosition (in category 'tests - positioning') ----- + testPosition + | stream | + self assert: self emptyStream position isZero. + + stream := self streamOnArray. + self assert: stream position = 0. + stream next. + self assert: stream position = 1. + stream next. + self assert: stream position = 2. + stream next. + self assert: stream position = 3. + stream next. + self assert: stream position = 3. + stream next. + self assert: stream position = 3.! Item was added: + ----- Method: ReadStreamTest>>testOldBack (in category 'tests - back') ----- + testOldBack + "Test the old behavior of the method back. The method #oldBack is a misconception about what a stream is. A stream contains a pointer *between* elements with past and future elements. The method #oldBack considers that the pointer is *on* an element. (Damien Cassou - 1 August 2007)" + |stream| + stream := self streamOn: 'abc'. + stream next: 2. + self assert: stream oldBack = $a.! Item was added: + ----- Method: ReadStreamTest>>testContents (in category 'tests - accessing') ----- + testContents + | stream | + self assert: self emptyStream contents = ''. + + stream := self streamOnArray. + self assert: stream contents = #(1 #(a b c) false). + stream position: 3. + self assert: stream contents = #(1 #(a b c) false). + + stream := self streamOnString. + self assert: stream contents = 'abcde'. + stream setToEnd. + self assert: stream contents = 'abcde'.! Item was added: + ----- Method: ReadStreamTest>>testNexts2 (in category 'tests - accessing') ----- + testNexts2 + + | stream | + stream := self streamOnArray. + self assert: (stream next: 2) = #(1 #(a b c)). + self assert: (stream next: 1) = #(false).! Item was added: + ----- Method: ReadStreamTest>>testOldBackOnPosition1 (in category 'tests - back') ----- + testOldBackOnPosition1 + "Test the old behavior of the method back. The method #oldBack is a misconception about what a stream is. A stream contains a pointer *between* elements with past and future elements. The method #oldBack considers that the pointer is *on* an element. (Damien Cassou - 1 August 2007)" + |stream| + stream := self streamOn: 'abc'. + stream next. + self assert: stream oldBack = nil.! Item was added: + ----- Method: ReadStreamTest>>testNexts (in category 'tests - accessing') ----- + testNexts + self assert: (self emptyStream next: 0) isEmpty. + self assert: (self streamOnArray next: 0) isEmpty. + self assert: (self streamOnArray next: 1) = #(1). + self assert: (self streamOnArray next: 2) = #(1 #(a b c)). + self assert: (self streamOnArray next: 3) = #(1 #(a b c) false).! Item was changed: + ClassTestCase subclass: #ReadStreamTest - TestCase subclass: #ReadStreamTest - uses: TReadStreamTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'CollectionsTests-Streams'! !ReadStreamTest commentStamp: 'tlk 12/5/2004 14:36' prior: 0! I am an SUnit test for ReadStream. I have no test fixtures.! - ReadStreamTest class - uses: TReadStreamTest classTrait - instanceVariableNames: ''! Item was added: + ----- Method: ReadStreamTest>>testSetToEnd (in category 'tests - positioning') ----- + testSetToEnd + | stream | + + stream := self emptyStream. + stream setToEnd. + self assert: stream atEnd. + + stream := self streamOnArray. + stream setToEnd. + self assert: stream atEnd. + stream position: 1. + self deny: stream atEnd. + stream setToEnd. + self assert: stream atEnd.! Item was added: + ----- Method: ReadStreamTest>>testSetPosition (in category 'tests - positioning') ----- + testSetPosition + | stream | + + stream := self emptyStream. + self should: [stream position: -2] raise: Error. + self shouldnt: [stream position: 0] raise: Error. + + stream := self streamOnArray. + self should: [stream position: -1] raise: Error. + self shouldnt: [stream position: 0] raise: Error. + self shouldnt: [stream position: 1] raise: Error. + self shouldnt: [stream position: 2] raise: Error. + + "According to ANSI Smalltalk Standard 1.9 Draft, the following should be tested too: + self should: [stream position: 3] raise: Error. + + However, I don't see the point of raising an error when positioning at the end. + + I prefer testing the absence of error: + " + self shouldnt: [stream position: 3] raise: Error. + self should: [stream position: 4] raise: Error.! Item was added: + ----- Method: ReadStreamTest>>testSkipTo2 (in category 'tests - positionning') ----- + testSkipTo2 + | stream | + + stream := self streamOnString. + self assert: (stream skipTo: $b). + self assert: stream peek = $c. + self assert: (stream skipTo: $d). + self assert: stream peek = $e. + self assert: (stream skipTo: $e). + self assert: stream atEnd.! Item was added: + ----- Method: ReadStreamTest>>testBackOnPosition1 (in category 'tests - back') ----- + testBackOnPosition1 + "Test the new implemtation of the method back." + |stream| + stream := self streamOn: 'abc'. + stream next. + self assert: stream back = $a.! Item was added: + ----- Method: ReadStreamTest>>testAtEnd (in category 'tests - testing') ----- + testAtEnd + | stream | + self assert: self emptyStream atEnd. + + stream := self streamOnArray. + self deny: stream atEnd. + stream next: 3. + self assert: stream atEnd.! Item was added: + ----- Method: ReadStreamTest>>testNew (in category 'tests - instance creation') ----- + testNew + self should: [self classUnderTest new] raise: Error.! Item was added: + ----- Method: ReadStreamTest>>testBack (in category 'tests - back') ----- + testBack + "Test the new implemtation of the method back." + |stream| + stream := self streamOn: 'abc'. + stream next: 2. + self assert: stream back = $b.! Item was added: + ----- Method: ReadStreamTest>>testOn (in category 'tests - instance creation') ----- + testOn + self shouldnt: [self streamOn: ' '] raise: Error. + self assert: (self streamOn: ' ') position isZero.! Item was added: + ----- Method: ReadStreamTest>>testBackUpToPatternNotFound1 (in category 'tests - positioning') ----- + testBackUpToPatternNotFound1 + |stream| + stream := ReadStream on: 'abcdabg'. + stream setToEnd. + self deny: (stream backUpTo: 'zz'). + self assert: stream position = 0! Item was added: + ----- Method: ReadStreamTest>>testUpTo2 (in category 'tests - accessing') ----- + testUpTo2 + | returnValue stream | + + stream := self streamOnString. + returnValue := stream upTo: $d. + self assert: returnValue = 'abc'. + self assert: stream peek = $e.! Item was added: + ----- Method: ReadStreamTest>>testPeekFor2 (in category 'tests - testing') ----- + testPeekFor2 + | stream negative number | + + stream := self streamOn: '- 145'. + negative := stream peekFor: $-. + stream peekFor: Character space. + number := stream next: 3. + self assert: negative. + self assert: number = '145'. + + stream := self streamOn: '-145'. + negative := stream peekFor: $-. + stream peekFor: Character space. + number := stream next: 3. + self assert: negative. + self assert: number = '145'. + + stream := self streamOn: ' 145'. + negative := stream peekFor: $-. + stream peekFor: Character space. + number := stream next: 3. + self deny: negative. + self assert: number = '145'. + + stream := self streamOn: '145'. + negative := stream peekFor: $-. + stream peekFor: Character space. + number := stream next: 3. + self deny: negative. + self assert: number = '145'.! Item was added: + ----- Method: ReadStreamTest>>testContents2 (in category 'tests - accessing') ----- + testContents2 + "From ANSI Smalltalk Standard draft 1.9: + + it is unspecified whether or not the returned collection [using #contents] is the same object as the backing store collection. However, if the returned collection is not the same object as the stream backing store collection then the class of the returned collection is the same class as would be returned if the message #select: was sent to the backing store collection." + + "In Squeak, there is #species to know what class should be used on copy, selection..." + | interval stream streamContents | + interval := 1 to: 32. + stream := self streamOn: interval. + streamContents := stream contents. + + (streamContents == interval) + ifFalse: [self assert: streamContents class = Interval new species]! Item was added: + ----- Method: ReadStreamTest>>testPeek (in category 'tests - accessing') ----- + testPeek + | stream | + stream := self streamOnArray. + + self assert: stream peek = 1. + self deny: stream peek = #(a b c). + self deny: stream peek = false. + + stream next. + + self deny: stream peek = 1. + self assert: stream peek = #(a b c). + self deny: stream peek = false. + + stream next. + + self deny: stream peek = 1. + self deny: stream peek = #(a b c). + self assert: stream peek = false. + + stream next. + + "In ANSI Smalltalk Standard Draft, it is said that nil will return nil at the end when using #peek." + self assert: stream peek isNil.! Item was added: + ----- Method: ReadStreamTest>>testPeekFor (in category 'tests - testing') ----- + testPeekFor + | stream | + + stream := self streamOnArray. + self assert: (stream peekFor: 1). + self assert: (stream peekFor: #(a b c)). + self assert: (stream peekFor: false). + + stream := self streamOnArray. + self deny: (stream peekFor: #(a b c)). + self deny: (stream peekFor: false). + self assert: (stream peekFor: 1). + + self deny: (stream peekFor: 1). + self deny: (stream peekFor: false). + self assert: (stream peekFor: #(a b c)). + + self deny: (stream peekFor: 1). + self deny: (stream peekFor: #(a b c)). + self assert: (stream peekFor: false). + + self assert: (stream atEnd). + self deny: (stream peekFor: nil). + self deny: (stream peekFor: 1). + self deny: (stream peekFor: #(a b c)). + self deny: (stream peekFor: false).! Item was removed: - ----- Method: TGettableStreamTest>>testPeek (in category 'tests - accessing') ----- - testPeek - | stream | - stream := self streamOnArray. - - self assert: stream peek = 1. - self deny: stream peek = #(a b c). - self deny: stream peek = false. - - stream next. - - self deny: stream peek = 1. - self assert: stream peek = #(a b c). - self deny: stream peek = false. - - stream next. - - self deny: stream peek = 1. - self deny: stream peek = #(a b c). - self assert: stream peek = false. - - stream next. - - "In ANSI Smalltalk Standard Draft, it is said that nil will return nil at the end when using #peek." - self assert: stream peek isNil.! Item was removed: - ----- Method: TGettableStreamTest>>testPeekFor (in category 'tests - testing') ----- - testPeekFor - | stream | - - stream := self streamOnArray. - self assert: (stream peekFor: 1). - self assert: (stream peekFor: #(a b c)). - self assert: (stream peekFor: false). - - stream := self streamOnArray. - self deny: (stream peekFor: #(a b c)). - self deny: (stream peekFor: false). - self assert: (stream peekFor: 1). - - self deny: (stream peekFor: 1). - self deny: (stream peekFor: false). - self assert: (stream peekFor: #(a b c)). - - self deny: (stream peekFor: 1). - self deny: (stream peekFor: #(a b c)). - self assert: (stream peekFor: false). - - self assert: (stream atEnd). - self deny: (stream peekFor: nil). - self deny: (stream peekFor: 1). - self deny: (stream peekFor: #(a b c)). - self deny: (stream peekFor: false).! Item was removed: - ----- Method: TGettableStreamTest>>testUpTo (in category 'tests - accessing') ----- - testUpTo - | returnValue stream | - returnValue := (self emptyStream upTo: nil). - self assert: returnValue isCollection. - self assert: returnValue isEmpty. - - stream := self streamOnArray. - returnValue := stream upTo: #(a b c). - self assert: returnValue = #(1). - self assert: stream peek = false. - - stream := self streamOnArray. - returnValue := stream upTo: true. - self assert: returnValue = #(1 #(a b c) false). - self assert: stream atEnd.! Item was removed: - ----- Method: TStreamTest>>classUnderTest (in category 'accessing') ----- - classUnderTest - self explicitRequirement! Item was removed: - Trait named: #TReadStreamTest - uses: TGettableStreamTest + TSequencedStreamTest - category: 'CollectionsTests-Streams'! Item was removed: - TReadStreamTest classTrait - uses: TGettableStreamTest classTrait + TSequencedStreamTest classTrait! Item was removed: - Trait named: #TGettableStreamTest - uses: TStreamTest - category: 'CollectionsTests-Streams'! Item was removed: - ----- Method: TStreamTest>>emptyStream (in category 'accessing - defaults') ----- - emptyStream - ^ self streamOn: String new! Item was removed: - ----- Method: TPuttableStreamTest>>testNextPutAllReplacing (in category 'tests - accessing') ----- - testNextPutAllReplacing - | stream | - stream := self streamOnString. - stream reset. - self shouldnt: [ - stream - nextPutAll: 'abc'. - ] raise: Error.! Item was removed: - ----- Method: TReadStreamTest>>testNew (in category 'tests - instance creation') ----- - testNew - self should: [self classUnderTest new] raise: Error.! Item was removed: - ----- Method: TGettableStreamTest>>testPeek2 (in category 'tests - accessing') ----- - testPeek2 - | stream | - stream := self streamOn: #(nil nil nil). - - self assert: stream peek isNil. - stream next. - self assert: stream peek isNil. - stream next. - self assert: stream peek isNil. - stream next. - - "Yes, #peek answers nil when there is no more element to read." - self assert: stream peek isNil.! Item was removed: - ----- Method: TGettableStreamTest>>testNext (in category 'tests - accessing') ----- - testNext - |stream| - - stream := self streamOnArray. - self assert: stream next = 1. - self assert: stream next = #(a b c). - self assert: stream next = false. - - stream := self streamOnString. - self assert: stream next = $a. - self assert: stream next = $b. - self assert: stream next = $c. - self assert: stream next = $d. - self assert: stream next = $e. - ! Item was removed: - ----- Method: TGettableStreamTest>>testNextMatchFor (in category 'tests - testing') ----- - testNextMatchFor - | stream | - stream := self streamOnArray. - self assert: (stream nextMatchFor: 1). - self assert: (stream nextMatchFor: #(a b c)). - self assert: (stream nextMatchFor: false). - - stream := self streamOnArray. - self deny: (stream nextMatchFor: false). - self assert: (stream nextMatchFor: #(a b c)). - self assert: (stream nextMatchFor: false). - ! Item was removed: - Trait named: #TWriteStreamTest - uses: TPuttableStreamTest + TSequencedStreamTest - category: 'CollectionsTests-Streams'! Item was removed: - ----- Method: TReadStreamTest>>testOn (in category 'tests - instance creation') ----- - testOn - self shouldnt: [self streamOn: ' '] raise: Error. - self assert: (self streamOn: ' ') position isZero.! Item was removed: - ----- Method: TGettableStreamTest>>testOldBack (in category 'tests - back') ----- - testOldBack - "Test the old behavior of the method back. The method #oldBack is a misconception about what a stream is. A stream contains a pointer *between* elements with past and future elements. The method #oldBack considers that the pointer is *on* an element. (Damien Cassou - 1 August 2007)" - |stream| - stream := self streamOn: 'abc'. - stream next: 2. - self assert: stream oldBack = $a.! Item was removed: - ----- Method: TGettableStreamTest>>testDo (in category 'tests - enumerating') ----- - testDo - self emptyStream do: [:value | self fail]! Item was removed: - ----- Method: TPuttableStreamTest>>testNextPutAllAppending (in category 'tests - accessing') ----- - testNextPutAllAppending - | stream | - stream := self emptyStream. - self shouldnt: [ - stream - nextPutAll: 'abc'. - ] raise: Error.! Item was removed: - ----- Method: TSequencedStreamTest>>testBackUpToPatternNotFound1 (in category 'tests - positioning') ----- - testBackUpToPatternNotFound1 - |stream| - stream := ReadStream on: 'abcdabg'. - stream setToEnd. - self deny: (stream backUpTo: 'zz'). - self assert: stream position = 0! Item was removed: - ----- Method: TGettableStreamTest>>testDo2 (in category 'tests - enumerating') ----- - testDo2 - | stream string | - stream := self streamOnArray. - string := String new. - - stream do: [:value | string := string, ' ', value asString]. - - self assert: string = (' ', 1 asString, ' ', #(a b c) asString, ' ', false asString)! Item was removed: - ----- Method: TReadStreamTest>>testContents2 (in category 'tests - accessing') ----- - testContents2 - "From ANSI Smalltalk Standard draft 1.9: - - it is unspecified whether or not the returned collection [using #contents] is the same object as the backing store collection. However, if the returned collection is not the same object as the stream backing store collection then the class of the returned collection is the same class as would be returned if the message #select: was sent to the backing store collection." - - "In Squeak, there is #species to know what class should be used on copy, selection..." - | interval stream streamContents | - interval := 1 to: 32. - stream := self streamOn: interval. - streamContents := stream contents. - - (streamContents == interval) - ifFalse: [self assert: streamContents class = Interval new species]! Item was removed: - ----- Method: TGettableStreamTest>>testSkipTo (in category 'tests - positionning') ----- - testSkipTo - | stream | - stream := self emptyStream. - self deny: (stream skipTo: nil). - - stream := self streamOnArray. - self deny: stream atEnd. - self deny: (stream skipTo: nil). - self assert: stream atEnd. - - stream := self streamOnArray. - self assert: stream peek = 1. - self assert: (stream skipTo: #(a b c)). - self assert: stream peek = false. - self assert: (stream skipTo: false). - self assert: stream atEnd.! Item was removed: - TGettableStreamTest classTrait - uses: TStreamTest classTrait! Item was removed: - ----- Method: TGettableStreamTest>>testNexts2 (in category 'tests - accessing') ----- - testNexts2 - - | stream | - stream := self streamOnArray. - self assert: (stream next: 2) = #(1 #(a b c)). - self assert: (stream next: 1) = #(false).! Item was removed: - ----- Method: TGettableStreamTest>>testOldBackOnPosition1 (in category 'tests - back') ----- - testOldBackOnPosition1 - "Test the old behavior of the method back. The method #oldBack is a misconception about what a stream is. A stream contains a pointer *between* elements with past and future elements. The method #oldBack considers that the pointer is *on* an element. (Damien Cassou - 1 August 2007)" - |stream| - stream := self streamOn: 'abc'. - stream next. - self assert: stream oldBack = nil.! Item was removed: - ----- Method: TGettableStreamTest>>testNexts (in category 'tests - accessing') ----- - testNexts - self assert: (self emptyStream next: 0) isEmpty. - self assert: (self streamOnArray next: 0) isEmpty. - self assert: (self streamOnArray next: 1) = #(1). - self assert: (self streamOnArray next: 2) = #(1 #(a b c)). - self assert: (self streamOnArray next: 3) = #(1 #(a b c) false).! Item was removed: - ----- Method: TStreamTest>>streamOnString (in category 'accessing - defaults') ----- - streamOnString - ^ self streamOn: 'abcde'! Item was removed: - ----- Method: TSequencedStreamTest>>testBackUpToEmptyPattern1 (in category 'tests - positioning') ----- - testBackUpToEmptyPattern1 - "This test represents the current behavior which is not clearly defined and could be revised." - |stream| - stream := ReadStream on: 'abcdabg'. - stream setToEnd. - self should: [stream backUpTo: ''] raise: Error.! Item was removed: - TPuttableStreamTest classTrait - uses: TStreamTest classTrait! Item was removed: - ----- Method: TStreamTest>>streamOn: (in category 'helpers') ----- - streamOn: aCollection - ^ self classUnderTest on: aCollection! Item was removed: - ----- Method: TStreamTest>>streamOnArray (in category 'accessing - defaults') ----- - streamOnArray - ^ self streamOn: (Array with: 1 with: #(a b c) with: false)! Item was removed: - ----- Method: TSequencedStreamTest>>testReset (in category 'tests - positioning') ----- - testReset - | stream | - - stream := self emptyStream. - stream reset. - self assert: stream position = 0. - - stream := self streamOnArray. - stream reset. - self assert: stream position = 0. - self deny: stream atEnd. - stream position: 3. - self assert: stream atEnd. - stream reset. - self assert: stream position = 0.! Item was removed: - ----- Method: TGettableStreamTest>>testSkipTo2 (in category 'tests - positionning') ----- - testSkipTo2 - | stream | - - stream := self streamOnString. - self assert: (stream skipTo: $b). - self assert: stream peek = $c. - self assert: (stream skipTo: $d). - self assert: stream peek = $e. - self assert: (stream skipTo: $e). - self assert: stream atEnd.! Item was removed: - TSequencedStreamTest classTrait - uses: TStreamTest classTrait! Item was removed: - TWriteStreamTest classTrait - uses: TSequencedStreamTest classTrait + TPuttableStreamTest classTrait! Item was removed: - ----- Method: TPuttableStreamTest>>testNextPutReplacing (in category 'tests - accessing') ----- - testNextPutReplacing - | stream | - stream := self streamOnArray. - stream reset. - self shouldnt: [ - stream - nextPut: $a; - nextPut: $b; - nextPut: $c. - ] raise: Error.! Item was removed: - ----- Method: TGettableStreamTest>>testBackOnPosition1 (in category 'tests - back') ----- - testBackOnPosition1 - "Test the new implemtation of the method back." - |stream| - stream := self streamOn: 'abc'. - stream next. - self assert: stream back = $a.! Item was removed: - ----- Method: TSequencedStreamTest>>testBackUpTo1 (in category 'tests - positioning') ----- - testBackUpTo1 - |stream| - stream := ReadStream on: 'abcdabg'. - stream setToEnd. - self assert: (stream backUpTo: 'ab'). - self assert: stream peek = $g! Item was removed: - ----- Method: TGettableStreamTest>>testAtEnd (in category 'tests - testing') ----- - testAtEnd - | stream | - self assert: self emptyStream atEnd. - - stream := self streamOnArray. - self deny: stream atEnd. - stream next: 3. - self assert: stream atEnd.! Item was removed: - ----- Method: TReadStreamTest>>testPosition (in category 'tests - positioning') ----- - testPosition - | stream | - self assert: self emptyStream position isZero. - - stream := self streamOnArray. - self assert: stream position = 0. - stream next. - self assert: stream position = 1. - stream next. - self assert: stream position = 2. - stream next. - self assert: stream position = 3. - stream next. - self assert: stream position = 3. - stream next. - self assert: stream position = 3.! Item was removed: - Trait named: #TStreamTest - uses: {} - category: 'CollectionsTests-Streams'! Item was removed: - ----- Method: TSequencedStreamTest>>testContents (in category 'tests - accessing') ----- - testContents - | stream | - self assert: self emptyStream contents = ''. - - stream := self streamOnArray. - self assert: stream contents = #(1 #(a b c) false). - stream position: 3. - self assert: stream contents = #(1 #(a b c) false). - - stream := self streamOnString. - self assert: stream contents = 'abcde'. - stream setToEnd. - self assert: stream contents = 'abcde'.! Item was removed: - ----- Method: TGettableStreamTest>>testBack (in category 'tests - back') ----- - testBack - "Test the new implemtation of the method back." - |stream| - stream := self streamOn: 'abc'. - stream next: 2. - self assert: stream back = $b.! Item was removed: - Trait named: #TPuttableStreamTest - uses: TStreamTest - category: 'CollectionsTests-Streams'! Item was removed: - ----- Method: TPuttableStreamTest>>testNextPutAppending (in category 'tests - accessing') ----- - testNextPutAppending - | stream | - stream := self emptyStream. - self shouldnt: [ - stream - nextPut: $a; - nextPut: $b; - nextPut: $c. - ] raise: Error.! Item was removed: - ----- Method: TSequencedStreamTest>>testSetToEnd (in category 'tests - positioning') ----- - testSetToEnd - | stream | - - stream := self emptyStream. - stream setToEnd. - self assert: stream atEnd. - - stream := self streamOnArray. - stream setToEnd. - self assert: stream atEnd. - stream position: 1. - self deny: stream atEnd. - stream setToEnd. - self assert: stream atEnd.! Item was removed: - ----- Method: TSequencedStreamTest>>testSetPosition (in category 'tests - positioning') ----- - testSetPosition - | stream | - - stream := self emptyStream. - self should: [stream position: -2] raise: Error. - self shouldnt: [stream position: 0] raise: Error. - - stream := self streamOnArray. - self should: [stream position: -1] raise: Error. - self shouldnt: [stream position: 0] raise: Error. - self shouldnt: [stream position: 1] raise: Error. - self shouldnt: [stream position: 2] raise: Error. - - "According to ANSI Smalltalk Standard 1.9 Draft, the following should be tested too: - self should: [stream position: 3] raise: Error. - - However, I don't see the point of raising an error when positioning at the end. - - I prefer testing the absence of error: - " - self shouldnt: [stream position: 3] raise: Error. - self should: [stream position: 4] raise: Error.! Item was removed: - Trait named: #TSequencedStreamTest - uses: TStreamTest - category: 'CollectionsTests-Streams'! Item was removed: - ----- Method: TGettableStreamTest>>testUpTo2 (in category 'tests - accessing') ----- - testUpTo2 - | returnValue stream | - - stream := self streamOnString. - returnValue := stream upTo: $d. - self assert: returnValue = 'abc'. - self assert: stream peek = $e.! Item was removed: - ----- Method: TGettableStreamTest>>testPeekFor2 (in category 'tests - testing') ----- - testPeekFor2 - | stream negative number | - - stream := self streamOn: '- 145'. - negative := stream peekFor: $-. - stream peekFor: Character space. - number := stream next: 3. - self assert: negative. - self assert: number = '145'. - - stream := self streamOn: '-145'. - negative := stream peekFor: $-. - stream peekFor: Character space. - number := stream next: 3. - self assert: negative. - self assert: number = '145'. - - stream := self streamOn: ' 145'. - negative := stream peekFor: $-. - stream peekFor: Character space. - number := stream next: 3. - self deny: negative. - self assert: number = '145'. - - stream := self streamOn: '145'. - negative := stream peekFor: $-. - stream peekFor: Character space. - number := stream next: 3. - self deny: negative. - self assert: number = '145'.! |
Free forum by Nabble | Edit this page |