File: rebuild.t

package info (click to toggle)
libmoox-buildargs-perl 0.08-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 144 kB
  • sloc: perl: 300; makefile: 2
file content (27 lines) | stat: -rwxr-xr-x 674 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/env perl
use 5.008001;
use strictures 2;
use Test2::V0;

{
    package Foo;
    use 5.008001;
    use strictures 2;

    use Moo;
    with 'MooX::Rebuild';
    has get_bar => ( is=>'ro', init_arg=>'bar' );
    has baz => ( is=>'ro' );
}

my $orig = Foo->new( bar=>11, baz=>22 );

my $clone1 = $orig->rebuild();
is( $clone1->get_bar(), 11, 'cloned attribute with different init_arg' );
is( $clone1->baz(), 22, 'cloned attribute with same init_arg' );

my $clone2 = $orig->rebuild( baz=>33 );
is( $clone2->get_bar(), 11, 'cloned attribute with different init_arg' );
is( $clone2->baz(), 33, 'cloned attribute with same init_arg, but custom value' );

done_testing;