[squeak-dev] Fwd: [SeasideSt/Grease] GRIntervalTest >> #testSorted assumes new collection (#95)

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Tue Aug 27 14:42:36 UTC 2019


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.

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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20190827/fc06fd00/attachment.html>


More information about the Squeak-dev mailing list