File: in_roles.t

package info (click to toggle)
libtest-moose-more-perl 0.050-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 512 kB
  • sloc: perl: 755; makefile: 2
file content (49 lines) | stat: -rw-r--r-- 1,266 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use strict;
use warnings;

use Test::Builder::Tester;
use Test::More;
use Test::Moose::More;
use TAP::SimpleOutput 0.009 'counters';

{
    package TestRole;
    use Moose::Role;
    use namespace::autoclean;

    has thinger => (is => 'ro', predicate => 'has_thinger');
}

subtest 'a standalone run of validate_attribute (thinger)' => sub {

    validate_attribute TestRole => thinger => (
        reader    => 'thinger',
        predicate => 'has_thinger',
    );
};

{
    note my $test_title = 'validate_attribute() for a valid role attribute';
    my ($_ok, $_nok, $_skip, $_todo, $_other) = counters();
    test_out $_ok->('TestRole has an attribute named thinger');
    test_out $_skip->('cannot yet test role attribute layouts');
    validate_attribute TestRole => thinger => (
        reader    => 'thinger',
        predicate => 'has_thinger',
    );
    test_test $test_title;
}

{
    note my $test_title = 'validate_attribute() for an invalid role attribute';
    my ($_ok, $_nok, $_skip, $_todo, $_other) = counters();
    test_out $_nok->('TestRole has an attribute named dne');
    test_fail 1;
    validate_attribute TestRole => dne => (
        reader    => 'dne',
        predicate => 'has_dne',
    );
    test_test $test_title;
}

done_testing;