This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Test::Harness 2.25 -> 2.26
[perl5.git] / lib / ExtUtils / t / writemakefile_args.t
CommitLineData
69ff8adf
JH
1#!/usr/bin/perl -w
2
3# This is a test of the verification of the arguments to
4# WriteMakefile.
5
6BEGIN {
7 if( $ENV{PERL_CORE} ) {
8 chdir 't' if -d 't';
9 @INC = ('../lib', 'lib');
10 }
11 else {
12 unshift @INC, 't/lib';
13 }
14}
15
16use strict;
d5d4ec93 17use Test::More tests => 16;
69ff8adf
JH
18
19use TieOut;
20use MakeMaker::Test::Utils;
21
22use ExtUtils::MakeMaker;
23
24chdir 't';
25
26perl_lib();
27
28ok( chdir 'Big-Dummy', "chdir'd to Big-Dummy" ) ||
29 diag("chdir failed: $!");
30
31{
32 ok( my $stdout = tie *STDOUT, 'TieOut' );
33 my $warnings = '';
34 local $SIG{__WARN__} = sub {
35 $warnings .= join '', @_;
36 };
37
38 my $mm = WriteMakefile(
39 NAME => 'Big::Dummy',
40 VERSION_FROM => 'lib/Big/Dummy.pm',
41 MAN3PODS => ' ', # common mistake
42 );
43
44 is( $warnings, <<VERIFY );
45WARNING: MAN3PODS takes a hash reference not a string/number.
46 Please inform the author.
47VERIFY
48 is_deeply( $mm->{MAN3PODS}, {}, 'Wrong argument type corrected' );
49
50 $warnings = '';
51 $mm = WriteMakefile(
52 NAME => 'Big::Dummy',
53 VERSION_FROM => 'lib/Big/Dummy.pm',
54 AUTHOR => sub {},
55 );
d5d4ec93 56
69ff8adf
JH
57 is( $warnings, <<VERIFY );
58WARNING: AUTHOR takes a string/number not a code reference.
59 Please inform the author.
60VERIFY
61
62 is_deeply( $mm->{AUTHOR}, '' );
63
64
65 # LIBS accepts *both* a string or an array ref. The first cut of
66 # our verification did not take this into account.
67 $warnings = '';
68 $mm = WriteMakefile(
69 NAME => 'Big::Dummy',
70 VERSION_FROM => 'lib/Big/Dummy.pm',
71 LIBS => '-lwibble -lwobble',
72 );
d5d4ec93 73
69ff8adf
JH
74 # We'll get warnings about the bogus libs, that's ok.
75 unlike( $warnings, qr/WARNING: .* takes/ );
76 is_deeply( $mm->{LIBS}, ['-lwibble -lwobble'] );
77
78 $warnings = '';
79 $mm = WriteMakefile(
80 NAME => 'Big::Dummy',
81 VERSION_FROM => 'lib/Big/Dummy.pm',
82 LIBS => ['-lwibble', '-lwobble'],
83 );
d5d4ec93 84
69ff8adf
JH
85 # We'll get warnings about the bogus libs, that's ok.
86 unlike( $warnings, qr/WARNING: .* takes/ );
87 is_deeply( $mm->{LIBS}, ['-lwibble', '-lwobble'] );
88
89 $warnings = '';
90 $mm = WriteMakefile(
91 NAME => 'Big::Dummy',
92 VERSION_FROM => 'lib/Big/Dummy.pm',
93 LIBS => { wibble => "wobble" },
94 );
d5d4ec93 95
69ff8adf
JH
96 # We'll get warnings about the bogus libs, that's ok.
97 like( $warnings, qr{^WARNING: LIBS takes a array reference or string/number not a hash reference}m );
98 is_deeply( $mm->{LIBS}, [] );
99
d5d4ec93
MS
100
101 $warnings = '';
102 $mm = WriteMakefile(
103 NAME => 'Big::Dummy',
104 WIBBLE => 'something',
105 wump => { foo => 42 },
106 );
107
108 like( $warnings, qr{^WARNING: WIBBLE is not a known parameter.\n}m );
109 like( $warnings, qr{^WARNING: wump is not a known parameter.\n}m );
110
111 is( $mm->{WIBBLE}, 'something' );
112 is_deeply( $mm->{wump}, { foo => 42 } );
69ff8adf 113}