perl 4.0 patch 22: patch #20, continued
[p5sagit/p5-mst-13.2.git] / t / comp / cpp.t
1 #!./perl -P
2
3 # $RCSfile: cpp.t,v $$Revision: 4.0.1.1 $$Date: 92/06/08 15:42:08 $
4
5 open(CONFIG,"../config.sh") || die;
6 while (<CONFIG>) {
7     if (/^cppstdin/) {
8         if (/^cppstdin='(.*cppstdin)'/ && ! -e $1) {
9             print "1..0\n";
10             exit;               # Can't test till after install, alas.
11         }
12         last;
13     }
14 }
15 close CONFIG;
16
17 print "1..3\n";
18
19 #this is a comment
20 #define MESS "ok 1\n"
21 print MESS;
22
23 #If you capitalize, it's a comment.
24 #ifdef MESS
25         print "ok 2\n";
26 #else
27         print "not ok 2\n";
28 #endif
29
30 open(TRY,">Comp.cpp.tmp") || die "Can't open temp perl file.";
31
32 ($prog = <<'END') =~ s/X//g;
33 X$ok = "not ok 3\n";
34 X#include "Comp.cpp.inc"
35 X#ifdef OK
36 X$ok = OK;
37 X#endif
38 Xprint $ok;
39 END
40 print TRY $prog;
41 close TRY;
42
43 open(TRY,">Comp.cpp.inc") || (die "Can't open temp include file.");
44 print TRY '#define OK "ok 3\n"' . "\n";
45 close TRY;
46
47 $pwd=`pwd`;
48 $pwd =~ s/\n//;
49 $x = `./perl -P Comp.cpp.tmp`;
50 print $x;
51 unlink "Comp.cpp.tmp", "Comp.cpp.inc";