File: chained_deprecated.t

package info (click to toggle)
libmoosex-attribute-chained-perl 1.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 212 kB
  • sloc: perl: 425; makefile: 2
file content (36 lines) | stat: -rw-r--r-- 745 bytes parent folder | download | duplicates (3)
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
use strict;
use warnings;
use Test::More;

package SimpleChained;
use Moose;

has 'regular_attr' => (
    is      => 'rw',
    isa     => 'Str',
    default => sub { 'hello'; },
);

has 'chained_attr' => (
    traits  => ['Chained'],
    is      => 'rw',
    isa     => 'Bool',
    lazy    => 1,
    default => sub { 0; },
);

has 'writer_attr' => (
    traits => ['Chained'],
    is     => 'rw',
    isa    => 'Str',
    reader => 'get_writer_attr',
    writer => 'set_writer_attr',
);

package main;

my $simple = SimpleChained->new();
is($simple->chained_attr(1)->regular_attr, 'hello', 'chained accessor attribute');
is($simple->chained_attr(0)->set_writer_attr('world')->get_writer_attr, 'world', 'chained writer attribute');

done_testing;