6 require "../t/charset_tools.pl";
11 eval { require Encode; };
14 print "1..0 # Skip: Encode is not available\n";
20 require "dbm_filter_util.pl";
22 use Test::More tests => 26;
24 BEGIN { use_ok('DBM_Filter') };
28 foreach (qw/SDBM_File ODBM_File NDBM_File GDBM_File DB_File/) {
29 if ($Config{extensions} =~ /\b$_\b/) {
36 BEGIN { use_ok('Fcntl') };
37 BEGIN { use_ok('charnames', qw{greek})};
39 use charnames qw{greek};
42 END { unlink <Op_dbmx*>; }
45 my $db1 = tie(%h1, $db_file,'Op_dbmx', O_RDWR|O_CREAT, 0640) ;
47 ok $db1, "tied to $db_file";
49 eval { $db1->Filter_Push('encode' => 'blah') };
50 like $@, qr/^Encoding 'blah' is not available/, "push an illegal filter" ;
52 eval { $db1->Filter_Push('encode') };
53 is $@, '', "push an 'encode' filter (default to utf-8)" ;
57 no warnings 'uninitialized';
61 'alpha' => "\N{alpha}",
62 "\N{gamma}"=> "gamma",
69 local $TODO = "Currently broken on EBCDIC" if $::IS_EBCDIC;
72 'alpha' => "\N{alpha}",
74 "\N{gamma}"=> "gamma",
79 eval { $db1->Filter_Pop() };
80 is $@, '', "pop the 'utf8' filter" ;
83 skip "Encode doesn't currently work for most filters on EBCDIC, including 8859-16", 11 if $::IS_EBCDIC || $::IS_EBCDIC;
84 # Actually the only thing failing below is the euro, because that's the
85 # only thing that's added in 8859-16.
86 eval { $db1->Filter_Push('encode' => 'iso-8859-16') };
87 is $@, '', "push an 'encode' filter (specify iso-8859-16)" ;
89 use charnames qw{:full};
92 'euro' => "\N{EURO SIGN}",
97 use warnings FATAL => 'untie';
99 is $@, '', "untie without inner references" ;
102 # read the dbm file without the filter
104 my $db2 = tie(%h2, $db_file,'Op_dbmx', O_RDWR|O_CREAT, 0640) ;
106 ok $db2, "tied to $db_file";
110 'alpha' => byte_utf8a_to_utf8n("\xCE\xB1"),
111 'beta' => byte_utf8a_to_utf8n("\xCE\xB2"),
112 byte_utf8a_to_utf8n("\xCE\xB3") => "gamma",
113 'euro' => uni_to_native("\xA4"),
119 use warnings FATAL => 'untie';
121 is $@, '', "untie without inner references" ;