1 |
wakaba |
1.1 |
#!/usr/bin/perl |
2 |
|
|
use strict; |
3 |
|
|
use warnings; |
4 |
|
|
use Test; |
5 |
|
|
use FindBin q($Bin); |
6 |
|
|
BEGIN {plan tests => 5} |
7 |
|
|
use SuikaWiki::DB::Hash; |
8 |
|
|
|
9 |
|
|
my %db; |
10 |
|
|
my $db = new SuikaWiki::DB::Hash |
11 |
|
|
constructor => sub { \%db }, |
12 |
|
|
has_exist => 1; |
13 |
|
|
|
14 |
|
|
unshift @{$db->{event}->{error}}, sub { |
15 |
|
|
my ($self, $event) = @_; |
16 |
|
|
unless ({qw/fatal 1 stop 1 warn 1/}->{$event->{error}->{-def}->{level}}) { |
17 |
|
|
warn "DEBUG: ". $event->{error}->stringify; |
18 |
|
|
} |
19 |
|
|
} if $^W; |
20 |
|
|
|
21 |
|
|
$db->set (test => ['Key'] => 'Value'); |
22 |
|
|
|
23 |
|
|
ok $db->get (test => ['Key']), 'Value'; |
24 |
|
|
ok $db->get (test => ['other']), undef; |
25 |
|
|
|
26 |
|
|
$db->set (test => ['Key', 'Sub'] => 'SubValue'); |
27 |
|
|
ok $db->get (test => ['Key', 'Sub']), 'SubValue'; |
28 |
|
|
|
29 |
|
|
$db->set (test => ['KeySub'] => 'OtherValue'); |
30 |
|
|
ok $db->get (test => ['KeySub']), 'OtherValue'; |
31 |
|
|
ok $db->get (test => ['Key', 'Sub']), 'SubValue'; |
32 |
|
|
|
33 |
|
|
$db->close; |
34 |
|
|
|
35 |
|
|
undef $db; |
36 |
|
|
|