More DWIMminess for Class::Struct: calling the array or hash
[p5sagit/p5-mst-13.2.git] / t / lib / 1_compile.t
1 #!./perl
2
3 BEGIN {
4     chdir '..' if -d '../pod' && -d '../t';
5     @INC = 'lib';
6 }
7
8 use strict;
9 use warnings;
10 use Config;
11
12 my %Core_Modules;
13
14 unless (open(MANIFEST, "MANIFEST")) {
15     die "$0: failed to open 'MANIFEST': $!\n";
16 }
17
18 sub add_by_name {
19     $Core_Modules{$_[0]}++;
20 }
21
22 while (<MANIFEST>) {
23     next unless m!^lib/(\S+?)\.pm!;
24     my $module = $1;
25     $module =~ s!/!::!g;
26     add_by_name($module);
27 }
28
29 close(MANIFEST);
30
31 # Delete stuff that can't be tested here.
32
33 sub delete_by_name {
34     delete $Core_Modules{$_[0]};
35 }
36
37 sub has_extension {
38     $Config{extensions} =~ /\b$_[0]\b/i;
39 }
40
41 sub delete_unless_has_extension {
42     delete $Core_Modules{$_[0]} unless has_extension($_[0]);
43 }
44
45 foreach my $known_extension (split(' ', $Config{known_extensions})) {
46     delete_unless_has_extension($known_extension);
47 }
48
49 sub delete_by_prefix {
50     for my $match (grep { /^$_[0]/ } keys %Core_Modules) {
51         delete_by_name($match);
52     }
53 }
54
55 delete_by_name('CGI::Fast');            # won't load without FCGI
56
57 delete_by_name('Devel::DProf');         # needs to be run as -d:DProf
58
59 delete_by_prefix('ExtUtils::MM_');      # ExtUtils::MakeMaker's domain
60
61 delete_by_prefix('File::Spec::');       # File::Spec's domain
62 add_by_name('File::Spec::Functions');   # put this back
63
64 sub using_feature {
65     my $use = "use$_[0]";
66     exists $Config{$use} &&
67         defined $Config{$use} &&
68         $Config{$use} eq 'define';
69 }
70
71 unless (using_feature('threads') && has_extension('Thread')) {
72     delete_by_name('Thread');
73     delete_by_prefix('Thread::');
74 }
75
76 delete_by_prefix('unicode::');
77 add_by_name('unicode::distinct');       # put this back
78
79
80 # Delete all modules which have their own tests.  This makes
81 # this test a lot faster.
82 foreach my $mod (<DATA>) {
83     chomp $mod;
84     delete_by_name($mod);
85 }
86
87 # Okay, this is the list.
88
89 my @Core_Modules = sort keys %Core_Modules;
90
91 print "1..".@Core_Modules."\n";
92
93 my $test_num = 1;
94
95 foreach my $module (@Core_Modules) {
96     print "# $module compile failed\nnot " unless compile_module($module);
97     print "ok $test_num\n";
98     $test_num++;
99 }
100
101 # We do this as a separate process else we'll blow the hell
102 # out of our namespace.
103 sub compile_module {
104     my ($module) = $_[0];
105     
106     return scalar `$^X "-Ilib" t/lib/compmod.pl $module` =~ /^ok/;
107 }
108
109 __DATA__
110 AnyDBM_File
111 AutoLoader
112 B
113 B::Debug
114 B::Deparse
115 B::ShowLex
116 B::Stash
117 Benchmark
118 CGI
119 CGI::Pretty
120 CGI::Util
121 Carp
122 Class::ISA
123 Class::Struct
124 CPAN
125 Cwd
126 DB_File
127 Data::Dumper
128 Devel::DProf
129 Devel::Peek
130 Devel::SelfStubber
131 Digest
132 Digest::MD5
133 DirHandle
134 Dumpvalue
135 Encode
136 English
137 Env
138 Errno
139 Exporter
140 Exporter::Heavy
141 Fatal
142 Fcntl
143 File::Basename
144 File::CheckTree
145 File::Copy
146 File::DosGlob
147 File::Find
148 File::Glob
149 File::Path
150 File::Spec
151 File::Spec::Functions
152 File::Temp
153 FileCache
154 FileHandle
155 Filter::Simple
156 Filter::Util::Call
157 FindBin
158 GDBM_File
159 Getopt::Long
160 Getopt::Std
161 IO::Dir
162 IO::File
163 IO::Handle
164 IO::Pipe
165 IO::Poll
166 IO::Seekable
167 IO::Select
168 IO::Socket
169 IO::Socket::INET
170 IO::Socket::UNIX
171 IPC::Open2
172 IPC::Open3
173 IPC::SysV
174 List::Util
175 Locale::Constants
176 Locale::Country
177 Locale::Currency
178 Locale::Language
179 MIME::Base64
180 MIME::QuotedPrint
181 Math::BigFloat
182 Math::BigInt
183 Math::Complex
184 Math::Trig
185 NDBM_File
186 NEXT
187 Net::hostent
188 ODBM_File
189 Opcode
190 POSIX
191 Pod::Checker
192 Pod::Find
193 Pod::Text
194 Pod::Usage
195 SDBM_File
196 Safe
197 Scalar::Util
198 Search::Dict
199 SelectSaver
200 SelfLoader
201 Socket
202 Storable
203 Switch
204 Symbol
205 Sys::Hostname
206 Sys::Syslog
207 Term::ANSIColor
208 Test
209 Test::Harness
210 Test::ParseWords
211 Text::Abbrev
212 Text::Balanced
213 Text::ParseWords
214 Text::Soundex
215 Text::Tabs
216 Text::Wrap
217 Thread
218 Tie::Array
219 Tie::Handle
220 Tie::Hash
221 Tie::RefHash
222 Tie::Scalar
223 Tie::SubstrHash
224 Time::HiRes
225 Time::Local
226 Time::Piece
227 UNIVERSAL
228 XS::Typemap
229 attrs
230 base
231 bytes
232 charnames
233 constant
234 diagnostics
235 fields
236 integer
237 locale
238 ops
239 overload
240 strict
241 subs
242 utf8
243 vars
244 warnings
245 warnings::register