1#!/usr/bin/perl
2use strict;
3use warnings;
4
5use Fennec::Lite;
6
7{
8    package An::Exporter;
9    use Exporter::Declare;
10
11    default_exports qw/ a /;
12    exports qw/ b c $X /;
13
14    our $X = 'x';
15
16    sub a { 'a' }
17    sub b { 'b' }
18    sub c { 'c' }
19}
20{
21    package Old::Exporter;
22    use base 'Exporter';
23
24    our @EXPORT = qw/ d e f $Y /;
25
26    our $Y = 'y';
27
28    sub d { 'd' }
29    sub e { 'e' }
30    sub f { 'f' }
31}
32{
33    package Combination;
34    use Exporter::Declare qw/reexport import/;
35
36    reexport 'An::Exporter';
37    reexport 'Old::Exporter';
38}
39
40tests meta_data => sub {
41    is_deeply(
42        [ sort keys %{ Combination->export_meta->exports }],
43        [ sort qw/ &a &b &c &d &e &f $Y $X &Combination/],
44        "All exports"
45    );
46    is_deeply(
47        [ sort @{ Combination->export_meta->export_tags->{ all }}],
48        [ sort qw/ &a &b &c &d &e &f $Y $X &Combination/],
49        "All exports tag"
50    );
51    is_deeply(
52        [ sort @{ Combination->export_meta->export_tags->{ default }}],
53        [ sort qw/ a d e f $Y / ],
54        "Defaults"
55    );
56};
57
58tests imports => sub {
59    Combination->import('-all');
60    can_ok( __PACKAGE__, qw/a b c d e f/ );
61    is( a(), 'a', "a()" );
62    is( b(), 'b', "b()" );
63    is( c(), 'c', "c()" );
64    is( d(), 'd', "d()" );
65    is( e(), 'e', "e()" );
66    is( f(), 'f', "f()" );
67    no strict 'vars';
68    no warnings 'once';
69    is( $X, 'x', '$X' );
70    is( $Y, 'y', '$Y' );
71};
72
73run_tests;
74done_testing;
75