File: has-after-meta.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 (25 lines) | stat: -rw-r--r-- 590 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
use Moo::_strictures;
use Test::More;
use Test::Fatal;

use Moose ();

{
  package MyClass;
  use Moo;

  has attr1 => ( is => 'ro' );

  # this will inflate a metaclass and undefer all of the methods, including the
  # constructor.  the constructor still needs to be modifyable though.
  # Metaclass inflation can happen for unexpected reasons, such as using
  # namespace::autoclean (but only if Moose has been loaded).
  __PACKAGE__->meta->name;

  ::is ::exception {
    has attr2 => ( is => 'ro' );
  }, undef,
    'attributes can be added after metaclass inflation';
}

done_testing;