File: more-symbols.t

package info (click to toggle)
libmodule-implementation-perl 0.09-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 248 kB
  • sloc: perl: 423; makefile: 2
file content (47 lines) | stat: -rw-r--r-- 1,044 bytes parent folder | download | duplicates (4)
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
use strict;
use warnings;

use Test::More 0.88;

{
    package T;

    use strict;
    use warnings;

    use lib 't/lib';

    use Module::Implementation;
    my $loader = Module::Implementation::build_loader_sub(
        implementations => [ 'Impl1', 'Impl2' ],
        symbols => [qw( return_42 &return_package $SCALAR @ARRAY %HASH )],
    );

    $loader->();
}

{
    ok( T->can('return_42'),      'T package has a return_42 sub' );
    ok( T->can('return_package'), 'T package has a return_package sub' );
    is( T::return_42(), 42, 'T::return_42 work as expected' );
    is(
        T::return_package(),
        'T::Impl1',
        'T::return_package returns implementation package'
    );

    no warnings 'once';
    is( $T::SCALAR, 42, '$T::SCALAR was copied from implementation' );
    is_deeply(
        \@T::ARRAY,
        [ 1, 2, 3 ],
        '@T::ARRAY was copied from implementation'
    );
    is_deeply(
        \%T::HASH,
        { key => 'val' },
        '%T::HASH was copied from implementation'
    );
}

done_testing();