File: long-package-name.t

package info (click to toggle)
libmoo-perl 2.002005-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 856 kB
  • ctags: 192
  • sloc: perl: 2,561; makefile: 6
file content (51 lines) | stat: -rw-r--r-- 904 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
use Moo::_strictures;
use Test::More;
use Test::Fatal;

{
  package Some::Class;
  use Moo;
  has attr1 => (is => 'ro');
}

my $max_length = 252;

my $long_name = "Long::Package::Name::";
$long_name .= substr("0123456789" x 26, 0, $max_length - length $long_name);

is exception {
  eval qq{
    package $long_name;
    use Moo;
    has attr2 => (is => 'ro');
    1;
  } or die "$@";
}, undef,
  'can use Moo in a long package';

is exception {
  $long_name->new;
}, undef,
  'long package name instantiation works';

{
  package AMooClass;
  use Moo;
  has attr1 => (is => 'ro');
}

for (1..7) {
  eval qq{
    package LongRole${_}::ABCDEFGHIGKLMNOPQRSTUVWXYZ;
    use Moo::Role;
    1;
  } or die $@;
}

is exception {
  Moo::Role->create_class_with_roles('AMooClass',
    map "LongRole${_}::ABCDEFGHIGKLMNOPQRSTUVWXYZ", 1..7)->new->attr1;
}, undef,
  'generated long class names work';

done_testing;