parser panics on lvalue methods
[p5sagit/p5-mst-13.2.git] / t / op / system.t
CommitLineData
dd7038b3 1#!perl
2
3BEGIN {
4 chdir 't' if -d 't';
5 @INC = '../lib';
6 # XXX this could be further munged to enable some parts on other
7 # platforms
8 unless ($^O =~ /^MSWin/) {
9 print "1..0 # skipped: windows specific test\n";
10 exit 0;
11 }
12}
13
14use File::Path;
15use File::Copy;
16use Config;
17use Cwd;
18use strict;
19
20$| = 1;
21
22my $cwd = cwd();
23
24my $testdir = "t e s t";
25my $exename = "showav";
26my $plxname = "showargv";
27rmtree($testdir);
28mkdir($testdir);
29
30open(my $F, ">$testdir/$exename.c")
31 or die "Can't create $testdir/$exename.c: $!";
32print $F <<'EOT';
33#include <stdio.h>
34int
35main(int ac, char **av)
36{
37 int i;
38 for (i = 0; i < ac; i++)
39 printf("[%s]", av[i]);
40 printf("\n");
41 return 0;
42}
43EOT
44
45open($F, ">$testdir/$plxname.bat")
46 or die "Can't create $testdir/$plxname.bat: $!";
47print $F <<'EOT';
48@rem = '--*-Perl-*--
49@echo off
50if "%OS%" == "Windows_NT" goto WinNT
51EOT
52
53print $F <<EOT;
54"$^X" -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
55goto endofperl
56:WinNT
57"$^X" -x -S %0 %*
58EOT
59print $F <<'EOT';
60if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl
61if %errorlevel% == 9009 echo You do not have Perl in your PATH.
62if errorlevel 1 goto script_failed_so_exit_with_non_zero_val 2>nul
63goto endofperl
64@rem ';
65#!perl
66#line 15
67print "[$_]" for ($0, @ARGV);
68print "\n";
69__END__
70:endofperl
71EOT
72
73close $F;
74
75# build the executable
76chdir($testdir);
77END {
78 chdir($cwd);
79 rmtree($testdir);
80}
81if (open(my $EIN, "$cwd/op/${exename}_exe.uu")) {
82 print "# Unpacking $exename.exe\n";
83 my $e;
84 {
85 local $/;
86 $e = unpack "u", <$EIN>;
87 close $EIN;
88 }
89 open my $EOUT, ">$exename.exe" or die "Can't write $exename.exe: $!";
90 binmode $EOUT;
91 print $EOUT $e;
92 close $EOUT;
93}
94else {
95 print "# Compiling $exename.c\n";
96 if (system("$Config{cc} $Config{ccflags} $exename.c 2>&1 >nul") != 0) {
97 print "# Could not compile $exename.c, status $?\n"
98 ."# Where is your C compiler?\n"
99 ."1..0 # skipped: can't build test executable\n";
100 }
101}
102copy("$plxname.bat","$plxname.cmd");
103chdir($cwd);
104
105open my $T, "$^X -I../lib -w op/system_tests |"
106 or die "Can't spawn op/system_tests: $!";
107my $expect;
108my $comment = "";
109my $test = 0;
110while (<$T>) {
111 chomp;
112 if (/^1\.\./) {
113 print "$_\n";
114 }
115 elsif (/^#+\s(.*)$/) {
116 $comment = $1;
117 }
118 elsif (/^</) {
119 $expect = $_;
120 $expect =~ tr/<>/[]/;
121 $expect =~ s/\Q$plxname\E]/$plxname.bat]/;
122 }
123 else {
124 if ($expect ne $_) {
125 print "# $comment\n" if $comment;
126 print "# want: $expect\n";
127 print "# got : $_\n";
128 print "not ";
129 }
130 ++$test;
131 print "ok $test\n";
132 }
133}
134close $T;