File: 400_import_via_into.t

package info (click to toggle)
libmoosex-markasmethods-perl 0.15-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 200 kB
  • sloc: perl: 280; makefile: 2
file content (60 lines) | stat: -rw-r--r-- 1,129 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
52
53
54
55
56
57
58
59
60

use strict;
use warnings;

use Moose                 ( );
use MooseX::MarkAsMethods ( );

use Test::More ();

BEGIN {
    {
        package TestClass::Funky;

        use Moose::Exporter;

        my ($import, $unimport, $init_meta) = Moose::Exporter->build_import_methods(
            install => [ qw{ unimport init_meta } ],
        );

        sub import {

            my $target = scalar caller;
            MooseX::MarkAsMethods->import({ into => $target }, autoclean => 1);

            goto &$import;
        }
    }

    $INC{'TestClass/Funky.pm'} = 1;
}
{
    package TestClass;

    use Moose;
    use TestClass::Funky;

    use overload q{""} => sub { shift->stringify }, fallback => 1;

    has class_att => (isa => 'Str', is => 'rw');
    sub stringify { 'from class' }
}

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

require 't/funcs.pm' unless eval { require funcs };

does_ok(TestClass->meta, 'MooseX::MarkAsMethods::MetaRole::MethodMarker');

check_sugar_removed_ok('TestClass');

my $t = make_and_check(
    'TestClass',
    undef,
    [ 'class_att' ],
);

check_overloads($t, '""' => 'from class');

done_testing;