File: 03_mldbm.pl

package info (click to toggle)
libtm-perl 1.56-7
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 3,692 kB
  • ctags: 1,084
  • sloc: perl: 35,266; makefile: 48
file content (31 lines) | stat: -rw-r--r-- 793 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
my ($tmp);
use IO::File;
use POSIX qw(tmpnam);
do { $tmp = tmpnam() ;  } until IO::File->new ($tmp, O_RDWR|O_CREAT|O_EXCL);

END { unlink ($tmp) || warn "cannot unlink tmp file '$tmp'"; }

{
    use TM::Materialized::MLDBM;
    my $tm = new TM::Materialized::MLDBM (file => $tmp);
    
    $tm->assert (Assertion->new (
				 type => 'isa',
				 roles => [ 'instance', 'class' ],
				 players => [ 'sacklpicka', 'cat' ]));
    $tm->sync_out;
}

utime time + 1, time + 1, $tmp; # lets pretend that the file has been changed

{
    use TM::Materialized::MLDBM;
    my $tm = new TM::Materialized::MLDBM (file => $tmp);

    use Data::Dumper;
    warn Dumper [ $tm->tids ('cat') ]; # nothing there

    $tm->sync_in;
    warn Dumper [ $tm->instances ($tm->tids ('cat')) ]; # sacklpicka is back!
}