From: Rick Delaney Date: Sun, 21 Aug 2005 15:09:57 +0000 (-0400) Subject: Re: [perl #36959] List Constructor Operator - Undefined Values X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=984a4bea51971bb283e220c062d5c48cc4392e13;p=p5sagit%2Fp5-mst-13.2.git Re: [perl #36959] List Constructor Operator - Undefined Values Message-ID: <20050821190957.GE7674@localhost.localdomain> p4raw-id: //depot/perl@25319 --- diff --git a/pp_ctl.c b/pp_ctl.c index 983a760..3952a4a 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -1843,6 +1843,8 @@ PP(pp_enteriter) if (SvTYPE(cx->blk_loop.iterary) != SVt_PVAV) { dPOPss; SV *right = (SV*)cx->blk_loop.iterary; + SvGETMAGIC(sv); + SvGETMAGIC(right); if (RANGE_IS_NUMERIC(sv,right)) { if ((SvOK(sv) && SvNV(sv) < IV_MIN) || (SvOK(right) && SvNV(right) >= IV_MAX)) diff --git a/t/op/range.t b/t/op/range.t index 310f480..8cc327b 100755 --- a/t/op/range.t +++ b/t/op/range.t @@ -7,7 +7,7 @@ BEGIN { use Config; -print "1..37\n"; +print "1..45\n"; print join(':',1..5) eq '1:2:3:4:5' ? "ok 1\n" : "not ok 1\n"; @@ -140,3 +140,51 @@ print join(":", map "[$_]", @foo) eq '' ? "ok 36\n" : "not ok 36\n"; @foo=(); push @foo, $_ for undef..undef; print join(":", map "[$_]", @foo) eq '[]' ? "ok 37\n" : "not ok 37\n"; + +# again with magic +{ + my @a = (1..3); + @foo=(); push @foo, $_ for undef..$#a; + print join(":", @foo) eq '0:1:2' ? "ok 38\n" : "not ok 38\n"; +} +{ + my @a = (); + @foo=(); push @foo, $_ for $#a..undef; + print join(":", @foo) eq '-1:0' ? "ok 39\n" : "not ok 39\n"; +} +{ + local $1; + "2" =~ /(.+)/; + @foo=(); push @foo, $_ for undef..$1; + print join(":", @foo) eq '0:1:2' ? "ok 40\n" : "not ok 40\n"; +} +{ + local $1; + "-2" =~ /(.+)/; + @foo=(); push @foo, $_ for $1..undef; + print join(":", @foo) eq '-2:-1:0' ? "ok 41\n" : "not ok 41\n"; +} +{ + local $1; + "B" =~ /(.+)/; + @foo=(); push @foo, $_ for undef..$1; + print join(":", map "[$_]", @foo) eq '[]' ? "ok 42\n" : "not ok 42\n"; +} +{ + local $1; + "B" =~ /(.+)/; + @foo=(); push @foo, $_ for ""..$1; + print join(":", map "[$_]", @foo) eq '[]' ? "ok 43\n" : "not ok 43\n"; +} +{ + local $1; + "B" =~ /(.+)/; + @foo=(); push @foo, $_ for $1..undef; + print join(":", map "[$_]", @foo) eq '' ? "ok 44\n" : "not ok 44\n"; +} +{ + local $1; + "B" =~ /(.+)/; + @foo=(); push @foo, $_ for $1..""; + print join(":", map "[$_]", @foo) eq '' ? "ok 45\n" : "not ok 45\n"; +}