"Fossies" - the Fresh Open Source Software Archive

Member "Apache-Session-1.93/t/99storable.t" (15 Sep 2009, 951 Bytes) of package /linux/www/Apache-Session-1.93.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 use Test::More;
    2 use Test::Deep;
    3 use Test::Exception;
    4 use File::Temp qw[tempdir];
    5 use Cwd qw[getcwd];
    6 
    7 #plan skip_all => "Optional module (Storable) not installed"
    8 #  unless eval {
    9 #               require Storable;
   10 #              };
   11 
   12 plan tests => 2;
   13 
   14 my $package = 'Apache::Session::Serialize::Storable';
   15 use_ok $package;
   16 
   17 my $origdir = getcwd;
   18 my $tempdir = tempdir( DIR => '.', CLEANUP => 1 );
   19 chdir( $tempdir );
   20 
   21 
   22 my $serial   = \&Apache::Session::Serialize::Storable::serialize;
   23 my $unserial = \&Apache::Session::Serialize::Storable::unserialize;
   24 
   25 my $session = {
   26     serialized => undef,
   27     data       => undef,
   28 };
   29 my $simple  = {
   30     foo  => 1,
   31     bar  => 2,
   32     baz  => 'quux',
   33     quux => ['foo', 'bar'],
   34 };
   35 
   36 $session->{data} = $simple;
   37 
   38 &$serial($session);
   39 
   40 $session->{data} = undef;
   41 
   42 &$unserial($session);
   43 
   44 cmp_deeply($simple, $session->{data}, 'session data is correct');
   45 
   46 chdir( $origdir );