diff --git a/source/Buoy-Collections-Tests/OrderedSetTest.class.st b/source/Buoy-Collections-Tests/OrderedSetTest.class.st index 4f3098e..3bcda05 100644 --- a/source/Buoy-Collections-Tests/OrderedSetTest.class.st +++ b/source/Buoy-Collections-Tests/OrderedSetTest.class.st @@ -1106,20 +1106,20 @@ OrderedSetTest >> testWriteStream [ nextPut: $d; nextPut: $e; nextPut: $f. + + "According to ANSI standard it is unspecified whether or not the + returned collection is the same object as the backing store collection. + + Se we just test over the stream contents" + self - assert: set size equals: 3; - assert: set first equals: $d; - assert: set second equals: $e; - assert: set last equals: $f. + assert: stream contents size equals: 3; + assert: stream contents first equals: $d; + assert: stream contents second equals: $e; + assert: stream contents last equals: $f. stream nextPut: $g. - self - assert: set size equals: 3; - assert: set first equals: $d; - assert: set second equals: $e; - assert: set last equals: $f. - self assert: stream contents size equals: 4; assert: stream contents first equals: $d; diff --git a/source/Buoy-Collections/OrderedSet.class.st b/source/Buoy-Collections/OrderedSet.class.st index cfb69ec..fa4edda 100644 --- a/source/Buoy-Collections/OrderedSet.class.st +++ b/source/Buoy-Collections/OrderedSet.class.st @@ -128,7 +128,17 @@ OrderedSet >> copyReplaceAll: oldSubCollection with: newSubCollection [ { #category : #copying } OrderedSet >> copyReplaceFrom: start to: stop with: replacementCollection [ - ^ self species withAll: ( collection copyReplaceFrom: start to: stop with: replacementCollection ) + stop >= start then: [ "When stop>=start this method will do a replacement, otherwise an insertion" + AssertionChecker + enforce: [ stop - start + 1 = replacementCollection size ] + because: + 'The replacement collection doesn''t have the expected size.' + raising: SubscriptOutOfBounds ]. + + ^ self species withAll: (collection + copyReplaceFrom: start + to: stop + with: replacementCollection) ] { #category : #copying }