File: storable_dbfile.t

package info (click to toggle)
libmldbm-perl 2.05-2.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 132 kB
  • sloc: perl: 376; makefile: 2
file content (69 lines) | stat: -rw-r--r-- 1,643 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/perl -w

use Fcntl;
use MLDBM qw(DB_File Storable);
use Data::Dumper;
use strict;
use Test::More;

plan skip_all => "Optional module (DB_File,Storable) not installed"
  unless eval {
               require Storable;
               require DB_File;
              };
plan tests => 9;

tie my %o, 'MLDBM', 'testmldbm', O_CREAT|O_RDWR, 0640 or die $!;

my $c_scalar = 'c';
my $c = [\$c_scalar];
my $b = {};
my $a = [1, $b, $c];
$b->{a} = $a;
$b->{b} = $a->[1];
$b->{c} = $a->[2];
@o{qw(a b c)} = ($a, $b, $c);
$o{d} = "{once upon a time}";
$o{e} = 1024;
$o{f} = 1024.1024;

my $compare_ok = &MLDBM::_compare([ @o{qw(a b c)} ], [ $a, $b, $c ]);
ok($compare_ok);

is($o{d},"{once upon a time}");
is($o{e},1024);
is($o{f},1024.1024);
#print ( ? "ok 2\n" : "# |$o{d}|\nnot ok 2\n");
#print ($o{e} == 1024 ? "ok 3\n" : "# |$o{e}|\nnot ok 3\n");
#print ($o{f} eq 1024.1024 ? "ok 4\n" : "# |$o{f}|\nnot ok 4\n");

# NEW TEST SEQUENCE
untie %o;
my $obj = tie %o, 'MLDBM', 'testmldbm', O_CREAT|O_RDWR, 0640 or die $!;
$obj->DumpMeth('portable');

$c = [\$c_scalar];
$b = {};
$a = [1, $b, $c];
$b->{a} = $a;
$b->{b} = $a->[1];
$b->{c} = $a->[2];
@o{qw(a b c)} = ($a, $b, $c);
$o{d} = "{once upon a time}";
$o{e} = 1024;
$o{f} = 1024.1024;

$compare_ok = &MLDBM::_compare([ @o{qw(a b c)} ], [ $a, $b, $c]);
ok($compare_ok);

is($o{d},"{once upon a time}");
is($o{e},1024);
is($o{f},1024.1024);
#print ($o{d} eq "{once upon a time}" ? "ok 6\n" : "# |$o{d}|\nnot ok 6\n");
#print ($o{e} == 1024 ? "ok 7\n" : "# |$o{e}|\nnot ok 7\n");
#print ($o{f} eq 1024.1024 ? "ok 8\n" : "# |$o{f}|\nnot ok 8\n");

my $d=[17];
$o{g}=$d;
$d='';
is($o{g}->[0],17);