[Ironruby-core] Review: fixes for Array#rindex and Array#reverse_each

Daniele Alessandri
Thu, 23 Apr 2009 21:03:33 -0000

Ha! I got caught :-) The duplicated logic is there precisely because
I, too, couldn''t think of a place to share that small piece of code in
a good way, so I just coded it like that for now but I''ll ponder about
that for the next commit. OK for the specs.

Thanks,
Daniele

On Thu, Apr 23, 2009 at 22:08, Jim Deville <jdeville at microsoft.com>
wrote:
> Can you add specs for rindex that expose the bug you fixed? Also, is there
any shared place that you could put the following code:
> ? ? ? ? if (self.Count < originalSize) {
> ? ? ? ? ? ? i = originalSize - i - 1 + self.Count;
> ? ? ? ? ? ? originalSize = self.Count;
> ? ? ? ? }
>
> It would be nice to get rid of the duplicated logic, but I can''t
think of where it should go.
>
> Other than that, looks good.
> JD
>
>> -----Original Message-----
>> From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-
>> bounces at rubyforge.org] On Behalf Of Daniele Alessandri
>> Sent: Thursday, April 23, 2009 12:59 PM
>> To: ironruby-core at rubyforge.org
>> Subject: [Ironruby-core] Review: fixes for Array#rindex and
>> Array#reverse_each
>>
>> Hi,
>> I just pushed two fixes on my repository, the first one addresses a bug
>> in Array#rindex (there was a bug in my last commit) and the second one
>> makes Array#reverse_each compliant with the rubyspecs.
>>
>> http://github.com/nrk/ironruby/commit/d2b18f5d01a49cb62a2ea0c205e1cf123
>> 3ac94e0
>>
>> >From the commit message:
>>
>> * Fixed a bug in IListOps.ReverseIndex (core/array/rindex specs were
>> passing, this bug was triggered under certain conditions different from
>> the ones defined in the specs)
>>
>> * Fixed ArrayOps.ReverseEach to make it not fail when elemens in the
>> array are removed from inside a block.
>>
>> See also the attached diff.
>>
>> Thanks,
>> Daniele
>>
>> --
>> Daniele Alessandri
>> http://www.clorophilla.net/blog/
>> http://twitter.com/JoL1hAHN