The Im() function wasn't returning zero for non-Math::Complex
[p5sagit/p5-mst-13.2.git] / t / TEST
CommitLineData
8d063cd8 1#!./perl
2
e824fb2c 3# Last change: Fri May 28 03:16:57 BST 1999
8d063cd8 4
5# This is written in a peculiar style, since we're trying to avoid
6# most of the constructs we'll be testing for.
7
a687059c 8$| = 1;
9
3e6e8be7 10if ($#ARGV >= 0 && $ARGV[0] eq '-v') {
8d063cd8 11 $verbose = 1;
12 shift;
13}
14
378cc40b 15chdir 't' if -f 't/TEST';
16
3e6e8be7 17die "You need to run \"make test\" first to set things up.\n"
4633a7c4 18 unless -e 'perl' or -e 'perl.exe';
19
3fb91a5e 20# check leakage for embedders
21$ENV{PERL_DESTRUCT_LEVEL} = 2 unless exists $ENV{PERL_DESTRUCT_LEVEL};
22
4633a7c4 23$ENV{EMXSHELL} = 'sh'; # For OS/2
748a9306 24
3e6e8be7 25if ($#ARGV == -1) {
26 @ARGV = split(/[ \n]/,
04c8f6e4 27 `echo base/*.t comp/*.t cmd/*.t io/*.t; echo op/*.t pragma/*.t lib/*.t`);
8d063cd8 28}
29
6ee623d5 30%infinite = ( 'comp/require.t', 1, 'op/bop.t', 1, 'lib/hostname.t', 1 );
31
32_testprogs('perl', @ARGV);
33_testprogs('compile', @ARGV) if (-e "../testcompile");
34
bb365837 35sub _testprogs {
36 $type = shift @_;
37 @tests = @_;
6ee623d5 38
39
bb365837 40 print <<'EOT' if ($type eq 'compile');
6ee623d5 41--------------------------------------------------------------------------------
42TESTING COMPILER
43--------------------------------------------------------------------------------
bb365837 44EOT
45
9636a016 46 $ENV{PERLCC_TIMEOUT} = 120
47 if ($type eq 'compile' && !$ENV{PERLCC_TIMEOUT});
ef712cf7 48
bb365837 49 $bad = 0;
50 $good = 0;
51 $total = @tests;
52 $files = 0;
53 $totmax = 0;
088b5126 54 $maxlen = 0;
55 foreach (@tests) {
56 $len = length;
57 $maxlen = $len if $len > $maxlen;
58 }
59 # +3 : we want three dots between the test name and the "ok"
60 # -2 : the .t suffix
61 $dotdotdot = $maxlen + 3 - 2;
bb365837 62 while ($test = shift @tests) {
63
64 if ( $infinite{$test} && $type eq 'compile' ) {
65 print STDERR "$test creates infinite loop! Skipping.\n";
66 next;
6ee623d5 67 }
bb365837 68 if ($test =~ /^$/) {
69 next;
6ee623d5 70 }
bb365837 71 $te = $test;
72 chop($te);
088b5126 73 print "$te" . '.' x ($dotdotdot - length($te));
bb365837 74
d638aca2 75 open(SCRIPT,"<$test") or die "Can't run $test.\n";
76 $_ = <SCRIPT>;
77 close(SCRIPT);
78 if (/#!.*perl(.*)$/) {
79 $switch = $1;
80 if ($^O eq 'VMS') {
81 # Must protect uppercase switches with "" on command line
82 $switch =~ s/-([A-Z]\S*)/"-$1"/g;
55497cff 83 }
135863df 84 }
bb365837 85 else {
d638aca2 86 $switch = '';
87 }
6ee623d5 88
d638aca2 89 if ($type eq 'perl') {
90 open(RESULTS,"./perl$switch $test |") or print "can't run.\n";
91 }
92 else {
5b541967 93 open(RESULTS, "./perl -I../lib ../utils/perlcc -o ./$test.plc ./$test "
94 ." && ./$test.plc |")
d638aca2 95 or print "can't compile.\n";
5b541967 96 unlink "./$test.plc";
6ee623d5 97 }
d638aca2 98
bb365837 99 $ok = 0;
100 $next = 0;
101 while (<RESULTS>) {
102 if ($verbose) {
103 print $_;
104 }
105 unless (/^#/) {
106 if (/^1\.\.([0-9]+)/) {
107 $max = $1;
108 $totmax += $max;
109 $files += 1;
110 $next = 1;
111 $ok = 1;
112 }
113 else {
114 $next = $1, $ok = 0, last if /^not ok ([0-9]*)/;
f178911d 115 if (/^ok (\d+)(\s*#.*)?/ && $1 == $next) {
bb365837 116 $next = $next + 1;
d667a7e6 117 }
118 elsif (/^Bail out!\s*(.*)/i) { # magic words
119 die "FAILED--Further testing stopped" . ($1 ? ": $1\n" : ".\n");
bb365837 120 }
121 else {
122 $ok = 0;
123 }
8d063cd8 124 }
125 }
126 }
bb365837 127 close RESULTS;
128 $next = $next - 1;
129 if ($ok && $next == $max) {
130 if ($max) {
131 print "ok\n";
132 $good = $good + 1;
133 }
134 else {
135 print "skipping test on this platform\n";
136 $files -= 1;
137 }
bcce72a7 138 }
bb365837 139 else {
140 $next += 1;
141 print "FAILED at test $next\n";
142 $bad = $bad + 1;
143 $_ = $test;
144 if (/^base/) {
145 die "Failed a basic test--cannot continue.\n";
146 }
8d063cd8 147 }
148 }
8d063cd8 149
bb365837 150 if ($bad == 0) {
151 if ($ok) {
152 print "All tests successful.\n";
153 # XXX add mention of 'perlbug -ok' ?
154 }
155 else {
156 die "FAILED--no tests were run for some reason.\n";
157 }
8d063cd8 158 }
bb365837 159 else {
ba1398cf 160 $pct = $files ? sprintf("%.2f", ($files - $bad) / $files * 100) : "0.00";
bb365837 161 if ($bad == 1) {
e824fb2c 162 warn "Failed 1 test script out of $files, $pct% okay.\n";
bb365837 163 }
164 else {
e824fb2c 165 warn "Failed $bad test scripts out of $files, $pct% okay.\n";
bb365837 166 }
167 warn <<'SHRDLU';
f46c10df 168 ### Since not all tests were successful, you may want to run some
169 ### of them individually and examine any diagnostic messages they
170 ### produce. See the INSTALL document's section on "make test".
6ee623d5 171 ### If you are testing the compiler, then ignore this message
172 ### and run
173 ### ./perl harness
174 ### in the directory ./t.
f46c10df 175SHRDLU
bb365837 176 warn <<'SHRDLU' if $good / $total > 0.8;
3e6e8be7 177 ###
178 ### Since most tests were successful, you have a good chance to
179 ### get information with better granularity by running
6ee623d5 180 ### ./perl harness
3e6e8be7 181 ### in directory ./t.
182SHRDLU
bb365837 183 }
184 ($user,$sys,$cuser,$csys) = times;
185 print sprintf("u=%g s=%g cu=%g cs=%g scripts=%d tests=%d\n",
186 $user,$sys,$cuser,$csys,$files,$totmax);
6ee623d5 187}
3e6e8be7 188exit ($bad != 0);