File: 11-moose-exporter.t

package info (click to toggle)
libmoosex-classattribute-perl 0.27-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 244 kB
  • ctags: 47
  • sloc: perl: 994; makefile: 2
file content (42 lines) | stat: -rw-r--r-- 773 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
use strict;
use warnings;

use Test::More;

BEGIN { plan skip_all => 'This test fails with a syntax error' }

{
    package MooseX::Foo;

    use strict;
    use warnings;

    use Moose::Exporter;
    use MooseX::ClassAttribute ();

    Moose::Exporter->setup_import_methods(
        also => ['MooseX::ClassAttribute'],
    );
}

{
    package MyClass;

    use Moose;

    # use MooseX::Foo;  # normal use
    MooseX::Foo->import;

    # Now theoretically, this should work -- the 'class_has' method
    # should have been imported via the MooseX package above.
    class_has attr => (
        is      => 'ro', isa => 'Str',
        default => 'foo',
    );
}

my $obj = MyClass->new();

is( $obj->attr(), 'foo', 'class attribute is properly created' );

done_testing();