# New Ticket Created by Eric Hanchrow # Please include the string: [perl #42996] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=42996 >
Add a new TODO test for iterator cloning: make sure that we're not accidentally copying the entire array. (Since this test currently fails, I fear that we _are_ copying the entire array :-( ) Index: t/pmc/iterator.t =================================================================== --- t/pmc/iterator.t (revision 18587) +++ t/pmc/iterator.t (working copy) @@ -7,7 +7,7 @@ use lib qw( . lib ../lib ../../lib ); use Test::More; -use Parrot::Test tests => 43; +use Parrot::Test tests => 44; =head1 NAME @@ -1391,6 +1391,38 @@ ok OUTPUT +TODO: { + local $TODO = "cloned iterator doesn't copy the array to which it 'points'"; +pir_output_is( <<'CODE', <<'OUTPUT', "cloned iterator doesn't copy the array to which it 'points'" ); +.sub main :main + .local pmc ar, i1, i2 + .local Integer temp + temp = new Integer + ar = new ResizableIntegerArray + push ar, 1 + new i1, .Iterator, ar + + # i1 and i2 now "point" to the same element of the same array. + clone i2, i1 + + # Modify the array ... + temp = 17 + i1 = temp + + # Now read back the modified value ... + shift temp, i2 + + unless temp == 17 goto fail + + say "ok" + end +fail: + say "not ok" +.end +CODE +ok +OUTPUT +} # Local Variables: # mode: cperl # cperl-indent-level: 4 iterator.t | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) -- [T]he only two jobs at which I have ever earned my living are soul musician and linguist Geoffrey K. Pullum