Hi levente Thankx for the mail.
That OrderedCollection still has 0 size, so there's nothing to replace there.
indeed this is what I saw.
It was an accident that the code worked before. Consider using #ofSize: instead of #new: if you want the collection to have slots.
Yes I fixed the test by providing a receiver with equal size so that all the elements can be swapped nicely and all the tests are green now.
Levente
P.S.: If XMLOrderedList is a subclass of OrderedCollection, then it's just plain wrong IMHO. Creating subclasses of collections in external packages is bad practice.
It is wrapping an orderedCollection :)
So I fixed the tests of the XMLOrderedList to work but I'm a bit unsatisfied.
Stef
Do you have an idea how I can handle that? Because XMLObservableList and XMLOrderedList implements replaceFrom: to: with: startingAt:
because there is no self makeRoomFor: (stop - self capacity) invocation.
in 1.4>> replaceFrom: start to: stop with: replacement startingAt: repStart "This destructively replaces elements from start to stop in the receiver starting at index, repStart, in the sequenceable collection, replacementCollection. Answer the receiver. No range checks are performed."
| index repOff | repOff := repStart - start. index := start - 1. [(index := index + 1) <= stop] whileTrue: [self at: index put: (replacement at: repOff + index)]
at: anInteger put: anObject "Put anObject at element index anInteger. at:put: cannot be used to append, front or back, to an ordered collection; it is used by a knowledgeable client to replace an element." self ensureBoundsFrom: anInteger to: anInteger. ^array at: anInteger + firstIndex - 1 put: anObject
in 1.2.1
replaceFrom: start to: stop with: replacement startingAt: repStart "An ordered collection is growable, so a call to this can make the collection grow." self makeRoomFor: (stop - self capacity). array replaceFrom: start + firstIndex - 1 to: stop + firstIndex - 1 with: replacement startingAt: repStart. lastIndex := lastIndex max: stop + firstIndex - 1.