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