Commit | Line | Data |
8d063cd8 |
1 | #!./perl -P |
2 | |
68decaef |
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; |
8d063cd8 |
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 | |
5303340c |
30 | open(TRY,">Comp.cpp.tmp") || die "Can't open temp perl file."; |
8d063cd8 |
31 | |
5303340c |
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; |
8d063cd8 |
46 | |
47 | $pwd=`pwd`; |
48 | $pwd =~ s/\n//; |
5303340c |
49 | $x = `./perl -P Comp.cpp.tmp`; |
8d063cd8 |
50 | print $x; |
87250799 |
51 | unlink "Comp.cpp.tmp", "Comp.cpp.inc"; |