1=pod
2
3=encoding utf-8
4
5=head1 PURPOSE
6
7Test what happens when trying to import symbols and tags that don't exist
8or aren't marked as suitable for exporting.
9
10=head1 AUTHOR
11
12Toby Inkster E<lt>tobyink@cpan.orgE<gt>.
13
14=head1 COPYRIGHT AND LICENCE
15
16This software is copyright (c) 2018 by Toby Inkster.
17
18This is free software; you can redistribute it and/or modify it under
19the same terms as the Perl 5 programming language system itself.
20
21=cut
22
23use strict;
24use warnings;
25use Test::More tests => 4;
26
27sub exception ($) {
28	local $@;
29	eval shift;
30	return $@;
31}
32
33BEGIN {
34	package My::Exporter;
35	use Exporter::Shiny qw( $Foo Bar Bam wibble );
36	our $Foo = 42;
37	sub Bar { 666 }
38	sub Baz { 999 }
39	our $Bat = 69;
40	sub _generate_wibble {
41		my $class = shift;
42		my ($name, $arg, $globals) = @_;
43		return sub { $globals };
44	}
45};
46
47like(
48	exception q{ use My::Exporter qw(Baz) },
49	qr/Could not find sub/,
50	'sub that is not marked for export'
51);
52
53like(
54	exception q{ use My::Exporter qw(Bam) },
55	qr/Could not find sub/,
56	'sub that cannot be found'
57);
58
59like(
60	exception q{ use My::Exporter qw($Bat) },
61	qr/Could not find sub/,  # this error should probably be changed
62	'non-code symbol that is not marked for export'
63);
64
65use My::Exporter -wobble => { butt => 88 }, qw(wibble);
66
67is_deeply(
68	wibble->{wobble},
69	{ butt => 88 },
70	'unknown tags get added to globals'
71);