Removed final vestiges of misunderstandings
[dbsrgits/DBM-Deep.git] / t / lib / TestSimpleArray.pm
CommitLineData
361dba51 1package TestSimpleArray;
2
3use 5.6.0;
4
5use strict;
6use warnings;
7
8use Test::More;
9use Test::Exception;
10
11use base 'TestBase';
12
13sub A_assignment : Test( 37 ) {
14 my $self = shift;
15 my $db = $self->{db};
16
17 my @keys = 0 .. $#{$self->{data}};
18
19 push @keys, $keys[0] while @keys < 5;
20
21 cmp_ok( @$db, '==', 0 );
22
23 foreach my $k ( @keys[0..4] ) {
24 ok( !exists $db->[$k] );
25 ok( !$db->exists( $k ) );
26 }
27
28 $db->[$keys[0]] = $self->{data}[$keys[1]];
29 $db->push( $self->{data}[$keys[2]] );
30 $db->put( $keys[2] => $self->{data}[$keys[3]] );
31 $db->store( $keys[3] => $self->{data}[$keys[4]] );
32 $db->unshift( $self->{data}[$keys[0]] );
33
34 foreach my $k ( @keys[0..4] ) {
35 ok( $db->exists( $k ) );
36 ok( exists $db->[$k] );
37
38 is( $db->[$k], $self->{data}[$k] );
39 is( $db->get($k), $self->{data}[$k] );
40 is( $db->fetch($k), $self->{data}[$k] );
41 }
42
43 if ( @keys > 5 ) {
44 $db->[$_] = $self->{data}[$_] for @keys[5..$#keys];
45 }
46
47 cmp_ok( @$db, '==', @keys );
48}
49
501;
51__END__