Exporter-Almighty

 view release on metacpan or  search on metacpan

t/unit/Exporter/Almighty.t  view on Meta::CPAN

=pod

=encoding utf-8

=head1 PURPOSE

Unit tests for L<Exporter::Almighty>.

=head1 AUTHOR

Toby Inkster E<lt>tobyink@cpan.orgE<gt>.

=head1 COPYRIGHT AND LICENCE

This software is copyright (c) 2023 by Toby Inkster.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut

use Test2::V0 -target => 'Exporter::Almighty';
use Test2::Tools::Spec;
use Data::Dumper;

my @builtins;
BEGIN { @builtins = qw( is_bool created_as_string created_as_number ) };
use if $] lt '5.036000', 'builtins::compat' => @builtins;
use if $] ge '5.036000', 'builtin' => @builtins;
no if $] ge '5.036000', 'warnings' => qw( experimental::builtin );

use FindBin qw( $Bin );
use lib "$Bin/../../lib";

describe "class `$CLASS`" => sub {

	tests 'it is an Exporter::Tiny' => sub {
		isa_ok( $CLASS, 'Exporter::Tiny' );
	};
};

describe "method `base_exporter`" => sub {

	tests 'it returns Exporter::Tiny or a subclass of it' => sub {
		isa_ok( $CLASS->base_exporter, 'Exporter::Tiny' );
	};
};

describe "method `standard_package_variables`" => sub {

	{
		package Local::TestPkg1;
		our @ISA          = qw( strict );
		our @EXPORT       = qw( a b c );
		our @EXPORT_OK    = qw( d e f );
		our %EXPORT_TAGS  = ( xyz => [ 1, 2, 3 ] );
	}
	
	tests 'it works' => sub {
		
		is(
			[ $CLASS->standard_package_variables( 'Local::TestPkg1' ) ],
			array {
				item array {
					item string 'strict';
					end;
				};
				item array {
					item string 'a';
					item string 'b';
					item string 'c';
					end;
				};
				item array {
					item string 'd';
					item string 'e';
					item string 'f';
					end;
				};
				item hash {
					field xyz => array {
						item number 1;
						item number 2;
						item number 3;
						end;
					};
					end;
				};
				end;
			},



( run in 1.901 second using v1.01-cache-2.11-cpan-b301d465b3d )