perl 4.0 patch 22: patch #20, continued
[p5sagit/p5-mst-13.2.git] / t / comp / cpp.t
CommitLineData
8d063cd8 1#!./perl -P
2
68decaef 3# $RCSfile: cpp.t,v $$Revision: 4.0.1.1 $$Date: 92/06/08 15:42:08 $
4
5open(CONFIG,"../config.sh") || die;
6while (<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}
15close CONFIG;
8d063cd8 16
17print "1..3\n";
18
19#this is a comment
20#define MESS "ok 1\n"
21print 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
5303340c 30open(TRY,">Comp.cpp.tmp") || die "Can't open temp perl file.";
8d063cd8 31
5303340c 32($prog = <<'END') =~ s/X//g;
33X$ok = "not ok 3\n";
34X#include "Comp.cpp.inc"
35X#ifdef OK
36X$ok = OK;
37X#endif
38Xprint $ok;
39END
40print TRY $prog;
41close TRY;
42
43open(TRY,">Comp.cpp.inc") || (die "Can't open temp include file.");
44print TRY '#define OK "ok 3\n"' . "\n";
45close TRY;
8d063cd8 46
47$pwd=`pwd`;
48$pwd =~ s/\n//;
5303340c 49$x = `./perl -P Comp.cpp.tmp`;
8d063cd8 50print $x;
87250799 51unlink "Comp.cpp.tmp", "Comp.cpp.inc";