Commit | Line | Data |
361dba51 |
1 | package TestSimpleArray; |
2 | |
3 | use 5.6.0; |
4 | |
5 | use strict; |
6 | use warnings; |
7 | |
8 | use Test::More; |
9 | use Test::Exception; |
10 | |
11 | use base 'TestBase'; |
12 | |
13 | sub 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 | |
50 | 1; |
51 | __END__ |