File: moo-c3.t

package info (click to toggle)
libmoo-perl 2.005005-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 840 kB
  • sloc: perl: 2,506; makefile: 2
file content (39 lines) | stat: -rw-r--r-- 761 bytes parent folder | download
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
use strict;
use warnings;

use Test::More;

{
  package MyClassRoot;
  use Moo;
  has root => (is => 'ro');
}

{
  package MyClassLeft;
  use Moo;
  extends 'MyClassRoot';
  has left => (is => 'ro');
}

{
  package MyClassRight;
  use Moo;
  extends 'MyClassRoot';
  has right => (is => 'ro');
}

{
  package MyClassChild;
  use Moo;
  extends 'MyClassLeft', 'MyClassRight';
  has child => (is => 'ro');
}

my $o = MyClassChild->new(root => 1, left => 2, right => 3, child => 4);
is $o->root, 1, 'constructor populates root class attribute';
is $o->left, 2, 'constructor populates left parent attribute';
is $o->right, undef, 'constructor doesn\'t populate right parent attribute';
is $o->child, 4, 'constructor populates child class attribute';

done_testing;