[squeak-dev] [SeasideSt/Grease] GRIntervalTest >> #testSorted assumes new collection (#95)
Tobias Pape
Das.Linux at gmx.de
Tue Aug 27 19:07:11 UTC 2019
> On 27.08.2019, at 16:42, Nicolas Cellier <nicolas.cellier.aka.nice at gmail.com> wrote:
>
> But would we want to mutate an Interval???
> I would consider an Interval as read-only and would lock the inst-vars just after setting if it were me, likewise for Point and some other species...
>
> IMO, the test is wrong in this regard.
> We should not expect that #sorted always answer a copy, if we don't need one.
> What we should expect is that #sorted do NEVER mutate the receiver, which is a different thing, contrarily to #sort which should.
> The test should rather assert that original is not mutated by original sorted...
>
> Of course, if what we really want is a #sortedCopy behavior, then we can add this innocuous copy...
> But IMO it is not necessary.
Makes sense. Thank you :)
>
> Le mar. 27 août 2019 à 15:04, Tobias Pape <Das.Linux at gmx.de> a écrit :
>
>
>> Begin forwarded message:
>>
>> From: Philippe Marschall <notifications at github.com>
>> Subject: [SeasideSt/Grease] GRIntervalTest >> #testSorted assumes new collection (#95)
>> Date: 27. August 2019 um 14:55:35 MESZ
>> To: SeasideSt/Grease <Grease at noreply.github.com>
>> Cc: Subscribed <subscribed at noreply.github.com>
>> Reply-To: SeasideSt/Grease <reply+AAA5D32XUYEK5HDHSCXBQ3N3OJUNPEVBNHHBZ5E5ZI at reply.github.com>
>> Delivered-To: tobias at netshed.de
>>
>> GRIntervalTest >> #testSorted assumes new a collection is returned. This is no longer true with the latest Squeak.
>>
>
> I just looked, all #sorted return a copy, except Interval:
>
> "
> sorted
> "an Interval is already sorted"
> step < 0 ifTrue: [^self reversed].
> ^self
> "
>
> Shouldn't that rather be this?
>
> "
> sorted
> "an Interval is already sorted"
> step < 0 ifTrue: [^self reversed].
> ^self copy
> "
>
>
> Best regards
> -Tobias
>
>
More information about the Squeak-dev
mailing list
|