offsetof() is in <stddef.h>
[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 ==)
c7a17d47 6
7BEGIN {
8 chdir 't' if -d 't';
9 @INC = '../lib';
10}
11
87a750c3 12BEGIN {
13 use Test::More;
14
15 if( $^O =~ /^VMS|os2|MacOS|MSWin32|cygwin$/ ) {
16 plan skip_all => 'Non-Unix platform';
17 }
18 else {
e567eb17 19 plan tests => 108;
87a750c3 20 }
21}
c7a17d47 22
23BEGIN { use_ok( 'ExtUtils::MM_Unix' ); }
24
e567eb17 25$VERSION = '0.02';
c7a17d47 26use strict;
27use File::Spec;
28
29my $class = 'ExtUtils::MM_Unix';
30
31# only one of the following can be true
32# test should be removed if MM_Unix ever stops handling other OS than Unix
33my $os = ($ExtUtils::MM_Unix::Is_OS2 || 0)
34 + ($ExtUtils::MM_Unix::Is_Mac || 0)
35 + ($ExtUtils::MM_Unix::Is_Win32 || 0)
36 + ($ExtUtils::MM_Unix::Is_Dos || 0)
37 + ($ExtUtils::MM_Unix::Is_VMS || 0);
38ok ( $os <= 1, 'There can be only one (or none)');
39
e567eb17 40cmp_ok ($ExtUtils::MM_Unix::VERSION, '>=', '1.12606', 'Should be at least version 1.12606');
c7a17d47 41
42# when the following calls like canonpath, catdir etc are replaced by
43# File::Spec calls, the test's become a bit pointless
44
45foreach ( qw( xx/ ./xx/ xx/././xx xx///xx) )
46 {
47 is ($class->canonpath($_), File::Spec->canonpath($_), "canonpath $_");
48 }
49
50is ($class->catdir('xx','xx'), File::Spec->catdir('xx','xx'),
51 'catdir(xx, xx) => xx/xx');
52is ($class->catfile('xx','xx','yy'), File::Spec->catfile('xx','xx','yy'),
53 'catfile(xx, xx) => xx/xx');
54
e567eb17 55is ($class->file_name_is_absolute('Bombdadil'),
56 File::Spec->file_name_is_absolute('Bombdadil'),
57 'file_name_is_absolute()');
58
59is ($class->path(), File::Spec->path(), 'path() same as File::Spec->path()');
60
c7a17d47 61foreach (qw/updir curdir rootdir/)
62 {
63 is ($class->$_(), File::Spec->$_(), $_ );
64 }
65
66foreach ( qw /
67 c_o
68 clean
69 const_cccmd
70 const_config
71 const_loadlibs
72 constants
73 depend
74 dir_target
75 dist
76 dist_basics
77 dist_ci
78 dist_core
79 dist_dir
80 dist_test
81 dlsyms
82 dynamic
83 dynamic_bs
84 dynamic_lib
85 exescan
86 export_list
87 extliblist
c7a17d47 88 find_perl
89 fixin
90 force
91 guess_name
c7a17d47 92 htmlifypods
93 init_dirscan
94 init_main
95 init_others
96 install
97 installbin
c7a17d47 98 linkext
99 lsdir
100 macro
101 makeaperl
102 makefile
103 manifypods
c7a17d47 104 maybe_command_in_dirs
105 needs_linking
c7a17d47 106 pasthru
c7a17d47 107 perldepend
108 pm_to_blib
c7a17d47 109 ppd
110 prefixify
111 processPL
112 quote_paren
113 realclean
c7a17d47 114 static
115 static_lib
116 staticmake
117 subdir_x
118 subdirs
119 test
120 test_via_harness
121 test_via_script
122 tool_autosplit
123 tool_xsubpp
124 tools_other
125 top_targets
126 writedoc
127 xs_c
128 xs_cpp
129 xs_o
130 xsubpp_version
131 / )
132 {
133 ok ($class->can ($_), "can $_");
134 }
135
e567eb17 136###############################################################################
137# some more detailed tests for the methods above
138
139ok ( join (' ', $class->dist_basics()), 'distclean :: realclean distcheck');
140
141###############################################################################
142# has_link_code tests
143
144my $t = {}; bless $t,$class;
145$t->{HAS_LINK_CODE} = 1;
146is ($t->has_link_code(),1,'has_link_code'); is ($t->{HAS_LINK_CODE},1);
147
148$t->{HAS_LINK_CODE} = 0;
149is ($t->has_link_code(),0); is ($t->{HAS_LINK_CODE},0);
150
151delete $t->{HAS_LINK_CODE}; delete $t->{OBJECT};
152is ($t->has_link_code(),0); is ($t->{HAS_LINK_CODE},0);
153
154delete $t->{HAS_LINK_CODE}; $t->{OBJECT} = 1;
155is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1);
156
157delete $t->{HAS_LINK_CODE}; delete $t->{OBJECT}; $t->{MYEXTLIB} = 1;
158is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1);
159
160delete $t->{HAS_LINK_CODE}; delete $t->{MYEXTLIB}; $t->{C} = [ 'Gloin' ];
161is ($t->has_link_code(),1); is ($t->{HAS_LINK_CODE},1);
162
163###############################################################################
164# libscan
165
166is ($t->libscan('RCS'),'','libscan on RCS');
167is ($t->libscan('CVS'),'','libscan on CVS');
168is ($t->libscan('SCCS'),'','libscan on SCCS');
169is ($t->libscan('Fatty'),'Fatty','libscan on something not RCS, CVS or SCCS');
170
171###############################################################################
172# maybe_command
173
174is ($t->maybe_command('blargel'),undef,"'blargel' isn't a command");
175
176###############################################################################
177# nicetext (dummy method)
178
179is ($t->nicetext('LOTR'),'LOTR','nicetext');
180
181###############################################################################
182# parse_version
183
184my $self_name = '../lib/ExtUtils/t/MM_Unix.t';
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