demerphq / data-dump-streamer Goto Github PK
View Code? Open in Web Editor NEWData::Dump::Streamer - DDS - Accurately serialize a data structure as Perl code.
Home Page: http://search.cpan.org/dist/Data-Dump-Streamer/
Data::Dump::Streamer - DDS - Accurately serialize a data structure as Perl code.
Home Page: http://search.cpan.org/dist/Data-Dump-Streamer/
I'd have just pinged you on irc, but couldn't spot you online.
Git doesn't seem to have been updated, and so CPAN is a fair bit ahead:
diff --git a/lib/Data/Dump/Streamer.pm b/lib/Data/Dump/Streamer.pm
index 61f8f84..83e7015 100644
--- a/lib/Data/Dump/Streamer.pm
+++ b/lib/Data/Dump/Streamer.pm
@@ -35,7 +35,7 @@ $DEBUG=0;
BEGIN{ $HasPadWalker=eval "use PadWalker 0.99; 1"; }
BEGIN {
- $VERSION ='2.38';
+ $VERSION ='2.40';
$XS_VERSION = $VERSION;
$VERSION = eval $VERSION; # used for beta stuff.
@ISA = qw(Exporter DynaLoader);
@@ -2765,6 +2765,9 @@ sub _dump_code {
#$self->{fh}->print("\n#",join " ",keys %$used,"\n");
#$code=~s/^\s*(\([^)]+\)|)\s*/sub$1\n/;
+
+ $code=~s/(\%\{)(\s*\{\}\s*)/$1;$2/g;
+
$code="sub".($code=~/^\s*\(/ ? "" : " ").$code;
if ($self->{style}{indent}) {
$code=~s/\n/"\n"." " x $indent/meg;
@@ -3709,13 +3712,12 @@ sub _get_lexicals {
my $svo=B::svref_2object($cv);
my @pl_array = eval { $svo->PADLIST->ARRAY };
-
my @name_obj = eval { $pl_array[0]->ARRAY };
my %named;
for my $i ( 0..$#name_obj ) {
if ( ref($name_obj[$i])!~/SPECIAL/) {
- $named{$i} = "${ $name_obj[$i]->object_2svref }";
+ $named{$i} = $name_obj[$i]->PV;
}
}
@@ -3748,7 +3750,7 @@ use B::Deparse;
our @ISA=qw(B::Deparse);
my %cache;
-our $VERSION = '2.38';
+our $VERSION = '2.40';
$VERSION= eval $VERSION;
if ( $VERSION ne $Data::Dump::Streamer::VERSION ) {
die "Incompatible Data::Dump::Streamer::Deparser v$VERSION vs Data::Dump::Streamer v$Data::Dump::Streamer::VERSION";
diff --git a/t/globtest.t b/t/globtest.t
index 41cc4fb..5ff7c66 100644
--- a/t/globtest.t
+++ b/t/globtest.t
@@ -66,7 +66,25 @@ vec($_,@#,@#) = @<< == @######### @>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
$off, $width, $bits, $val, $res
.
';
- same( scalar $o->Data(*g)->Out, <<'EXPECT', "data slots (glob/FORMAT)", $o );
+ if ( 5.021009 <= $] ) {
+ same( scalar $o->Data(*g)->Out, <<'EXPECT', "data slots (glob/FORMAT)", $o );
+$VAR1 = *::g;
+*::g = \do { my $v = 'a string' };
+*::g = { a => 'hash' };
+*::g = [
+ 'a',
+ 'list'
+ ];
+format g =
+vec($_,@#,@#) = @<< == @######### @>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+use warnings;
+; $off, $width, $bits, $val, $res
+vec($_,@#,@#) = @<< == @######### @>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+$off, $width, $bits, $val, $res
+.
+EXPECT
+ } else {
+ same( scalar $o->Data(*g)->Out, <<'EXPECT', "data slots (glob/FORMAT)", $o );
$VAR1 = *::g;
*::g = \do { my $v = 'a string' };
*::g = { a => 'hash' };
@@ -81,12 +99,28 @@ vec($_,@#,@#) = @<< == @######### @>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
$off, $width, $bits, $val, $res
.
EXPECT
+
+ }
SKIP: {
skip "no FORMAT refs before ".vstr(5,7)." and this is ".vstr(),
my $NUM=3
unless 5.008 <= $];
+ if ( 5.021009 <= $] ) {
- same( scalar $o->Data(*g{FORMAT})->Out, <<'EXPECT', "data slots (ref/FORMAT)", $o );
+ same( scalar $o->Data(*g{FORMAT})->Out, <<'EXPECT', "data slots (ref/FORMAT)", $o );
+$FORMAT1 = do{ local *F; my $F=<<'_EOF_FORMAT_'; $F=~s/^\s+# //mg; eval $F; die $F.$@ if $@; *F{FORMAT};
+ # format F =
+ # vec($_,@#,@#) = @<< == @######### @>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+ # use warnings;
+ # ; $off, $width, $bits, $val, $res
+ # vec($_,@#,@#) = @<< == @######### @>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+ # $off, $width, $bits, $val, $res
+ # .
+_EOF_FORMAT_
+ };
+EXPECT
+ } else {
+ same( scalar $o->Data(*g{FORMAT})->Out, <<'EXPECT', "data slots (ref/FORMAT)", $o );
$FORMAT1 = do{ local *F; my $F=<<'_EOF_FORMAT_'; $F=~s/^\s+# //mg; eval $F; die $F.$@ if $@; *F{FORMAT};
# format F =
# vec($_,@#,@#) = @<< == @######### @>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
@@ -97,14 +131,35 @@ $FORMAT1 = do{ local *F; my $F=<<'_EOF_FORMAT_'; $F=~s/^\s+# //mg; eval $F; die
_EOF_FORMAT_
};
EXPECT
- my $y=bless *g{FORMAT},"Thank::YSTH";
- #same ( scalar $o->Data(*g{FORMAT})->Out, <<'EXPECT', "data slots (blessed FORMAT)", $o );
- test_dump( {name=>"data slots (blessed FORMAT)",
- verbose=>1,
- pre_eval=>'our ($off,$width,$bits,$val,$res);',
- no_dumper=>1
- },
- $o, *g{FORMAT}, <<'EXPECT' );
+ }
+ my $y=bless *g{FORMAT},"Thank::YSTH";
+ if ( 5.021009 <= $] ) {
+ #same ( scalar $o->Data(*g{FORMAT})->Out, <<'EXPECT', "data slots (blessed FORMAT)", $o );
+ test_dump( {name=>"data slots (blessed FORMAT)",
+ verbose=>1,
+ pre_eval=>'our ($off,$width,$bits,$val,$res);',
+ no_dumper=>1,
+ no_redump=>1,
+ },
+ $o, *g{FORMAT}, <<'EXPECT' );
+$Thank_YSTH1 = bless( do{ local *F; my $F=<<'_EOF_FORMAT_'; $F=~s/^\s+# //mg; eval $F; die $F.$@ if $@; *F{FORMAT};
+ # format F =
+ # vec($_,@#,@#) = @<< == @######### @>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+ # use warnings;
+ # ; $off, $width, $bits, $val, $res
+ # vec($_,@#,@#) = @<< == @######### @>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+ # $off, $width, $bits, $val, $res
+ # .
+_EOF_FORMAT_
+ }, 'Thank::YSTH' );
+EXPECT
+ } else {
+ test_dump( {name=>"data slots (blessed FORMAT)",
+ verbose=>1,
+ pre_eval=>'our ($off,$width,$bits,$val,$res);',
+ no_dumper=>1,
+ },
+ $o, *g{FORMAT}, <<'EXPECT' );
$Thank_YSTH1 = bless( do{ local *F; my $F=<<'_EOF_FORMAT_'; $F=~s/^\s+# //mg; eval $F; die $F.$@ if $@; *F{FORMAT};
# format F =
# vec($_,@#,@#) = @<< == @######### @>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
@@ -115,8 +170,10 @@ $Thank_YSTH1 = bless( do{ local *F; my $F=<<'_EOF_FORMAT_'; $F=~s/^\s+# //mg; ev
_EOF_FORMAT_
}, 'Thank::YSTH' );
EXPECT
- our $gg=1; #silence a warning;
- same( scalar $o->Data(*gg{FORMAT})->Out, <<'EXPECT', "data slots (empty FORMAT)", $o );
+
+ }
+ our $gg=1; #silence a warning;
+ same( scalar $o->Data(*gg{FORMAT})->Out, <<'EXPECT', "data slots (empty FORMAT)", $o );
$VAR1 = undef;
EXPECT
};
diff --git a/t/madness_json.t b/t/madness_json.t
index db13def..5fb055e 100644
--- a/t/madness_json.t
+++ b/t/madness_json.t
@@ -230,7 +230,7 @@ format STDOUT =
else {
$expected_dot = 'undef';
}
- my $jstrue= JSON::XS::decode_json("true");
+ my $jstrue= JSON::XS::decode_json("[true]")->[0];
my %hash = (
UND => undef,
IV => 1,
@@ -392,7 +392,7 @@ EXPECT
}
# In JSON::XS < 3, the boolean class is JSON::XS::Boolean
# In JSON::XS >= 3, the boolean class is JSON::PP::Boolean
- my $json_boolean_class = ref JSON::XS::decode_json("true");
+ my $json_boolean_class = ref JSON::XS::decode_json("[true]")->[0];
$expect =~ s{JSON::XS::Boolean}{$json_boolean_class}g;
same( $dump= $o->Data(\%hash)->Out, template( $expect, expected_dot => $expected_dot ), "", $o);
}
diff --git a/t/test_helper.pl b/t/test_helper.pl
index 1a5ed61..2519636 100644
--- a/t/test_helper.pl
+++ b/t/test_helper.pl
@@ -110,12 +110,19 @@ sub _same {
s/\(0x[0-9a-xA-X]+\)/(0xdeadbeef)/g for $str1, $str2;
my @vars = $str2 =~ m/^(?:my\s*)?(\$\w+)\s*=/gm;
+ for ($str1, $str2) {
+ s/^\s+# use warnings;\n//mg;
+ s/^\s+# use strict[^;]*;\n//mg;
+ s/# ;/#/g;
+ }
+
#warn "@vars";
unless ( ok( "\n" . $str1 eq "\n" . $str2, $name ) ) {
if ( $str2 =~ /\S/ ) {
eval {
print string_diff( "\n" . $str2, "\n" . $str1, "Expected", "Result" );
print "Got:\n" . $str1 . "\n";
+ 1;
}
or do {
print "Expected:\n$str2\nGot:\n$str1\n";
Hi,
Building this fails with perl 5.16.3
see http://www.cpantesters.org/cpan/report/376392de-535c-11e3-a8f2-ae50d605dcb9
I pinned it down to
-Expected
+Result
@30,30 (30)
= };
For test at line 295
For some reason, JSON::XS::decode_json("true"); gives a JSON::PP::Boolean
$ perl -MJSON::XS -MData::Dumper -e 'print Dumper(JSON::XS::decode_json("true"));'
$VAR1 = bless( do{(my $o = 1)}, 'JSON::PP::Boolean' );
My JSON::XS version is 3.01
Interesting stuff:
https://metacpan.org/pod/JSON::PP::Boolean#NOTES-FOR-XS-USERS
Filing this for now, more details may follow :)
Cheers,
Jerome.
Build log:
+ /usr/bin/perl Build.PL --installdirs=vendor '--optimize=-O2 -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none -Wl,-z,relro -Wl,--as-needed -Wl,--gc-sections -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -flto=auto -flto-partition=none -fuse-linker-plugin -Wl,--build-id=sha1'
Installing Data::Dump::Streamer
I can install a shortcut so you can use the package 'DDS'
as though it was 'Data::Dump::Streamer'. This is handy for oneliners.
*Note* that if you select 'no' below and you already
have it installed then it will be removed.
Would you like me to install the shortcut? (yes/no) [no ]Checking prerequisites...
requires:
! Hash::Util is not installed
ERRORS/WARNINGS FOUND IN PREREQUISITES. You may wish to install the versions
of the modules indicated above before proceeding with this installation
Run 'Build installdeps' to install missing prerequisites.
I will also install DDS as an alias.
Created MYMETA.yml and MYMETA.json
Creating new 'Build' script for 'Data-Dump-Streamer' version '2.40'
+ ./Build
Building Data-Dump-Streamer
/usr/bin/gcc -I/usr/lib64/perl5/CORE -DVERSION="2.40" -DXS_VERSION="2.40" -fPIC -c -D_REENTRANT -D_GNU_SOURCE -O2 -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none -fwrapv -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none -g -o lib/Data/Dump/Streamer.o lib/Data/Dump/Streamer.c
lib/Data/Dump/Streamer.xs: In function 'XS_Data__Dump__Streamer_alias_ref':
lib/Data/Dump/Streamer.xs:542:25: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
542 | if (!(dt < SVt_PVAV && st < SVt_PVAV || dt == st && dt <= SVt_PVHV))
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
lib/Data/Dump/Streamer.xs: At top level:
lib/Data/Dump/Streamer.xs:152:1: warning: 'num_q' defined but not used [-Wunused-function]
152 | num_q(register char *s, register STRLEN slen)
| ^~~~~
ExtUtils::Mkbootstrap::Mkbootstrap('blib/arch/auto/Data/Dump/Streamer/Streamer.bs')
/usr/bin/gcc -lpthread -shared -Wl,-z,relro -Wl,--as-needed -Wl,--gc-sections -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -flto=auto -flto-partition=none -fuse-linker-plugin -Wl,--build-id=sha1 -L/usr/local/lib -fstack-protector-strong -lperl -o blib/arch/auto/Data/Dump/Streamer/Streamer.so lib/Data/Dump/Streamer.o
And test suites execution:
```console
+ cd Data-Dump-Streamer-2.40
+ ./Build test
t/as.t .............. ok
t/blessed.t ......... ok
t/dogpound.t ........ ok
t/dump.t ............ ok
t/filter.t .......... ok
t/globtest.t ........ ok
t/hardrefs.t ........ ok
t/impure_madness.t .. ok
t/lexicals.t ........ #
# PadWalker 2.5 is installed
t/lexicals.t ........ ok
t/locked.t .......... 1/11 Unhandled method/subroutine call Data::Dump::Streamer::lock_keys at /home/tkloczko/rpmbuild/BUILD/Data-Dump-Streamer-2.40/blib/lib/Data/Dump/Streamer.pm line 3680.
Data::Dump::Streamer::AUTOLOAD("a8", "a9", "a4", "a5", "a0", "a1", "a2", "a3", ...) called at t/locked.t line 32
# Looks like your test exited with 255 just after 2.
t/locked.t .......... Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 9/11 subtests
t/madness.t ......... ok
t/madness_json.t .... ok
t/madness_w.t ....... ok
t/names.t ........... ok
t/overload.t ........ ok
t/readonly.t ........ ok
t/refaddr.t ......... ok
t/refcount.t ........ ok
t/refelem.t ......... ok
t/reftype.t ......... ok
t/sortkeys.t ........ ok
t/tree.t ............ ok
t/usage.t ........... ok
t/xs_subs.t ......... 1/36 Unhandled method/subroutine call Data::Dump::Streamer::lock_keys at /home/tkloczko/rpmbuild/BUILD/Data-Dump-Streamer-2.40/blib/lib/Data/Dump/Streamer.pm line 3680.
Data::Dump::Streamer::AUTOLOAD("a", 1, "d", 1, "e", 1, "f", 1, ...) called at t/xs_subs.t line 41
# Looks like your test exited with 255 just after 10.
t/xs_subs.t ......... Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 26/36 subtests
Test Summary Report
-------------------
t/locked.t (Wstat: 65280 Tests: 2 Failed: 0)
Non-zero exit status: 255
Parse errors: Bad plan. You planned 11 tests but ran 2.
t/xs_subs.t (Wstat: 65280 Tests: 10 Failed: 0)
Non-zero exit status: 255
Parse errors: Bad plan. You planned 36 tests but ran 10.
Files=24, Tests=334, 4 wallclock secs ( 0.19 usr 0.08 sys + 2.99 cusr 0.43 csys = 3.69 CPU)
Result: FAIL
Failed 2/24 test programs. 0/334 subtests failed.
https://metacpan.org/release/Data-Dump-Streamer/ says that latest version is 2.40 but there is no git tag here.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.