Skip Menu |
 

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the PPI CPAN distribution.

Report information
The Basics
Id: 47417
Status: resolved
Priority: 0/
Queue: PPI

People
Owner: Nobody in particular
Requestors: PackyAnderson [...] gmail.com
Cc:
AdminCc:

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



Subject: PPI::Statement::Package->namespace doesn't allow all-numeric portions
Download (untitled) / with headers
text/plain 583b
If a package name includes an all-numeric portion, say "package Foo::Bar::1_0;", PPI only recognizes up to the numeric portion as being part of the namespace, namely "Foo::Bar::". The attached test fails like this: 1..1 not ok 1 - namespace matches package declaration # Failed test 'namespace matches package declaration' # in PPI_bug.t at line 10. # got: 'Foo::Bar::' # expected: 'Foo::Bar::1_0' # Looks like you failed 1 test of 1. The attached patch fixes this. I'd write the patch to the repository myself if I was given write access (I promise to be good).
Subject: 0001-Fix-namespace-so-it-allows-inclusion-of-number-tok.patch
From 9456ebcea54c95af51739b141c4de3f8235dc464 Mon Sep 17 00:00:00 2001 From: panderson <panderson@gridapp.com> Date: Sun, 28 Jun 2009 13:54:34 -0400 Subject: [PATCH] Fix namespace() so it allows inclusion of number tokens as well as word tokens. --- blib/lib/PPI/Statement/Package.pm | 13 +++++++++---- blib/man3/PPI::Statement::Package.3pm | 2 +- lib/PPI/Statement/Package.pm | 13 +++++++++---- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/blib/lib/PPI/Statement/Package.pm b/blib/lib/PPI/Statement/Package.pm index 329c4e6..791e165 100644 --- a/blib/lib/PPI/Statement/Package.pm +++ b/blib/lib/PPI/Statement/Package.pm @@ -64,10 +64,15 @@ If the package statement is done any different way, it returns false. sub namespace { my $self = shift; - my $namespace = $self->schild(1) or return ''; - $namespace->isa('PPI::Token::Word') - ? $namespace->content - : ''; + my @children = $self->schildren or return ''; + shift @children; # discard 'package' + my $namespace = q{}; + foreach my $child ( @children ) { + $namespace .= $child->isa('PPI::Token::Word') ? $child->content + : $child->isa('PPI::Token::Number') ? $child->content + : q{}; + } + return $namespace; } =pod diff --git a/blib/man3/PPI::Statement::Package.3pm b/blib/man3/PPI::Statement::Package.3pm index fabcd99..d523b08 100644 --- a/blib/man3/PPI::Statement::Package.3pm +++ b/blib/man3/PPI::Statement::Package.3pm @@ -129,7 +129,7 @@ .\" ======================================================================== .\" .IX Title "PPI::Statement::Package 3" -.TH PPI::Statement::Package 3 "2008-05-14" "perl v5.8.6" "User Contributed Perl Documentation" +.TH PPI::Statement::Package 3 "2009-06-28" "perl v5.8.6" "User Contributed Perl Documentation" .SH "NAME" PPI::Statement::Package \- A package statement .SH "INHERITANCE" diff --git a/lib/PPI/Statement/Package.pm b/lib/PPI/Statement/Package.pm index 329c4e6..791e165 100644 --- a/lib/PPI/Statement/Package.pm +++ b/lib/PPI/Statement/Package.pm @@ -64,10 +64,15 @@ If the package statement is done any different way, it returns false. sub namespace { my $self = shift; - my $namespace = $self->schild(1) or return ''; - $namespace->isa('PPI::Token::Word') - ? $namespace->content - : ''; + my @children = $self->schildren or return ''; + shift @children; # discard 'package' + my $namespace = q{}; + foreach my $child ( @children ) { + $namespace .= $child->isa('PPI::Token::Word') ? $child->content + : $child->isa('PPI::Token::Number') ? $child->content + : q{}; + } + return $namespace; } =pod -- 1.6.2.1
Subject: PPI_bug.t
Download PPI_bug.t
text/x-perl 290b
use strict; use PPI; use Test::More tests => 1; my $package_name = "Foo::Bar::1_0"; my $doc = PPI::Document->new(\"package $package_name;"); my $pkg = $doc->find_first('PPI::Statement::Package'); my $ns = $pkg->namespace; is( $ns, $package_name, 'namespace matches package declaration');
Subject: Re: [rt.cpan.org #47417] PPI::Statement::Package->namespace doesn't allow all-numeric portions
Date: Mon, 29 Jun 2009 13:44:24 +1000
To: bug-PPI [...] rt.cpan.org
From: Adam Kennedy <adamkennedybackup [...] gmail.com>
Download (untitled) / with headers
text/plain 1.1k
Do you have CPAN login/email? I'll add you to the commit list. Adam K 2009/6/29 Packy Anderson via RT <bug-PPI@rt.cpan.org>: Show quoted text
> Sun Jun 28 14:25:11 2009: Request 47417 was acted upon. > Transaction: Ticket created by packy >       Queue: PPI >     Subject: PPI::Statement::Package->namespace doesn't allow all-numeric portions >   Broken in: 1.203 >    Severity: (no value) >       Owner: Nobody >  Requestors: PackyAnderson@gmail.com >      Status: new >  Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=47417 > > > > If a package name includes an all-numeric portion, say "package > Foo::Bar::1_0;", PPI only recognizes up to the numeric portion as being > part of the namespace, namely "Foo::Bar::". > > The attached test fails like this: > > 1..1 > not ok 1 - namespace matches package declaration > #   Failed test 'namespace matches package declaration' > #   in PPI_bug.t at line 10. > #          got: 'Foo::Bar::' > #     expected: 'Foo::Bar::1_0' > # Looks like you failed 1 test of 1. > > The attached patch fixes this.  I'd write the patch to the repository > myself if I was given write access (I promise to be good). >
Subject: Re: [rt.cpan.org #47417] PPI::Statement::Package->namespace doesn't allow all-numeric portions
Date: Mon, 29 Jun 2009 06:56:47 -0400
To: bug-PPI [...] rt.cpan.org
From: Packy Anderson <packyanderson [...] gmail.com>
Download (untitled) / with headers
text/plain 418b
On Sun, Jun 28, 2009 at 11:44 PM, Reserved Local Account via RT<bug-PPI@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=47417 > > > Do you have CPAN login/email? > > I'll add you to the commit list.
Not yet. I've just submitted a request, because I also want to contribute some Perl::Critic rules. I'll reply again when it's been created. -packy -- Packy Anderson PackyAnderson@gmail.com
Subject: Re: [rt.cpan.org #47417] PPI::Statement::Package->namespace doesn't allow all-numeric portions
Date: Tue, 21 Jul 2009 07:58:41 -0400
To: bug-PPI [...] rt.cpan.org
From: Packy Anderson <packyanderson [...] gmail.com>
Download (untitled) / with headers
text/plain 488b
On Mon, Jun 29, 2009 at 6:56 AM, Packy Anderson<packyanderson@gmail.com> wrote: Show quoted text
> On Sun, Jun 28, 2009 at 11:44 PM, Reserved Local Account via > RT<bug-PPI@rt.cpan.org> wrote:
>> <URL: https://rt.cpan.org/Ticket/Display.html?id=47417 > >> >> Do you have CPAN login/email? >> >> I'll add you to the commit list.
> > Not yet.  I've just submitted a request, because I also want to > contribute some Perl::Critic rules.  I'll reply again when it's been > created.
My CPAN login is PACKY.
Resolved in 1.211_01


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.