/
is_not_anon.t
55 lines (46 loc) · 1.34 KB
/
is_not_anon.t
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
use strict;
use warnings;
use Test::Builder::Tester;
use Moose::Util 'with_traits';
use Test::More;
use Test::Moose::More;
use TAP::SimpleOutput 'counters';
{ package TestRole; use Moose::Role; use namespace::autoclean; }
{ package TestClass; use Moose; }
# initial tests, covering the most straight-forward cases (IMHO)
my $anon_class = with_traits('TestClass' => 'TestRole');
my $anon_role = Moose::Meta::Role
->create_anon_role(weaken => 0)
->name
;
note 'simple anon class';
{
my ($_ok, $_nok, $_skip) = counters();
test_out $_nok->("$anon_class is not anonymous");
test_fail 1;
is_not_anon $anon_class;
test_test 'is_not_anon works correctly on anon class';
}
note 'simple anon role';
{
my ($_ok, $_nok, $_skip) = counters();
test_out $_nok->("$anon_role is not anonymous");
test_fail 1;
is_not_anon $anon_role;
test_test 'is_not_anon works correctly on anon role';
}
note 'simple !anon class';
{
my ($_ok, $_nok, $_skip) = counters();
test_out $_ok->('TestClass is not anonymous');
is_not_anon 'TestClass';
test_test 'is_not_anon works correctly on !anon class';
}
note 'simple !anon role';
{
my ($_ok, $_nok, $_skip) = counters();
test_out $_ok->('TestRole is not anonymous');
is_not_anon 'TestRole';
test_test 'is_not_anon works correctly on !anon role';
}
done_testing;