# New Ticket Created by Eric Hanchrow # Please include the string: [perl #41739] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=41739 >
b/CREDITS | 4 ++++ b/t/pmc/iterator.t | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- src/pmc/iterator.pmc | 18 +++++------------- 3 files changed, 56 insertions(+), 15 deletions(-) -- A DRE voting system is one of the simplest computer applications you could imagine. It just adds by one. -- Brit Williams, emeritus professor of computer science
diff --git a/CREDITS b/CREDITS index 5539d51..a11a4d2 100644 --- a/CREDITS +++ b/CREDITS @@ -182,6 +182,10 @@ E: [EMAIL PROTECTED] N: Eirik Berg Hanssen D: Use unix98 ps option in signal.t +N: Eric Hanchrow +D: add "clone" to iterator +E: [EMAIL PROTECTED] + N: Eric Lubow D: makefile fixes E: [EMAIL PROTECTED] diff --git a/docs/art/pp001-intro.pod b/docs/art/pp001-intro.pod index 0d8f17a..f1d7695 100644 --- a/src/pmc/iterator.pmc +++ b/src/pmc/iterator.pmc @@ -1,6 +1,6 @@ /* Copyright (C) 2001-2003, The Perl Foundation. -$Id$ +$Id: iterator.pmc 16275 2006-12-28 01:20:44Z particle $ =head1 NAME @@ -85,19 +85,11 @@ Marks the current idx/key and the aggregate as live. pobject_lives(INTERP, (PObj *) PMC_pmc_val(SELF)); } -/* - -=item C<PMC *clone()> - -Unimplemented. Calls the C<default> method. - -=cut - -*/ - PMC* clone() { - return SUPER(); - /* XXX (#40799): TODO */ + PMC *res; + /* TODO -- find the proper macro that expands to this stuff */ + res = pmc_new_init(INTERP, SELF->vtable->base_type, PMC_pmc_val(SELF)); + return res; } /* diff --git a/t/pmc/iterator.t b/t/pmc/iterator.t index 0d6b7f9..f365d7d 100644 --- a/t/pmc/iterator.t +++ b/t/pmc/iterator.t @@ -1,13 +1,13 @@ #!perl # Copyright (C) 2001-2006, The Perl Foundation. -# $Id$ +# $Id: iterator.t 16171 2006-12-17 19:06:36Z paultcochrane $ use strict; use warnings; use lib qw( . lib ../lib ../../lib ); use Test::More; -use Parrot::Test tests => 40; +use Parrot::Test tests => 42; =head1 NAME @@ -1319,6 +1319,51 @@ pi 6.28 OUTPUT + +pir_output_is (<< 'CODE', << 'OUTPUT', "iterator can be cloned"); +.sub main :main + .local pmc ar, i1, i2 + ar = new ResizableIntegerArray + push ar, 17 + new i1, .Iterator, ar + clone i2, i1 +.end +CODE +OUTPUT + +pir_output_is (<< 'CODE', << 'OUTPUT', "cloned iterator independent of original"); +.sub main :main + .local pmc ar, i1, i2 + ar = new ResizableIntegerArray + push ar, 17 + push ar, 42 + + new i1, .Iterator, ar + clone i2, i1 + + .local Integer temp + + shift temp, i1 + unless temp == 17 goto fail + + shift temp, i1 + unless temp == 42 goto fail + + shift temp, i2 + unless temp == 17 goto fail + + shift temp, i2 + unless temp == 42 goto fail + + say "ok" + end +fail: + say "not ok" +.end +CODE +ok +OUTPUT + # Local Variables: # mode: cperl # cperl-indent-level: 4