File: 011.1-attributes.t

package info (click to toggle)
libdata-printer-perl 1.002001-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 748 kB
  • sloc: perl: 4,364; makefile: 7; sh: 1
file content (57 lines) | stat: -rw-r--r-- 1,465 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use strict;
use warnings;
use Test::More;
use Data::Printer::Common;
use Data::Printer::Object;

plan tests => 4;

test_moo();
test_moose();
exit;

sub test_moo {
    SKIP: {
        my $moo_error = Data::Printer::Common::_tryme(
            'package TestMooClass; use Moo; has bar => (is => "ro", required => 0); no Moo; 1;'
        );
        skip 'Moo not found', 2 if $moo_error;

        my $ddp = Data::Printer::Object->new( colored => 0 );
        my $obj = TestMooClass->new;
        my $parsed = $ddp->parse($obj);
        like(
            $parsed,
            qr/attributes \(1\): bar$/m,
            'Moo object parsed properly'
        );
        unlike(
            $parsed,
            qr/roles/,
            'No role output displayed since no roles were used.'
        );
    };
}

sub test_moose {
    SKIP: {
        my $moose_error = Data::Printer::Common::_tryme(
            'package TestMooseClass; use Moose; has foo => (is => "rw", required => 0); no Moose; 1;'
        );
        skip 'Moose not found', 2 if $moose_error;

        my $ddp = Data::Printer::Object->new( colored => 0 );
        my $obj = TestMooseClass->new;
        my $parsed = $ddp->parse($obj);
        like(
            $parsed,
            qr/attributes \(1\): foo$/m,
            'Moose object parsed properly'
        );
        unlike(
            $parsed,
            qr/roles/,
            'No role output displayed since no roles were used.'
        );
    };
}