Integrate mainline (for ndbm fixes etc.)
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / t / MM_Unix.t
CommitLineData
c7a17d47 1#!./perl -w
2
3# 2001-12-16 Tels first version
e567eb17 4# 2002-01-13 Tels 0.02 added some tests for various functions, added Andreas
5# fix to the version test (>= vs ==)
235bddc8 6# 2002-01-14 Tels 0.03 exclude on beos and netware, /i for $^O test
c7a17d47 7
8BEGIN {
9 chdir 't' if -d 't';
10 @INC = '../lib';
11}
12
87a750c3 13BEGIN {
14 use Test::More;
15
235bddc8 16 if( $^O =~ /^VMS|os2|MacOS|MSWin32|cygwin|beos|netware$/i ) {
87a750c3 17 plan skip_all => 'Non-Unix platform';
18 }
19 else {
e567eb17 20 plan tests => 108;
87a750c3 21 }
22}
c7a17d47 23
24BEGIN { use_ok( 'ExtUtils::MM_Unix' ); }
25
e567eb17 26$VERSION = '0.02';
c7a17d47 27use strict;
28use File::Spec;
29
30my $class = 'ExtUtils::MM_Unix';
31
32# only one of the following can be true
33# test should be removed if MM_Unix ever stops handling other OS than Unix
34my $os = ($ExtUtils::MM_Unix::Is_OS2 || 0)
35 + ($ExtUtils::MM_Unix::Is_Mac || 0)
36 + ($ExtUtils::MM_Unix::Is_Win32 || 0)
37 + ($ExtUtils::MM_Unix::Is_Dos || 0)
38 + ($ExtUtils::MM_Unix::Is_VMS || 0);
39ok ( $os <= 1, 'There can be only one (or none)');
40
e567eb17 41cmp_ok ($ExtUtils::MM_Unix::VERSION, '>=', '1.12606', 'Should be at least version 1.12606');
c7a17d47 42
43# when the following calls like canonpath, catdir etc are replaced by
44# File::Spec calls, the test's become a bit pointless
45
46foreach ( qw( xx/ ./xx/ xx/././xx xx///xx) )
47 {
48 is ($class->canonpath($_), File::Spec->canonpath($_), "canonpath $_");
49 }
50
51is ($class->catdir('xx','xx'), File::Spec->catdir('xx','xx'),
52 'catdir(xx, xx) => xx/xx');
53is ($class->catfile('xx','xx','yy'), File::Spec->catfile('xx','xx','yy'),
54 'catfile(xx, xx) => xx/xx');
55
e567eb17 56is ($class->file_name_is_absolute('Bombdadil'),
57 File::Spec->file_name_is_absolute('Bombdadil'),
58 'file_name_is_absolute()');
59
60is ($class->path(), File::Spec->path(), 'path() same as File::Spec->path()');
61
c7a17d47 62foreach (qw/updir curdir rootdir/)
63 {
64 is ($class->$_(), File::Spec->$_(), $_ );
65 }
66
67foreach ( qw /
68 c_o
69 clean
70 const_cccmd
71 const_config
72 const_loadlibs
73 constants
74 depend
75 dir_target
76 dist
77 dist_basics
78 dist_ci
79 dist_core
80 dist_dir
81 dist_test
82 dlsyms
83 dynamic
84 dynamic_bs
85 dynamic_lib
86 exescan
87 export_list
88 extliblist
c7a17d47 89 find_perl
90 fixin
91 force
92 guess_name
c7a17d47 93 htmlifypods
94 init_dirscan
95 init_main
96 init_others
97 install
98 installbin
c7a17d47 99 linkext
100 lsdir
101 macro
102 makeaperl
103 makefile
104 manifypods
c7a17d47 105 maybe_command_in_dirs
106 needs_linking
c7a17d47 107 pasthru
c7a17d47 108 perldepend
109 pm_to_blib
c7a17d47 110 ppd
111 prefixify
112 processPL
113 quote_paren
114 realclean
c7a17d47 115 static
116 static_lib
117 staticmake
118 subdir_x
119 subdirs
120 test
121 test_via_harness
122 test_via_script
123 tool_autosplit
124 tool_xsubpp
125 tools_other
126 top_targets
127 writedoc
128 xs_c
129 xs_cpp
130 xs_o
131 xsubpp_version
132 / )
133 {
134 ok ($class->can ($_), "can $_");
135 }
136
e567eb17 137###############################################################################
138# some more detailed tests for the methods above
139
140ok ( join (' ', $class->dist_basics()), 'distclean :: realclean distcheck');
141
142###############################################################################
143# has_link_code tests
144
145my $t = {}; bless $t,$class;
146$t->{HAS_LINK_CODE} = 1;
147is ($t->has_link_code(),1,'has_link_code'); is ($t->{HAS_LINK_CODE},1);
148
149$t->{HAS_LINK_CODE} = 0;
150is ($t->has_link_code(),0); is ($t->{HAS_LINK_CODE},0);
151
152delete $t->{HAS_LINK_CODE}; delete $t->{OBJECT};
153is ($t->has_link_code(),0); is ($t->{HAS_LINK_CODE},0);
154
155delete $t->{HAS_LINK_CODE}; $t->{OBJECT} = 1;
156is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1);
157
158delete $t->{HAS_LINK_CODE}; delete $t->{OBJECT}; $t->{MYEXTLIB} = 1;
159is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1);
160
161delete $t->{HAS_LINK_CODE}; delete $t->{MYEXTLIB}; $t->{C} = [ 'Gloin' ];
162is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1);
163
164###############################################################################
165# libscan
166
167is ($t->libscan('RCS'),'','libscan on RCS');
168is ($t->libscan('CVS'),'','libscan on CVS');
169is ($t->libscan('SCCS'),'','libscan on SCCS');
170is ($t->libscan('Fatty'),'Fatty','libscan on something not RCS, CVS or SCCS');
171
172###############################################################################
173# maybe_command
174
175is ($t->maybe_command('blargel'),undef,"'blargel' isn't a command");
176
177###############################################################################
178# nicetext (dummy method)
179
180is ($t->nicetext('LOTR'),'LOTR','nicetext');
181
182###############################################################################
183# parse_version
184
185my $self_name = '../lib/ExtUtils/t/MM_Unix.t';
186
187is ($t->parse_version($self_name),'0.02',
188 'parse_version on ourself');
189
190###############################################################################
191# perl_script (on unix any ordinary, readable file)
192
193is ($t->perl_script($self_name),$self_name, 'we pass as a perl_script()');
194
195###############################################################################
196# perm_rw perm_rwx
197
198is ($t->perm_rw(),'644', 'perm_rw() is 644');
199is ($t->perm_rwx(),'755', 'perm_rwx() is 755');
200
201###############################################################################
202# post_constants, postamble, post_initialize
203
204foreach (qw/ post_constants postamble post_initialize/)
205 {
206 is ($t->$_(),'', "$_() is an empty string");
207 }
208
209###############################################################################
210# replace_manpage_separator
211
212is ($t->replace_manpage_separator('Foo/Bar'),'Foo::Bar','manpage_separator');
213
214###############################################################################
215# export_list, perl_archive, perl_archive_after
216
217foreach (qw/ export_list perl_archive perl_archive_after/)
218 {
219 is ($t->$_(),'',"$_() is empty string on Unix");
220 }
221
c7a17d47 222