Re: [PATCH] Make the 'sort' pragma lexically scoped
[p5sagit/p5-mst-13.2.git] / lib / DBM_Filter / t / int32.t
CommitLineData
0e9b1cbd 1
2use strict;
3use warnings;
4use Carp;
5
6require "dbm_filter_util.pl";
7
8use Test::More tests => 22;
9
10BEGIN { use_ok('DBM_Filter') };
11BEGIN { use_ok('SDBM_File') };
12BEGIN { use_ok('Fcntl') };
13
14unlink <Op_dbmx*>;
15END { unlink <Op_dbmx*>; }
16
17my %h1 = () ;
18my $db1 = tie(%h1, 'SDBM_File','Op_dbmx', O_RDWR|O_CREAT, 0640) ;
19
20ok $db1, "tied to SDBM_File";
21
22# store before adding the filter
23
24StoreData(\%h1,
25 {
26 1234 => 5678,
27 -3 => -5,
28 "22" => "88",
29 "-45" => "-88",
30 });
31
32VerifyData(\%h1,
33 {
34 1234 => 5678,
35 -3 => -5,
36 22 => 88,
37 -45 => -88,
38 });
39
40
41eval { $db1->Filter_Push('int32') };
42is $@, '', "push an 'int32' filter" ;
43
44{
45 no warnings 'uninitialized';
46 StoreData(\%h1,
47 {
48 undef() => undef(),
49 "400" => "500",
50 0 => 1,
51 1 => 0,
52 -47 => -6,
53 });
54
55}
56
57undef $db1;
58{
59 use warnings FATAL => 'untie';
60 eval { untie %h1 };
61 is $@, '', "untie without inner references" ;
62}
63
64# read the dbm file without the filter
65my %h2 = () ;
66my $db2 = tie(%h2, 'SDBM_File','Op_dbmx', O_RDWR|O_CREAT, 0640) ;
67
68ok $db2, "tied to SDBM_File";
69
70VerifyData(\%h2,
71 {
72 1234 => 5678,
73 -3 => -5,
74 22 => 88,
75 -45 => -88,
76
77 #undef() => undef(),
78 pack("i", 400) => pack("i", 500),
79 pack("i", 0) => pack("i", 1),
80 pack("i", 1) => pack("i", 0),
81 pack("i", -47) => pack("i", -6),
82 });
83
84undef $db2;
85{
86 use warnings FATAL => 'untie';
87 eval { untie %h2 };
88 is $@, '', "untie without inner references" ;
89}
90