Data-Serializer

 view release on metacpan or  search on metacpan

t/serializer-testlib  view on Meta::CPAN

                        'PHP::Serialization'    => {
                                                simpleobject  => 0,
                                                simplescalar  => 0,
                                                simplearray  => $counts{simplearray},
                                                complexarray => $counts{complexarray},
                                                selfrefarray  => $counts{selfrefarray},
                                                simplehash   => $counts{simplehash},
                                                utf8hash   => $counts{utf8hash},
                                                complexhash  => $counts{complexhash},
                                                selfrefhash  => $counts{selfrefhash},
                                           },
                        'Bencode'  => {
                                                simpleobject  => 0,	#Bencode does not support serializing objects
                                                simplescalarref  => 0,	#Bencode does not support serializing saclar references
                                                simplescalar  => $counts{simplescalar},
                                                trickyscalar  => $counts{trickyscalar},
                                                simplearray  => $counts{simplearray},
                                                complexarray => $counts{complexarray},
                                                selfrefarray  => $counts{selfrefarray},
                                                simplehash   => $counts{simplehash},
                                                utf8hash   => $counts{utf8hash},
                                                complexhash  => $counts{complexhash},
                                                selfrefhash  => $counts{selfrefhash},
                                           },
                        'Convert::Bencode'  => {
                                                simpleobject  => 0,	#Convert::Bencode does not support serializing objects
                                                simplescalarref  => 0,	#Convert::Bencode does not support serializing saclar references
                                                simplescalar  => $counts{simplescalar},
                                                trickyscalar  => $counts{trickyscalar},
                                                simplearray  => $counts{simplearray},
                                                complexarray => $counts{complexarray},
                                                selfrefarray  => $counts{selfrefarray},
                                                simplehash   => $counts{simplehash},
                                                utf8hash   => $counts{utf8hash},
                                                complexhash  => $counts{complexhash},
                                                selfrefhash  => $counts{selfrefhash},
                                           },
                        'Convert::Bencode_XS'  => {
                                                simpleobject  => 0,	#Convert::Bencode_XS does not support serializing objects
                                                simplescalarref  => 0,	#Convert::Bencode_XS does not support serializing saclar references
                                                simplescalar  => $counts{simplescalar},
                                                trickyscalar  => $counts{trickyscalar},
                                                simplearray  => $counts{simplearray},
                                                complexarray => $counts{complexarray},
                                                selfrefarray  => $counts{selfrefarray},
                                                simplehash   => $counts{simplehash},
                                                utf8hash   => $counts{utf8hash},
                                                complexhash  => $counts{complexhash},
                                                selfrefhash  => $counts{selfrefhash},
                                           },
                  );

%features = (
                'objraw'     	 => [],
                'raw'     	 => [],
                'rawnew'     	 => [],
                'non-portable'   => [],
                'basic'     	 => [],
                'cgopt'     	 => [],
                'xmldumpopt'   	 => [],
                'encryption'     => [qw (Crypt::CBC Crypt::Blowfish)],
                'compresszlib'    => [qw (Compress::Zlib)],
                'compressppmd'    => [qw (Compress::PPMd)],
                'encoding'       => [qw (MIME::Base64)],
                'md5'       => [qw (Crypt::CBC Crypt::Blowfish Digest::MD5)],
                'sha1'     	 => [qw (Crypt::CBC Crypt::Blowfish Digest::SHA1)],
                'sha-256'     	 => [qw (Crypt::CBC Crypt::Blowfish Digest::SHA)],
                );


sub run_test {
        my ($T,$serializer,$test,$features) = @_;
        $T->msg("Test $serializer $test $features");  # message for the log
	my $obj;
        my @features = (split(" ", $features));
        if (grep {/^objraw$/} @features) {
        	$obj = Data::Serializer::Raw->new(serializer=>$serializer);
	} else {
        	$obj = Data::Serializer->new(serializer=>$serializer);
	}
        foreach my $feature (@features) {
                if ($feature eq 'basic') {
                        #do nothing special
                } elsif ($feature eq 'non-portable') {
                        #make sure we work without ascii armoring
                        $obj->portable(0);
                } elsif ($feature eq 'encryption') {
                        #setup a secret so we use encryption on this run
                        $obj->secret('test');
                } elsif ($feature eq 'md5') {
			#only relevant if we have a secret
                        $obj->secret('test');
                        $obj->digester('MD5');
                } elsif ($feature eq 'sha1') {
			#only relevant if we have a secret
                        $obj->secret('test');
                        $obj->digester('SHA-256');
                } elsif ($feature eq 'sha-256') {
			#only relevant if we have a secret
                        $obj->secret('test');
                        $obj->digester('SHA-256');
                } elsif ($feature eq 'compresszlib') {
                        # use compression 
                        $obj->compress(1);
                        $obj->compressor("Compress::Zlib");
                } elsif ($feature eq 'compressppmd') {
                        # use compression 
                        $obj->compress(1);
                        $obj->compressor("Compress::PPMd");
                } elsif ($feature eq 'encoding') {
                        # test alternate encoding
                        $obj->encoding('b64');
                } elsif ($feature eq 'cgopt') {
                        # test options for Config::General
                        $obj->options( {
                                         -LowerCaseNames       => 1,
                                         -UseApacheInclude     => 1,
                                         -MergeDuplicateBlocks => 1,
                                         -AutoTrue             => 1,
                                         -InterPolateVars      => 1
                                       });
                } elsif ($feature eq 'xmldumpopt') {
                        # test options for XML::Dumper
                        $obj->options( {
                                         dtd       => 1,
                                       });
                }



( run in 1.122 second using v1.01-cache-2.11-cpan-e1769b4cff6 )