File: method_is_not_accessor_ok.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 (50 lines) | stat: -rw-r--r-- 1,084 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
50
use strict;
use warnings;

use Test::More;
use Test::Moose::More;

use Test::Builder::Tester;
use TAP::SimpleOutput;

{ package A; use Moose::Role; has a => (is => 'rw'); sub a1 {} }
{ package B; use Moose;       has b => (is => 'rw'); sub b1 {} }
{ package C; use Moose; extends 'B'; with 'A'; sub c1 {} }


subtest standalone => sub {

    method_is_not_accessor_ok A => 'a1';
    method_is_not_accessor_ok B => 'b1';
    method_is_not_accessor_ok C => 'a1';
    method_is_not_accessor_ok C => 'b1';
};


note 'pass (TBT)';
{
    my ($_ok, $_nok) = counters;
    test_out $_ok->(q{B's method b1 is not an accessor method});
    method_is_not_accessor_ok B => 'b1';
    test_test;
}

note 'fails - DNE method (TBT)';
{
    my ($_ok, $_nok) = counters;
    test_out $_nok->('C has no method dne');
    test_fail 1;
    method_is_not_accessor_ok C => 'dne';
    test_test;
}

note 'fails (TBT)';
{
    my ($_ok, $_nok) = counters;
    test_out $_nok->(q{C's method b is not an accessor method});
    test_fail 1;
    method_is_not_accessor_ok C => 'b';
    test_test;
}

done_testing;