Re: [Pharo-project] Issue 2704 in pharo: Tests for broken withNoLineLongerThan: behavior.
Comment #6 on issue 2704 by elpochod...@gmail.com: Tests for broken withNoLineLongerThan: behavior. http://code.google.com/p/pharo/issues/detail?id=2704 I have another implementation for this method, which I think may be a bit cleaner (and also passes all tests) withNoLineLongerThan: maxWidth "Answer a string with the same content as receiver, but rewrapped so that no line has more characters than the given number" | res size left right limit next | size := self size. maxWidth isNumber not | (maxWidth < 1) ifTrue: [self error: 'too narrow']. ^self class new: size * (maxWidth + 1) // maxWidth "provision for supplementary line breaks" streamContents: [ :stream | right := 1. [right <= size] whileTrue: [ left := self indexOfAnyOf: CSNonSeparators startingAt: right ifAbsent: [ ^stream next: size - left + 1 putAll: self startingAt: left; contents ]. limit := left + maxWidth - 1. (limit >= size) ifTrue: [ ^stream next: size - left + 1 putAll: self startingAt: left; contents ]. next := left. [ next - 1 <= limit ] whileTrue: [ right := next. next := self indexOfAnyOf: CSSeparators startingAt: next + 1 ifAbsent: [ (next = left) ifTrue: [ limit + 1] ifFalse: [ limit+2 ] ]. (CSLineEnders includes: (self at: right)) ifTrue: [ next := limit+2]. ]. stream next: right - left putAll: self startingAt: left. (right <= size) ifTrue: [ stream cr ]. ] ].
Comment #7 on issue 2704 by marianopeck: Tests for broken withNoLineLongerThan: behavior. http://code.google.com/p/pharo/issues/detail?id=2704 thanks pocho :) so, it is ready to integrate?
Comment #8 on issue 2704 by nicolas....@gmail.com: Tests for broken withNoLineLongerThan: behavior. http://code.google.com/p/pharo/issues/detail?id=2704 No, both methods fails with this test: String crlf withNoLineLongerThan: 5. Also, does your version works when there is no space available near ? 'ThisMightBe tooLong' withNoLineLongerThan: 5.
Comment #9 on issue 2704 by nicolas....@gmail.com: Tests for broken withNoLineLongerThan: behavior. http://code.google.com/p/pharo/issues/detail?id=2704 SLICE-Issue-2704-String-withNoLineLongerThan-nice.1 contains fresh Squeak test and fix. Pocho, you can correct the alternative if you want, but this method is damned tricky (I broke some teeth on it).
Updates: Status: Closed Labels: Milestone-1.3 Comment #10 on issue 2704 by stephane...@gmail.com: Tests for broken withNoLineLongerThan: behavior. http://code.google.com/p/pharo/issues/detail?id=2704 Thanks a lot. We have not much time for looking at these enhancements but there are still nice to have. So thanks Integrated in 13112
participants (1)
-
pharo@googlecode.com