Bump version numbers of moules affected by change #22258
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / t / MM_Cygwin.t
1 #!/usr/bin/perl
2
3 BEGIN {
4     if( $ENV{PERL_CORE} ) {
5         chdir 't' if -d 't';
6         @INC = '../lib';
7     }
8     else {
9         unshift @INC, 't/lib';
10     }
11 }
12 chdir 't';
13
14 use strict;
15 use Test::More;
16
17 BEGIN {
18         if ($^O =~ /cygwin/i) {
19                 plan tests => 11;
20         } else {
21                 plan skip_all => "This is not cygwin";
22         }
23 }
24
25 use Config;
26 use File::Spec;
27 use ExtUtils::MM;
28
29 use_ok( 'ExtUtils::MM_Cygwin' );
30
31 # test canonpath
32 my $path = File::Spec->canonpath('/a/../../c');
33 is( MM->canonpath('/a/../../c'), $path,
34         'canonpath() method should work just like the one in File::Spec' );
35
36 # test cflags, with the fake package below
37 my $MM = bless({
38         CFLAGS  => 'fakeflags',
39         CCFLAGS => '',
40 }, 'MM');
41
42 # with CFLAGS set, it should be returned
43 is( $MM->cflags(), 'fakeflags',
44         'cflags() should return CFLAGS member data, if set' );
45
46 delete $MM->{CFLAGS};
47
48 # ExtUtils::MM_Cygwin::cflags() calls this, fake the output
49 {
50     local $SIG{__WARN__} = sub { 
51         warn @_ unless $_[0] =~ /^Subroutine .* redefined/;
52     };
53     *ExtUtils::MM_Unix::cflags = sub { return $_[1] };
54 }
55
56 # respects the config setting, should ignore whitespace around equal sign
57 my $ccflags = $Config{useshrplib} eq 'true' ? ' -DUSEIMPORTLIB' : '';
58 {
59     local $MM->{NEEDS_LINKING} = 1;
60     $MM->cflags(<<FLAGS);
61 OPTIMIZE = opt
62 PERLTYPE  =pt
63 FLAGS
64 }
65
66 like( $MM->{CFLAGS}, qr/OPTIMIZE = opt/, '... should set OPTIMIZE' );
67 like( $MM->{CFLAGS}, qr/PERLTYPE = pt/, '... should set PERLTYPE' );
68 like( $MM->{CFLAGS}, qr/CCFLAGS = $ccflags/, '... should set CCFLAGS' );
69
70 # test manifypods
71 $MM = bless({
72         NOECHO => 'noecho',
73         MAN3PODS => {},
74         MAN1PODS => {},
75     MAKEFILE => 'Makefile',
76 }, 'MM');
77 unlike( $MM->manifypods(), qr/foo/,
78         'manifypods() should return without PODS values set' );
79
80 $MM->{MAN3PODS} = { foo => 'foo.1' };
81 my $res = $MM->manifypods();
82 like( $res, qr/pure_all.*foo.*foo.1/s, '... should add MAN3PODS targets' );
83
84
85 # init_linker
86 {
87     my $libperl = $Config{libperl} || 'libperl.a';
88     $libperl =~ s/\.a/.dll.a/ if $] >= 5.006002;
89     $libperl = "\$(PERL_INC)/$libperl";
90
91     my $export  = '';
92     my $after   = '';
93     $MM->init_linker;
94
95     is( $MM->{PERL_ARCHIVE},        $libperl,   'PERL_ARCHIVE' );
96     is( $MM->{PERL_ARCHIVE_AFTER},  $after,     'PERL_ARCHIVE_AFTER' );
97     is( $MM->{EXPORT_LIST},         $export,    'EXPORT_LIST' );
98 }
99
100
101
102 package FakeOut;
103
104 sub TIEHANDLE {
105         bless(\(my $scalar), $_[0]);
106 }
107
108 sub PRINT {
109         my $self = shift;
110         $$self .= shift;
111 }