Update Module::Build to 0.33_05
[p5sagit/p5-mst-13.2.git] / lib / autodie / t / dbmopen.t
1 #!/usr/bin/perl -w
2 use strict;
3 use Test::More qw(no_plan);
4
5 use constant ERROR_REGEXP => qr{Can't dbmopen\(%hash, 'foo/bar/baz', 0666\):};
6
7 my $return = "default";
8
9 eval {
10     $return = dbmopen(my %foo, "foo/bar/baz", 0666);
11 };
12
13 ok(!$return, "Sanity: dbmopen usually returns false on failure");
14 ok(!$@,      "Sanity: dbmopen doesn't usually throw exceptions");
15
16 eval {
17     use autodie;
18
19     dbmopen(my %foo, "foo/bar/baz", 0666);
20 };
21
22 ok($@, "autodie allows dbmopen to throw errors.");
23 isa_ok($@, "autodie::exception", "... errors are of the correct type");
24
25 like($@, ERROR_REGEXP, "Message should include number in octal, not decimal");
26
27 eval {
28     use autodie;
29
30     my %bar = ( foo => 1, bar => 2 );
31
32     dbmopen(%bar, "foo/bar/baz", 0666);
33 };
34
35 like($@, ERROR_REGEXP, "Correct formatting even with non-empty dbmopen hash");
36