1N/A#!/usr/bin/perl -w
1N/A
1N/A# This is a test of the verification of the arguments to
1N/A# WriteMakefile.
1N/A
1N/ABEGIN {
1N/A if( $ENV{PERL_CORE} ) {
1N/A chdir 't' if -d 't';
1N/A @INC = ('../lib', 'lib');
1N/A }
1N/A else {
1N/A unshift @INC, 't/lib';
1N/A }
1N/A}
1N/A
1N/Ause strict;
1N/Ause Test::More tests => 13;
1N/A
1N/Ause TieOut;
1N/Ause MakeMaker::Test::Utils;
1N/A
1N/Ause ExtUtils::MakeMaker;
1N/A
1N/Achdir 't';
1N/A
1N/Aperl_lib();
1N/A
1N/Aok( chdir 'Big-Dummy', "chdir'd to Big-Dummy" ) ||
1N/A diag("chdir failed: $!");
1N/A
1N/A{
1N/A ok( my $stdout = tie *STDOUT, 'TieOut' );
1N/A my $warnings = '';
1N/A local $SIG{__WARN__} = sub {
1N/A $warnings .= join '', @_;
1N/A };
1N/A
1N/A my $mm;
1N/A
1N/A eval {
1N/A $mm = WriteMakefile(
1N/A NAME => 'Big::Dummy',
1N/A VERSION_FROM => 'lib/Big/Dummy.pm',
1N/A MAN3PODS => ' ', # common mistake
1N/A );
1N/A };
1N/A
1N/A is( $warnings, <<VERIFY );
1N/AWARNING: MAN3PODS takes a hash reference not a string/number.
1N/A Please inform the author.
1N/AVERIFY
1N/A
1N/A $warnings = '';
1N/A eval {
1N/A $mm = WriteMakefile(
1N/A NAME => 'Big::Dummy',
1N/A VERSION_FROM => 'lib/Big/Dummy.pm',
1N/A AUTHOR => sub {},
1N/A );
1N/A };
1N/A
1N/A is( $warnings, <<VERIFY );
1N/AWARNING: AUTHOR takes a string/number not a code reference.
1N/A Please inform the author.
1N/AVERIFY
1N/A
1N/A # LIBS accepts *both* a string or an array ref. The first cut of
1N/A # our verification did not take this into account.
1N/A $warnings = '';
1N/A $mm = WriteMakefile(
1N/A NAME => 'Big::Dummy',
1N/A VERSION_FROM => 'lib/Big/Dummy.pm',
1N/A LIBS => '-lwibble -lwobble',
1N/A );
1N/A
1N/A # We'll get warnings about the bogus libs, that's ok.
1N/A unlike( $warnings, qr/WARNING: .* takes/ );
1N/A is_deeply( $mm->{LIBS}, ['-lwibble -lwobble'] );
1N/A
1N/A $warnings = '';
1N/A $mm = WriteMakefile(
1N/A NAME => 'Big::Dummy',
1N/A VERSION_FROM => 'lib/Big/Dummy.pm',
1N/A LIBS => ['-lwibble', '-lwobble'],
1N/A );
1N/A
1N/A # We'll get warnings about the bogus libs, that's ok.
1N/A unlike( $warnings, qr/WARNING: .* takes/ );
1N/A is_deeply( $mm->{LIBS}, ['-lwibble', '-lwobble'] );
1N/A
1N/A $warnings = '';
1N/A eval {
1N/A $mm = WriteMakefile(
1N/A NAME => 'Big::Dummy',
1N/A VERSION_FROM => 'lib/Big/Dummy.pm',
1N/A LIBS => { wibble => "wobble" },
1N/A );
1N/A };
1N/A
1N/A # We'll get warnings about the bogus libs, that's ok.
1N/A like( $warnings, qr{^WARNING: LIBS takes a array reference or string/number not a hash reference}m );
1N/A
1N/A
1N/A $warnings = '';
1N/A $mm = WriteMakefile(
1N/A NAME => 'Big::Dummy',
1N/A WIBBLE => 'something',
1N/A wump => { foo => 42 },
1N/A );
1N/A
1N/A like( $warnings, qr{^WARNING: WIBBLE is not a known parameter.\n}m );
1N/A like( $warnings, qr{^WARNING: wump is not a known parameter.\n}m );
1N/A
1N/A is( $mm->{WIBBLE}, 'something' );
1N/A is_deeply( $mm->{wump}, { foo => 42 } );
1N/A}