[FIX] replaceFromtowithstartingAt-fix

marcus at ira.uka.de marcus at ira.uka.de
Sun Aug 17 11:56:23 UTC 2003


from preamble:

"Change Set:		replaceFromtowithstartingAt-fix
Date:			17 August 2003
Author:			Tim Rowledge

A fix for replaceFrom:to:with:startingAt: by Tim Rowledge.

His comments:

 TestsForTextAndTextStreams>testReplacement1 was failing    because (I
claim) Text>replaceFrom:to:with:startingAt: was   simply messing up the
runs array by inserting the entire replacement's runs into thereceiver's
runs. Fixed - I think.

The test:

testReplacement1

  ' for a Text  t,
     the following assertion should always hold:
     t string size = t run size 
    This test examines the preservation of this assertion for in-place
replacement '


   | text1 string replacement startPos length startPosInRep string2 |

   text1 := (string := 'This is a simple text' copy) asText.
    ' without the copy, we would modify a constant that the compiler
attached at the compiled method. '
   startPos := string findString: 'simple'. 
   length  := 'simple' size.
   replacement := (string2 := 'both simple and short*') asText.
   startPosInRep :=  string2 findString: 'short'.
   text1 replaceFrom: startPos 
        to: startPos + length - 1
        with: replacement
        startingAt: startPosInRep.
   self assert: text1 string size = text1 runs size.
"!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: replaceFromtowithstartingAt-fix.cs.gz
Type: application/octet-stream
Size: 885 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20030817/a5beb23e/replaceFromtowithstartingAt-fix.cs.obj


More information about the Squeak-dev mailing list