r1039 - in packages/libdata-dumper-simple-perl/branches/upstream/current: . lib/Data/Dumper t
Gunnar Wolf
gwolf@costa.debian.org
Wed, 25 May 2005 14:57:59 +0000
Author: gwolf
Date: 2005-05-25 14:57:58 +0000 (Wed, 25 May 2005)
New Revision: 1039
Added:
packages/libdata-dumper-simple-perl/branches/upstream/current/t/40noparens.t
Modified:
packages/libdata-dumper-simple-perl/branches/upstream/current/Changes
packages/libdata-dumper-simple-perl/branches/upstream/current/MANIFEST
packages/libdata-dumper-simple-perl/branches/upstream/current/META.yml
packages/libdata-dumper-simple-perl/branches/upstream/current/Makefile.PL
packages/libdata-dumper-simple-perl/branches/upstream/current/lib/Data/Dumper/Simple.pm
packages/libdata-dumper-simple-perl/branches/upstream/current/t/10dump.t
Log:
Load /tmp/tmp.l6324Y/libdata-dumper-simple-perl-0.07 into
packages/libdata-dumper-simple-perl/branches/upstream/current.
Modified: packages/libdata-dumper-simple-perl/branches/upstream/current/Changes
===================================================================
--- packages/libdata-dumper-simple-perl/branches/upstream/current/Changes 2005-05-25 14:57:14 UTC (rev 1038)
+++ packages/libdata-dumper-simple-perl/branches/upstream/current/Changes 2005-05-25 14:57:58 UTC (rev 1039)
@@ -1,12 +1,28 @@
Revision history for Perl extension Data::Dumper::Simple.
-0.01 Fri Jul 30 16:29:14 PDT 2004
- - original version; created by make_project 0.1
+0.07 Thu May 19 2005
+ - Implemented patch from Tom Phoenix that makes parentheses
+ optional (and a doc fix, too).
+ - Fixed little-known bug that triggered indirect method call
+ syntax. You can now do "diag Dumper($foo)" or
+ "diag Dumper $foo" if you wish.
-0.02 Sat Jul 31 12:30:00 PDT 2004
- - fixed tiny bug with how scalars were represented when
- a reference to one is taken.
+0.06 Monday Aug 2 2004
+ - Fixed variable with whitespace bug ($foo[ 4 ]).
+ Added autowarning.
+ Added ability to choose own name for &Dumper (helps with
+ namespace collisions).
+0.05 Sun Aug 01 2004
+ - taking a reference to an array or hash now lists the data
+ structure as a reference in the output. Shoulda done that
+ the first time.
+
+ Perl Barbie says "Source filtering is *hard*"
+
+0.04 Sun Aug 01 2004
+ - Commenting out a Dumper statement now works.
+
0.03 Sat Jul 31 15:30:00 PDT 2004
- Changed the filter from "code" to "executable". This
will sometimes mean that quoted data could be inappropriately
@@ -14,18 +30,9 @@
Filter::Simple. Still, this is a debugging module and it
should not really be an issue.
-0.04 Sun Aug 01 2004
- - Commenting out a Dumper statement now works.
+0.02 Sat Jul 31 12:30:00 PDT 2004
+ - fixed tiny bug with how scalars were represented when
+ a reference to one is taken.
-0.05 Sun Aug 01 2004
- - taking a reference to an array or hash now lists the data
- structure as a reference in the output. Shoulda done that
- the first time.
-
- Perl Barbie says "Source filtering is *hard*"
-
-0.06 Monday Aug 2 2004
- - Fixed variable with whitespace bug ($foo[ 4 ]).
- Added autowarning.
- Added ability to choose own name for &Dumper (helps with
- namespace collisions).
+0.01 Fri Jul 30 16:29:14 PDT 2004
+ - original version; created by make_project 0.1
Modified: packages/libdata-dumper-simple-perl/branches/upstream/current/MANIFEST
===================================================================
--- packages/libdata-dumper-simple-perl/branches/upstream/current/MANIFEST 2005-05-25 14:57:14 UTC (rev 1038)
+++ packages/libdata-dumper-simple-perl/branches/upstream/current/MANIFEST 2005-05-25 14:57:58 UTC (rev 1039)
@@ -7,3 +7,4 @@
t/10dump.t
t/20import.t
t/30autowarn.t
+t/40noparens.t
Modified: packages/libdata-dumper-simple-perl/branches/upstream/current/META.yml
===================================================================
--- packages/libdata-dumper-simple-perl/branches/upstream/current/META.yml 2005-05-25 14:57:14 UTC (rev 1038)
+++ packages/libdata-dumper-simple-perl/branches/upstream/current/META.yml 2005-05-25 14:57:58 UTC (rev 1039)
@@ -1,7 +1,7 @@
# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: Data-Dumper-Simple
-version: 0.06
+version: 0.07
version_from: lib/Data/Dumper/Simple.pm
installdirs: site
requires:
Property changes on: packages/libdata-dumper-simple-perl/branches/upstream/current/Makefile.PL
___________________________________________________________________
Name: svn:executable
-
+ *
Modified: packages/libdata-dumper-simple-perl/branches/upstream/current/lib/Data/Dumper/Simple.pm
===================================================================
--- packages/libdata-dumper-simple-perl/branches/upstream/current/lib/Data/Dumper/Simple.pm 2005-05-25 14:57:14 UTC (rev 1038)
+++ packages/libdata-dumper-simple-perl/branches/upstream/current/lib/Data/Dumper/Simple.pm 2005-05-25 14:57:58 UTC (rev 1039)
@@ -1,13 +1,30 @@
package Data::Dumper::Simple;
-$REVISION = '$Id: Simple.pm,v 1.9 2004/08/03 04:48:09 ovid Exp $';
-$VERSION = '0.06';
+$REVISION = '$Id: Simple.pm,v 1.10 2005/05/20 01:37:08 ovid Exp $';
+$VERSION = '0.07';
use Filter::Simple;
use Data::Dumper ();
my $DUMPER_FUNCTION = 'Dumper';
my $AUTOWARN;
+my $COMMA = qr/(?:,|=>)/;
+my $ATOM = qr/(?!\d)[[:word:]]+/;
+my $SEP = qr/::/;
+my $NAME = qr/$SEP?$ATOM(?:$SEP$ATOM)*/;
+
+my $SCALAR = qr/\$$NAME/;
+my $ARRAY_ELEM = qr/\$$NAME\[[^]]+\]/;
+my $ARRAY = qr/\@$NAME/;
+my $HASH_ELEM = qr/\$$NAME\{[^}]+\}/;
+my $HASH = qr/\%$NAME/;
+
+my $VAR = qr/(?:$ARRAY|$HASH|$ARRAY_ELEM|$HASH_ELEM|$SCALAR)/;
+my $END_STMT = qr/(?=\s*[;}])/;
+
+my $ARG_LIST = qr/$VAR(?:\s*$COMMA\s*$VAR)*$END_STMT/;
+my $PAREN_LIST = qr/\([^)]+\)/;
+
sub import {
my ($class, @args) = @_;
@args = _validate_args(@args);
@@ -19,15 +36,17 @@
FILTER_ONLY
executable => sub { # not using code due to a possible bug in Filter::Simple
s{
- $DUMPER_FUNCTION\s*\(([^)]+)\)
+ $DUMPER_FUNCTION\s*($PAREN_LIST|$ARG_LIST)
}{
- my ($references, $names) = _munge_argument_list($1);
+ my $args = $1;
+ $args =~ s/^\((.*)\)$/$1/s; # strip parens, if any
+ my ($references, $names) = _munge_argument_list($args);
# keep it on a single line so users can comment it out
my $output = "Data::Dumper->Dump( [$references], [qw/$names/] )";
if ($AUTOWARN) {
$output = "$AUTOWARN($output)";
}
- $output
+ "($output)"; # parens prevent accidental indirect method syntax
}gex
};
@@ -91,6 +110,7 @@
use Data::Dumper::Simple;
warn Dumper($scalar, @array, %hash);
warn Dumper($scalar, \@array, \%hash);
+ warn Dumper $scalar, @array, %hash;
=head1 ABSTRACT
@@ -294,10 +314,22 @@
some items being dumped. I've fixed that, but made the module a wee bit less
robust. This will hopefully be fixed in the next release of Text::Balanced.
-=item * The parentheses are mandatory.
+=item * Line numbers may be wrong
-Sorry 'bout that.
+Because this module uses a source filter, line numbers reported from
+syntax or other errors may be thrown off a little.
+This is probably a bug in the source filter implementation, which should
+use C<#line> directives. As a workaround until this is fixed, put a
+directive (such as C<#line 10000>) a few lines ahead of the suspected
+bug. If the error is reported as happening in line 10007, you know to
+look about eight lines below your directive for the bug. Be sure to
+remove the bogus directive once you find the bug!
+
+=item * The parentheses are optional, but the syntax isn't bulletproof
+
+If you try, it's not hard to confuse the parser. Patches welcome.
+
=back
Note that this is not a drop-in replacement for C<Data::Dumper>. If you
Property changes on: packages/libdata-dumper-simple-perl/branches/upstream/current/t/10dump.t
___________________________________________________________________
Name: svn:executable
-
+ *
Added: packages/libdata-dumper-simple-perl/branches/upstream/current/t/40noparens.t
===================================================================
--- packages/libdata-dumper-simple-perl/branches/upstream/current/t/40noparens.t 2005-05-25 14:57:14 UTC (rev 1038)
+++ packages/libdata-dumper-simple-perl/branches/upstream/current/t/40noparens.t 2005-05-25 14:57:58 UTC (rev 1039)
@@ -0,0 +1,66 @@
+#!/usr/bin/perl
+# '$Id: 40noparens.t,v 1.1 2005/05/20 01:36:47 ovid Exp $';
+use warnings;
+use strict;
+use Test::More tests => 6;
+
+my $CLASS;
+BEGIN
+{
+ chdir 't' if -d 't';
+ unshift @INC => '../lib';
+ $CLASS = 'Data::Dumper::Simple';
+ use_ok($CLASS) or die;
+}
+
+my $scalar = 'Ovid';
+my @array = qw/Data Dumper Simple Rocks!/;
+my %hash = (
+ at => 'least',
+ I => 'hope',
+ it => 'does',
+);
+
+my $expected = Data::Dumper->Dump(
+ [$scalar, \@array, \%hash],
+ [qw/$scalar *array *hash/]
+);
+
+my $got = Dumper $scalar, @array, %hash;
+
+is($got, $expected, 'Having no parens is allowed');
+
+$got = Dumper
+ $scalar,
+ @array,
+ %hash;
+
+is($got, $expected, '... even split among several lines');
+
+$got = Dumper
+ $scalar =>
+ @array =>
+ %hash
+ ;
+
+is($got, $expected, '... or using big arrows, or whitespace before the semicolon');
+
+{
+ $got = Dumper
+ $scalar,
+ @array,
+ %hash
+}
+
+is($got, $expected, '... or at the end of a block (no semicolon)');
+
+$got = Dumper
+ $hash{I},
+ $array[3];
+
+$expected = Data::Dumper->Dump(
+ [$hash{I}, $array[3]],
+ [qw/$hash{I} $array[3]/]
+);
+
+is($got, $expected, '... or with aggregate elements');