The Trunk: CollectionsTests-dtl.212.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: CollectionsTests-dtl.212.mcz

commits-2
Levente Uzonyi uploaded a new version of CollectionsTests to project The Trunk:
http://source.squeak.org/trunk/CollectionsTests-dtl.212.mcz

==================== Summary ====================

Name: CollectionsTests-dtl.212
Author: dtl
Time: 19 January 2014, 10:43:43.125 am
UUID: 6916414f-dda9-4b64-a4ee-f5f50aacd4c4
Ancestors: CollectionsTests-dtl.211

Add OrderedCollectionTest>>testStreamContentsPositioning.

String class>>new:streamContents: optimizes performance by answering originalCollection in the case of a stream positioned to the size of its original collection. This fails if the stream has been repositioned backwards to its original length.

The optimization was introduced in Collections-ar.129 which merges Collections-ul.128 from inbox:

- introduced #new:streamContents: in SequenceableCollection class. It's like #streamContents: but if you know the size of the new collection this method doesn't copy the result.
- updated SequenceableCollection class >> #streamContents: to use #new:streamContents:, kept the original default size 100.

=============== Diff against CollectionsTests-dtl.211 ===============

Item was added:
+ ----- Method: OrderedCollectionTest>>testStreamContentsPositioning (in category 'testStreaming') -----
+ testStreamContentsPositioning
+ "String class>>new:streamContents: optimizes performance by answering the
+ originalCollection in the case of a stream positioned to the size of the original
+ collection. This fails if the stream has been repositioned backwards to its original
+ length."
+
+ "(OrderedCollectionTest selector: #testStreamContentsPositioning) debug"
+
+ | s |
+ s := String new: 10 streamContents: [ :strm |
+ strm nextPutAll: 'XXXXX'.
+ self assert: 'XXXXX' equals: strm contents.
+ strm nextPut: $X.
+ self assert: 'XXXXXX' equals: strm contents.
+ strm position: strm position - 1.
+ self assert: 'XXXXX' equals: strm contents.
+ strm nextPutAll: 'XXXXX'.
+ self assert: 'XXXXXXXXXX' equals: strm contents.
+ strm nextPut: $X.
+ self assert: 'XXXXXXXXXXX' equals: strm contents.
+ strm position: strm position - 1.
+ self assert: 'XXXXXXXXXX' equals: strm contents.
+ ].
+ self assert: 10 equals: s size.
+ self assert: 'XXXXXXXXXX' equals: s.
+
+ !