Oh wow, that's really interesting… and old.

I don't think that substr should work like this. Normal arrays are stringified
by 「substr」, why would it do something completely different for a native array?
So for both UInt and uint8 arrays I'd expect “65 66 67” as an output.

I think this ticket is rejectable as soon as someone can justify it better than
me.

On 2015-05-12 09:54:38, coke wrote:
> 3 tests here that need fixing or review:
>
> my uint8 @buffer = ('A' .. 'Z').map({ .ord });
> is(substr(@buffer, 0, 8), ord('A'), 'substr on compact array (1)');
> is(substr(@buffer, 200, 8), ord('Z'), 'substr on compact array (2)');
> is(
> substr(@buffer, 0, 16),
> sprintf('%08d%08d', ord('A'), ord('B')),
> 'substr on compacy array (3)'
> );
>
> yields:
>
> # Failed test 'substr on compact array (1)'
> # at t/spec/S02-types/compact.rakudo.moar line 14
> # expected: '65'
> # got: '65 66 67'
> # Failed test 'substr on compact array (2)'
> # at t/spec/S02-types/compact.rakudo.moar line 15
> # expected: '90'
> # got: (Failure)
> # Failed test 'substr on compacy array (3)'
> # at t/spec/S02-types/compact.rakudo.moar line 16
> # expected: '0000006500000066'
> # got: '65 66 67 68 69 7'

Reply via email to