This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
require should ignore directories found when searching @INC not just
[perl5.git] / t / lib / h2ph.h
1 /* 
2  * Test header file for h2ph
3  * 
4  * Try to test as many constructs as possible
5  * For example, the multi-line comment :)
6  */
7
8 /* And here's a single line comment :) */
9
10 /* Test #define with no indenting, over multiple lines */
11 #define SQUARE(x) \
12 ((x)*(x))
13
14 /* Test #ifndef and parameter interpretation*/
15 #ifndef ERROR
16 #define ERROR(x) fprintf(stderr, "%s\n", x[2][3][0])
17 #endif /* ERROR */
18
19 #ifndef _H2PH_H_
20 #define _H2PH_H_
21
22 /* #ident - doesn't really do anything, but I think it always gets included anyway */
23 #ident "$Revision h2ph.h,v 1.0 98/05/04 20:42:14 billy $"
24
25 /* Test #undef */
26 #undef MAX
27 #define MAX(a,b) ((a) > (b) ? (a) : (b))
28
29 /* Test #ifdef */
30 #ifdef __SOME_UNIMPORTANT_PROPERTY
31 #define MIN(a,b) ((a) < (b) ? (a) : (b))
32 #endif /* __SOME_UNIMPORTANT_PROPERTY */
33
34 /* 
35  * Test #if, #elif, #else, #endif, #warn and #error, and `!'
36  * Also test whitespace between the `#' and the command
37  */
38 #if !(defined __SOMETHING_MORE_IMPORTANT)
39 #    warn Be careful...
40 #elif !(defined __SOMETHING_REALLY_REALLY_IMPORTANT)
41 #    error "Nup, can't go on" /* ' /* stupid font-lock-mode */
42 #else /* defined __SOMETHING_MORE_IMPORTANT && defined __SOMETHING_REALLY_REALLY_IMPORTANT */
43 #    define EVERYTHING_IS_OK
44 #endif
45
46 /* Test && and || */
47 #undef WHATEVER
48 #if (!((defined __SOMETHING_TRIVIAL && defined __SOMETHING_LESS_SO)) \
49      || defined __SOMETHING_OVERPOWERING)
50 #    define WHATEVER 6
51 #elif !(defined __SOMETHING_TRIVIAL) /* defined __SOMETHING_LESS_SO */
52 #    define WHATEVER 7
53 #elif !(defined __SOMETHING_LESS_SO) /* defined __SOMETHING_TRIVIAL */
54 #    define WHATEVER 8
55 #else /* defined __SOMETHING_TRIVIAL && defined __SOMETHING_LESS_SO */
56 #    define WHATEVER 1000
57 #endif
58
59 /* Test passing through the alien constructs (perlbug #34493) */
60 #ifdef __LANGUAGE_PASCAL__
61 function Tru64_Pascal(n: Integer): Integer;
62 #endif
63
64 /* 
65  * Test #include, #import and #include_next
66  * #include_next is difficult to test, it really depends on the actual
67  *  circumstances - for example, `#include_next <limits.h>' on a Linux system
68  *  with `use lib qw(/opt/perl5/lib/site_perl/i586-linux/linux);' or whatever
69  *  your equivalent is...
70  */
71 #include <sys/socket.h>
72 #import "sys/ioctl.h"
73 #include_next <sys/fcntl.h>
74
75 /* typedefs should be ignored */
76 typedef struct a_struct {
77   int typedefs_should;
78   char be_ignored;
79   long as_well;
80 } a_typedef;
81
82 /* 
83  * however, typedefs of enums and just plain enums should end up being treated
84  * like a bunch of #defines...
85  */
86
87 typedef enum _days_of_week { sun, mon, tue, wed, thu, fri, sat, Sun=0, Mon,
88                              Tue, Wed, Thu, Fri, Sat } days_of_week;
89
90 /* 
91  * Some moderate flexing of tri-graph pre substitution.
92  */
93 ??=ifndef _SOMETHING_TRIGRAPHIC
94 ??=define _SOMETHING_TRIGRAPHIC
95 ??= define SOMETHING_ELSE_TRIGRAPHIC_0 "??!"          /* | ??!|  || */
96  ??=define SOMETHING_ELSE_TRIGRAPHIC_1 "??'"          /* | ??'|  ^| */
97 ??= define SOMETHING_ELSE_TRIGRAPHIC_2 "??("          /* | ??(|  [| */
98  ??= define SOMETHING_ELSE_TRIGRAPHIC_3 "??)"         /* | ??)|  ]| */
99 ??=define SOMETHING_ELSE_TRIGRAPHIC_4  "??-0"         /* | ??-|  ~| */
100         ??= define SOMETHING_ELSE_TRIGRAPHIC_5 "??/ " /* | ??/|  \| */
101 ??= define SOMETHING_ELSE_TRIGRAPHIC_6 "??<"          /* | ??<|  {| */
102 ??=define SOMETHING_ELSE_TRIGRAPHIC_7  "??="          /* | ??=|  #| */
103 ??= define SOMETHING_ELSE_TRIGRAPHIC_8 "??>"          /* | ??>|  }| */
104         ??=endif
105
106 // test C++-style comment
107
108 #if 1
109 typdef struct empty_struct {
110 } // trailing C++-style comment should not force continuation
111 #endif
112
113 /* comments (that look like string) inside enums... */
114
115 enum {
116    /* foo;
117      can't
118    */                        
119  };
120
121 enum flimflam {
122   flim,
123    /* foo;
124      can't
125    */
126   flam                      
127  } flamflim;
128
129 /* Handle multi-line quoted strings: */
130 __asm__ __volatile__("
131     this
132     produces
133     no
134     output
135 ");
136
137 #define multiline "multiline
138 string"
139
140 #endif /* _H2PH_H_ */