Skip Menu |
 

This queue is for tickets about the NEXT CPAN distribution.

Report information
The Basics
Id: 16885
Status: open
Priority: 0/
Queue: NEXT

People
Owner: Nobody in particular
Requestors: shlomif [...] iglu.org.il
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: Should Handle NEXT:: calls from eval { } or anonymous functions
Download (untitled) / with headers
text/plain 236b
NEXT should be able to handle calls to NEXT:: from within eval { ... } blocks or from within anonymous function calls within the method, which at the moment it does not handle and throws an exception. This patch implements this feature.
diff -u -r -N orig/NEXT-0.60/lib/NEXT.pm fixed/NEXT-0.60/lib/NEXT.pm --- orig/NEXT-0.60/lib/NEXT.pm 2003-08-13 06:55:41.000000000 +0300 +++ fixed/NEXT-0.60/lib/NEXT.pm 2006-01-03 16:24:57.000000000 +0200 @@ -32,7 +32,15 @@ sub AUTOLOAD { my ($self) = @_; - my $caller = (caller(1))[3]; + my $caller; + my $frame = 1; + while ((!defined($caller)) || + ($caller eq "(eval)") || + ($caller =~ /::__ANON__/) + ) + { + $caller = (caller($frame++))[3]; + } my $wanted = $NEXT::AUTOLOAD || 'NEXT::AUTOLOAD'; undef $NEXT::AUTOLOAD; my ($caller_class, $caller_method) = $caller =~ m{(.*)::(.*)}g; diff -u -r -N orig/NEXT-0.60/MANIFEST fixed/NEXT-0.60/MANIFEST --- orig/NEXT-0.60/MANIFEST 2001-11-16 02:15:47.000000000 +0200 +++ fixed/NEXT-0.60/MANIFEST 2006-01-03 16:25:46.000000000 +0200 @@ -5,6 +5,7 @@ lib/NEXT.pm t/actual.t t/actuns.t +t/blocks.t t/next.t t/unseen.t demo/demo.pl @@ -12,3 +13,4 @@ demo/demo_diamond.pl demo/demo_unseen.pl demo/demo_unseen_actual.pl +META.yml Module meta-data (added by MakeMaker) diff -u -r -N orig/NEXT-0.60/META.yml fixed/NEXT-0.60/META.yml --- orig/NEXT-0.60/META.yml 1970-01-01 02:00:00.000000000 +0200 +++ fixed/NEXT-0.60/META.yml 2006-01-03 16:25:46.000000000 +0200 @@ -0,0 +1,10 @@ +# http://module-build.sourceforge.net/META-spec.html +#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# +name: NEXT +version: 0.60 +version_from: +installdirs: site +requires: + +distribution_type: module +generated_by: ExtUtils::MakeMaker version 6.17 diff -u -r -N orig/NEXT-0.60/t/blocks.t fixed/NEXT-0.60/t/blocks.t --- orig/NEXT-0.60/t/blocks.t 1970-01-01 02:00:00.000000000 +0200 +++ fixed/NEXT-0.60/t/blocks.t 2006-01-03 16:22:51.000000000 +0200 @@ -0,0 +1,83 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use NEXT; + +package One; + +sub new +{ + my $class = shift; + my $self = {}; + bless $self, $class; + $self->_initialize(@_); + return $self; +} + +sub _initialize +{ +} + +sub hello +{ + return "hello"; +} + +package Two; + +sub hello +{ + my $self = shift; + my $ret; + eval { + $ret = $self->NEXT::hello(); + }; + return $ret; +} + +package TwoApp; + +use vars qw(@ISA); + +@ISA=(qw(Two One)); + +package Three; + +sub hello +{ + my $self = shift; + + my $ret; + my $mysub = sub { + $ret = $self->NEXT::hello(); + }; + + eval { + $mysub->(); + }; + return $ret; +} + +package ThreeApp; + +use vars qw(@ISA); + +@ISA=(qw(Three One)); + +package main; + +use Test::More tests => 2; + +{ + my $obj = TwoApp->new(); + # TEST + is ($obj->hello(), "hello", "NEXT operates for eval { } blocks"); +} +{ + my $obj = ThreeApp->new(); + # TEST + is ($obj->hello(), "hello", "NEXT operates for eval { } blocks"); +} +
Download (untitled) / with headers
text/plain 164b
This has been fixed by Dave Rolsky in 2004 and has since been part of the NEXT version shipped with the perl core. With NEXT 0.61 the fix is also available on CPAN.
Download (untitled) / with headers
text/plain 896b
On Tue Mar 24 18:32:35 2009, FLORA wrote: Show quoted text
> This has been fixed by Dave Rolsky in 2004 and has since been part of > the NEXT version shipped with the perl core. With NEXT 0.61 the fix is > also available on CPAN.
Hi! Thanks for maintaining NEXT on CPAN again. However, it seems that the modifications in the CPAN/perl-5.10.0 NEXT are incomplete in comparison to my own, because the test file I included (attached to this message) still partially fails: {{{{{{{{{{{{{{{ $ perl t/blocks.t 1..2 ok 1 - NEXT operates for eval { } blocks not ok 2 - NEXT operates for eval { } blocks # Failed test 'NEXT operates for eval { } blocks' # at t/blocks.t line 81. # got: undef # expected: 'hello' # Looks like you failed 1 test of 2. $ perldoc -m NEXT | grep VERSION $VERSION = '0.61'; $ }}}}}}}}}}}}}}} I'd like to fix it with a new patch if I find some time. Regards, -- Shlomi Fish
Download blocks.t
text/x-perl 970b
#!/usr/bin/perl use strict; use warnings; use NEXT; package One; sub new { my $class = shift; my $self = {}; bless $self, $class; $self->_initialize(@_); return $self; } sub _initialize { } sub hello { return "hello"; } package Two; sub hello { my $self = shift; my $ret; eval { $ret = $self->NEXT::hello(); }; return $ret; } package TwoApp; use vars qw(@ISA); @ISA=(qw(Two One)); package Three; sub hello { my $self = shift; my $ret; my $mysub = sub { $ret = $self->NEXT::hello(); }; eval { $mysub->(); }; return $ret; } package ThreeApp; use vars qw(@ISA); @ISA=(qw(Three One)); package main; use Test::More tests => 2; { my $obj = TwoApp->new(); # TEST is ($obj->hello(), "hello", "NEXT operates for eval { } blocks"); } { my $obj = ThreeApp->new(); # TEST is ($obj->hello(), "hello", "NEXT operates for eval { } blocks"); }


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.