1=pod 2 3=encoding utf-8 4 5=head1 PURPOSE 6 7Test Exporter::Tiny exporting non-code symbols from generators. 8 9=head1 AUTHOR 10 11Toby Inkster E<lt>tobyink@cpan.orgE<gt>. 12 13=head1 COPYRIGHT AND LICENCE 14 15This software is copyright (c) 2018 by Toby Inkster. 16 17This is free software; you can redistribute it and/or modify it under 18the same terms as the Perl 5 programming language system itself. 19 20=cut 21 22use strict; 23use warnings; 24use Test::More tests => 7; 25 26BEGIN { 27 package My::Exporter; 28 use Exporter::Shiny qw( $Foo @Bar %Baz ); 29 our $_Foo = 42; 30 our @_Bar = (1, 2, 3); 31 our %_Baz = (quux => 'xyzzy'); 32 sub _generateScalar_Foo { \$_Foo } 33 sub _generateArray_Bar { \@_Bar } 34 sub _generateHash_Baz { \%_Baz } 35}; 36 37BEGIN { 38 package My::Importer; 39 use My::Exporter -all; 40}; 41 42is($My::Importer::Foo, 42, 'importing scalar'); 43is_deeply(\@My::Importer::Bar, [1,2,3], 'importing array'); 44is_deeply(\%My::Importer::Baz, { quux => 'xyzzy' }, 'importing hash'); 45 46$My::Importer::Foo /= 2; 47push @My::Importer::Bar, 4; 48$My::Importer::Baz{quuux} = 'blarg'; 49 50is($My::Exporter::_Foo, 21, 'importing scalar does not copy'); 51is_deeply(\@My::Exporter::_Bar, [1,2,3,4], 'importing array does not copy'); 52is_deeply(\%My::Exporter::_Baz, { quux => 'xyzzy', quuux => 'blarg' }, 'importing hash does not copy'); 53 54my $into = {}; 55My::Exporter->import({ into => $into }, qw( $Foo @Bar %Baz )); 56is_deeply($into, { '$Foo' => \21, '@Bar' => [1..4], '%Baz' => {qw/quux xyzzy quuux blarg/} }, 'importing non-code symbols into hashrefs'); 57