Commit | Line | Data |
---|---|---|
16d20bd9 AD |
1 | #!./perl -P |
2 | ||
3 | # $RCSfile: cpp.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:18 $ | |
4 | ||
5 | print "1..3\n"; | |
6 | ||
7 | #this is a comment | |
8 | #define MESS "ok 1\n" | |
9 | print MESS; | |
10 | ||
11 | #If you capitalize, it's a comment. | |
12 | #ifdef MESS | |
13 | print "ok 2\n"; | |
14 | #else | |
15 | print "not ok 2\n"; | |
16 | #endif | |
17 | ||
18 | open(TRY,">Comp.cpp.tmp") || die "Can't open temp perl file."; | |
19 | ||
20 | ($prog = <<'END') =~ s/X//g; | |
21 | X$ok = "not ok 3\n"; | |
22 | X#include "Comp.cpp.inc" | |
23 | X#ifdef OK | |
24 | X$ok = OK; | |
25 | X#endif | |
26 | Xprint $ok; | |
27 | END | |
28 | print TRY $prog; | |
29 | close TRY; | |
30 | ||
31 | open(TRY,">Comp.cpp.inc") || (die "Can't open temp include file."); | |
32 | print TRY '#define OK "ok 3\n"' . "\n"; | |
33 | close TRY; | |
34 | ||
35 | $pwd=`pwd`; | |
36 | $pwd =~ s/\n//; | |
37 | $x = `./perl -P Comp.cpp.tmp`; | |
38 | print $x; | |
39 | unlink "Comp.cpp.tmp", "Comp.cpp.inc"; |