Skip to content

Commit

Permalink
Array slice assignment is no longer lazy after array slice re-imagina…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
lizmat committed Jan 8, 2021
1 parent f708802 commit b901130
Showing 1 changed file with 2 additions and 20 deletions.
22 changes: 2 additions & 20 deletions S32-list/seq.t
Expand Up @@ -3,7 +3,7 @@ use Test;
use lib $?FILE.IO.parent(2).add("packages/Test-Helpers");
use Test::Util;

plan 53;
plan 49;

my @result = 1,2,3;

Expand Down Expand Up @@ -89,29 +89,11 @@ is-deeply @searches[0].Array, @expected-searches, 'seq => array works 3';

}

# Lazy assignment. This behavior is experimental.
# Lazy assignment.
{
my @n = 0,1;
eager @n.map(-> $v is rw {$v})[0,1] = <a b>.sort;
is @n, <a b>, 'Seq slice assignment works';

@n = 0,1;
my $b = 0;
@n.map(-> $v is rw {$b++; $v})[0,1] = <a b>.sort;
is $b, 0, 'Seq slice assignment is lazy';

@n = 0,1;
my @log;
eager @n.map(-> $v is rw {@log.push("A " ~ $++); $v;})[0,1] = @n.map(-> $v is rw {@log.push("B " ~ $++); $v})[0,1] = <a b>.sort;
is @n, <a b>, 'Chained Seq slice assignment works';
is @log, ("A 0","B 0","A 1","B 1"), 'Chained Seq slice assignment is lazy';

@n = 0,1;
# (NYI need to cache in sub eagerize when reifying for elems)
{ eager @n.map(-> $v is rw {$v})[*-2,*-1] = <a b>.sort, <a b>, 'WhateverCode in Seq slice assignment'; CATCH { default { $_.defined } } };
#?rakudo todo 'Cannot assign immutable'
is @n, <a b>, 'WhateverCode in Seq slice assignment';

}

# https://github.com/Raku/old-issue-tracker/issues/5124
Expand Down

0 comments on commit b901130

Please sign in to comment.