File: Serialize.t_maint

package info (click to toggle)
libthread-serialize-perl 1.00-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 108 kB
  • sloc: perl: 46; makefile: 4
file content (50 lines) | stat: -rw-r--r-- 1,324 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
BEGIN {				# Magic Perl CORE pragma
    if ($ENV{PERL_CORE}) {
        chdir 't' if -d 't';
        @INC = '../lib';
    }
}

use Test::More tests => 16;

use Thread::Serialize; # can't fake bare import call yet with Test::More
use_ok( 'Thread::Serialize' );
can_ok( 'Thread::Serialize',qw(
 freeze
 thaw
) );
ok( !defined( $Thread::Serialize::no_external_perl ),
 "Check flag being unset" );

test();

delete $INC{'Thread/Serialize.pm'};
$Thread::Serialize::no_external_perl = 1;
require Thread::Serialize;
is( $Thread::Serialize::no_external_perl,'Signature obtained locally',
 "Check flag being set and changed" );

test();

sub test {
    my $scalar = '1234';
    my $frozen = freeze( $scalar );
    is( thaw($frozen),$scalar,			'check contents' );

    my @array = qw(a b c);
    $frozen = freeze( @array );
    is( join('',thaw($frozen)),join('',@array),	'check contents' );

    $frozen = freeze( \@array );
    is( join('',@{thaw($frozen)}),join('',@array),	'check contents' );

    $frozen = freeze();
    is( join('',thaw($frozen)),'',			'check contents' );

    $frozen = freeze( undef );
    ok( !defined( thaw($frozen) ),			'check contents' );

    my %hash = (a => 'A', b => 'B', c => 'C');
    $frozen = freeze( \%hash );
    is( join('',sort %{thaw($frozen)}),join('',sort %hash),'check contents' );
} #test