Skip Menu |

This queue is for tickets about the B-Keywords CPAN distribution.

Report information
The Basics
Id: 43919
Status: resolved
Priority: 0/
Queue: B-Keywords

People
Owner: Nobody in particular
Requestors: mschwern [...] cpan.org
Cc:
AdminCc:

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



Subject: Missing $\ in @Scalar
@Scalars is missing $\ On the road to fixing and testing that I noticed two other bugs. use B::Keywords qw(:all); didn't work and the @Symbols documentation was missing @Functions. Patches for all three attached.
Subject: 0003--was-missing-from-Scalars.patch
From 6ec4477b8552be0b594dd5ae7d659d7967fa252c Mon Sep 17 00:00:00 2001 From: Michael G. Schwern <schwern@pobox.com> Date: Fri, 6 Mar 2009 20:39:25 -0800 Subject: [PATCH 3/3] $\ was missing from @Scalars. Overhauled the keywords test. Now using individual ok() tests rather than one big lump for better diagnostics. Added a test to check all the single character things in main. The test was using Test.pm but also called diag() which is a Test::More thing so now it's using Test::More. --- lib/B/Keywords.pm | 2 +- t/11keywords.t | 55 ++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 39 insertions(+), 18 deletions(-) diff --git a/lib/B/Keywords.pm b/lib/B/Keywords.pm index 1d1195f..e4b1468 100644 --- a/lib/B/Keywords.pm +++ b/lib/B/Keywords.pm @@ -28,7 +28,7 @@ use vars '@Scalars'; $. $INPUT_LINE_NUMBER $NR $/ $INPUT_RECORD_SEPARATOR $RS $| $OUTPUT_AUTO_FLUSH ), '$,', qw( $OUTPUT_FIELD_SEPARATOR $OFS - $OUTPUT_RECORD_SEPARATOR $ORS + $\ $OUTPUT_RECORD_SEPARATOR $ORS $" $LIST_SEPARATOR $; $SUBSCRIPT_SEPARATOR $SUBSEP ), '$#', qw( $OFMT diff --git a/t/11keywords.t b/t/11keywords.t index 170ecb5..8ed3792 100644 --- a/t/11keywords.t +++ b/t/11keywords.t @@ -1,27 +1,48 @@ +#!/usr/bin/perl -w + use strict; -BEGIN { $^W = 1 } -use Test; -BEGIN { plan tests => 1 } +use Test::More 'no_plan'; use Config; use File::Spec; use lib qw( ../lib lib ); -use B::Keywords qw( @Symbols @Functions @Barewords ); +use B::Keywords ':all'; + +# Translate control characters into ^A format +# Leave others alone. +my @control_map = (undef, "A".."Z"); +sub _map_control_char { + my $char = shift; + my $ord = ord $char; + + return "^".$control_map[$ord] if $ord <= 26; + return $char; +} -my $keywords = File::Spec->catfile( $Config{archlibexp}, 'CORE', 'keywords.h' ); -open FH, "< $keywords\0" or die "Can't open $keywords: $!"; -local $/; -chomp( my @keywords = <FH> =~ /^\#define \s+ KEY_(\S+) /xmsg ); -close FH; +# Test everything in keywords.h is covered. +{ + my $keywords = File::Spec->catfile( $Config{archlibexp}, 'CORE', 'keywords.h' ); + open FH, "< $keywords\0" or die "Can't open $keywords: $!"; + local $/; + chomp( my @keywords = <FH> =~ /^\#define \s+ KEY_(\S+) /xmsg ); + close FH; + + my %covered = map { $_ => 1 } @Symbols, @Barewords; + + for my $keyword (@keywords) { + ok $covered{$keyword}, "keyword: $keyword"; + } +} -my %covered; -@covered{ @Symbols } = (); -@covered{ @Functions } = (); -@covered{ @Barewords } = (); -my @missing = grep { ! exists $covered{$_} } @keywords; +# Test all the single character globals in main +{ + my @globals = map { _map_control_char($_) } + grep { length $_ == 1 and /\W/ } + keys %main::; -ok( ! @missing ); -if ( @missing ) { - diag( "Missing: @missing" ); + my %symbols = map { s/^.//; $_ => 1 } (@Scalars, @Arrays, @Hashes); + for my $global (@globals) { + ok $symbols{$global}, "global: $global"; + } } -- 1.6.2
Subject: 0001-Fix-use-B-Keywords-qw-all.patch
From 7b0963f1ccd02fb0a14f8c8e0aa232e5af7f638d Mon Sep 17 00:00:00 2001 From: Michael G. Schwern <schwern@pobox.com> Date: Fri, 6 Mar 2009 12:28:19 -0800 Subject: [PATCH 1/3] Fix use B::Keywords qw(:all); It didn't work and also @Filehandles was misspelled as @FileHandles. --- lib/B/Keywords.pm | 7 ++++--- t/export.t | 11 +++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 t/export.t diff --git a/lib/B/Keywords.pm b/lib/B/Keywords.pm index ce7197d..10030cb 100644 --- a/lib/B/Keywords.pm +++ b/lib/B/Keywords.pm @@ -6,10 +6,11 @@ use strict; require Exporter; *import = *import = \&Exporter::import; + use vars qw( @EXPORT_OK %EXPORT_TAGS ); -@EXPORT_OK = qw( @Scalars @Arrays @Hashes @FileHandles @Symbols - @Functions @Barewords ); -%EXPORT_TAGS = ( ':all' => \@EXPORT_OK ); +@EXPORT_OK = qw( @Scalars @Arrays @Hashes @Filehandles @Symbols + @Functions @Barewords ); +%EXPORT_TAGS = ( 'all' => \@EXPORT_OK ); use vars '$VERSION'; $VERSION = '1.08'; diff --git a/t/export.t b/t/export.t new file mode 100644 index 0000000..e56452e --- /dev/null +++ b/t/export.t @@ -0,0 +1,11 @@ +#!/usr/bin/perl -w + +use strict; +use Test::More tests => 7; + +use B::Keywords ":all"; + +for my $name (qw(Scalars Arrays Hashes Filehandles Symbols Functions Barewords)) { + no strict 'refs'; + ok @{$name}, ":all exports \@$name"; +} -- 1.6.2
Subject: 0002--Functions-missing-from-Symbols.patch
From 28c91559ee56788404d5b0c5977b32552e0e90b9 Mon Sep 17 00:00:00 2001 From: Michael G. Schwern <schwern@pobox.com> Date: Fri, 6 Mar 2009 12:29:53 -0800 Subject: [PATCH 2/3] @Functions missing from @Symbols --- lib/B/Keywords.pm | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/lib/B/Keywords.pm b/lib/B/Keywords.pm index 10030cb..1d1195f 100644 --- a/lib/B/Keywords.pm +++ b/lib/B/Keywords.pm @@ -407,7 +407,7 @@ B::Keywords - Lists of reserved barewords and symbol names C<B::Keywords> supplies seven arrays of keywords: C<@Scalars>, C<@Arrays>, C<@Hashes>, C<@Filehandles>, C<@Symbols>, C<@Functions>, and C<@Barewords>. The C<@Symbols> array includes the contents of each -of C<@Scalars>, C<@Arrays>, C<@Hashes>, and C<@Filehandles>. +of C<@Scalars>, C<@Arrays>, C<@Hashes>, C<@Functions> and C<@Filehandles>. Similarly, C<@Barewords> adds a few non-function keywords and operators to the C<@Functions> array. -- 1.6.2
Subject: Re: [rt.cpan.org #43919] Missing $\ in @Scalar
Date: Sun, 8 Mar 2009 20:45:34 -0700
To: bug-B-Keywords [...] rt.cpan.org
From: Joshua ben Jore <twists [...] gmail.com>
On Fri, Mar 6, 2009 at 9:47 PM, Michael G Schwern via RT <bug-B-Keywords@rt.cpan.org> wrote: Show quoted text
> Fri Mar 06 23:47:50 2009: Request 43919 was acted upon. > Transaction: Ticket created by MSCHWERN >       Queue: B-Keywords >     Subject: Missing $\ in @Scalar >   Broken in: 1.08 >    Severity: Normal >       Owner: Nobody >  Requestors: mschwern@cpan.org >      Status: new >  Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=43919 >
Thank you, applied and uploaded 1.09 to PAUSE, also created github repo at http://github.com/jbenjore/b-keywords. Repo & PAUSE permissions granted freely. Josh