File: 01destroy.t

package info (click to toggle)
libcache-lru-perl 0.04-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 172 kB
  • sloc: perl: 1,432; makefile: 2
file content (38 lines) | stat: -rw-r--r-- 444 bytes parent folder | download | duplicates (4)
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
use strict;
use warnings;

use Test::More;

BEGIN {
    use_ok('Cache::LRU');
};

my $cache = Cache::LRU->new(
    size => 3,
);

$cache->set(a => Foo->new());
is $Foo::cnt, 1;
$cache->set(a => 2);
is $Foo::cnt, 0;

$cache->set(b => Foo->new());
is $Foo::cnt, 1;
$cache->remove('b');
is $Foo::cnt, 0;

done_testing;

package Foo;

our $cnt = 0;

sub new {
    my $klass = shift;
    $cnt++;
    bless {}, $klass;
}

sub DESTROY {
    --$cnt;
}