File: refaddr.t

package info (click to toggle)
libmixin-extrafields-perl 0.140003-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 220 kB
  • sloc: perl: 411; makefile: 2
file content (53 lines) | stat: -rw-r--r-- 1,158 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use strict;
use warnings;

use Test::More tests => 13;

BEGIN { require_ok('Mixin::ExtraFields'); }

use lib 't/lib';

my $test_class;

BEGIN {
  $test_class = 'Object::HasExtraFieldsRA';
  use_ok($test_class);
}

my $object = $test_class->new;

isa_ok($object, $test_class);

can_ok(
  $object,
  map { "$_\_extra" } qw(get get_all set exists delete delete_all),
);

is_deeply(
  [ $object->get_all_extra ],
  [ ],
  "when we begin, there are no extras",
);

is_deeply(
  [ $object->get_all_detailed_extra ],
  [ ],
  "...even if we ask for all the details",
);

ok( ! $object->exists_extra('datum'), "there exists no extra 'datum' yet");
is($object->get_extra('datum'), undef, "extra 'datum' shows undef value");
is($object->get_detailed_extra('datum'), undef, "...even with _detailed_");
ok( ! $object->exists_extra('datum'), "getting 'datum' value doesn't autoviv");

$object->set_extra(datum => 10);

ok($object->exists_extra('datum'), "extra 'datum' exists now");
is($object->get_extra('datum'), 10, "extra/datum has the value we supplied");

is(
  $object->{_extra}{datum},
  10,
  "with a fixed hash key, we can go find extras in the hash guts",
);