File: refcount.t

package info (click to toggle)
libdata-dump-streamer-perl 2.08-40-2
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 408 kB
  • ctags: 101
  • sloc: perl: 2,669; makefile: 51
file content (52 lines) | stat: -rwxr-xr-x 1,193 bytes parent folder | download
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
51
52
use Test::More tests => 18;
use Devel::Peek;

#$Id: refcount.t 26 2006-04-16 15:18:52Z demerphq $#

BEGIN { use_ok( 'Data::Dump::Streamer', 
            qw(refcount sv_refcount is_numeric looks_like_number weak_refcount weaken isweak)); 
}

my $sv="Foo";
my $rav=[];
my $rhv={};

is sv_refcount($sv),1,"sv_refcount";
is refcount($rav),1,"refcount av";
is refcount($rhv),1,"refcount hv";

is refcount(\$sv),2,'refcount \\$foo';

my $ref=\$sv;

is sv_refcount($sv),2,'sv_refcount after';
is refcount(\$sv),3,'refcount after';

SKIP: {
    skip ( "No Weak Refs", 3 )
        unless eval { weaken($ref) };

    is isweak($ref),1,"is weakened";
    is sv_refcount($sv),2,"weakened sv_refcount";
    is weak_refcount($sv),1,"weak_refcount";
    is refcount(\$sv),3,"weakened refcount";
}           

{
    use strict;
    my $sv="Foo";
    my $iv=100;
    my $nv=1.234;
    my $dbl=1e40;
    
    my %hash=(100=>1,1.234=>1,1e40=>1);
    
    for my $t ( [$sv,''], 
                [$iv,1], [$nv,1], 
                [$dbl,1], 
                map {[$_,'']} keys %hash
    ){
        is is_numeric($t->[0]),$t->[1],"Test:".$t->[0];
    }
}
__END__