File: dump.t

package info (click to toggle)
libclass-std-fast-perl 0.0.8-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 216 kB
  • sloc: perl: 575; makefile: 2
file content (48 lines) | stat: -rw-r--r-- 1,092 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
package MyBase;
use Class::Std::Fast;
{
    my %public_of  :ATTR( :init_arg<pub> );
    my %private_of :ATTR;

    sub BUILD {
        my ($self, $ident) = @_;

        $private_of{$ident} = 'base priv';
    }
}

package MyDer;
use base qw( MyBase );
use Class::Std::Fast;
{
    my %public_of  :ATTR( :init_arg<pub> );
    my %private_of :ATTR;

    sub BUILD {
        my ($self, $ident) = @_;

        $private_of{$ident} = 'der priv';
    }
}


package main;

my $rep = MyDer->new({
              MyBase => { pub => 'base pub' },
              MyDer  => { pub => 'der pub'  },
          })->_DUMP;

my $hash = eval $rep;

use Test::More 'no_plan';

ok !ref $rep                              => 'Representation is string';

ok $hash                                  => 'Representation is valid';

is $hash->{MyBase}{pub}, 'base pub'       => 'Public base attribute'; 
is $hash->{MyBase}{'????'}, 'base priv'   => 'Private base attribute'; 

is $hash->{MyDer}{pub}, 'der pub'         => 'Public derived attribute'; 
is $hash->{MyDer}{'????'}, 'der priv'     => 'Private derived attribute';