requires => {
perl => '5.6.0',
'Digest::MD5' => '1.00',
+ 'Fcntl' => '0.01',
'Scalar::Util' => '1.14',
},
optional => {
},
build_requires => {
+ 'File::Path' => '0.01',
+ 'File::Temp' => '0.01',
+ 'Temp::Class' => '0.01',
'Test::More' => '0.47',
'Test::Exception' => '0.21',
- 'File::Temp' => '0.01',
},
create_makefile_pl => 'traditional',
add_to_cleanup => [
--- /dev/null
+package Test1;
+
+use 5.6.0;
+
+use strict;
+use warnings;
+
+use base 'TestBase';
+use base 'TestSimpleHash';
+
+sub setup : Test(startup) {
+ my $self = shift;
+
+ $self->{db} = DBM::Deep->new( $self->new_file );
+
+ return;
+}
+
+1;
+__END__
--- /dev/null
+package TestBase;
+
+use 5.6.0;
+
+use strict;
+use warnings;
+
+use File::Path ();
+use File::Temp ();
+use Fcntl qw( :flock );
+
+use base 'Test::Class';
+
+use DBM::Deep;
+
+sub setup_dir : Test(startup) {
+ my $self = shift;
+
+ $self->{workdir} = File::Temp::tempdir();
+
+ return;
+}
+
+sub new_file {
+ my $self = shift;
+
+ my ($fh, $filename) = File::Temp::tempfile(
+ 'tmpXXXX', DIR => $self->{workdir}, CLEANUP => 1,
+ );
+ flock( $fh, LOCK_UN );
+
+ return $filename;
+}
+
+sub remove_dir : Test(shutdown) {
+ my $self = shift;
+
+ File::Path::rmtree( $self->{workdir} );
+
+ return;
+}
+
+1;
+__END__
--- /dev/null
+package TestSimpleHash;
+
+use 5.6.0;
+
+use strict;
+use warnings;
+
+use Test::More;
+use Test::Exception;
+
+use base 'TestBase';
+
+sub assignment_direct : Test( no_plan ) {
+ my $self = shift;
+
+ my $db = $self->{db};
+ while ( my ($k,$v) = each %{$self->{data}} ) {
+ $db->{$k} = $v;
+
+ ok( $db->exists( $k ) );
+ ok( exists $db->{$k} );
+
+ is( $db->get($k), $v );
+ is( $db->fetch($k), $v );
+ is( $db->{$k}, $v );
+ }
+}
+
+1;
+__END__
--- /dev/null
+use 5.6.0;
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+
+use DBM::Deep;
+
+use Test1;
+
+my $test = Test1->new(
+ data => {
+ key1 => 'value1',
+ key2 => undef,
+ key3 => 1.23,
+ },
+);
+
+$test->runtests;