1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373
|
#comment #####################################################################
#comment Filepp testsuite. This is run with the command: filepp testsuite
#comment It should produce no output other than a final OK.
#comment Thanks to Stephen Brooks for providing the original version of this.
#comment #####################################################################
#comment #####################################################################
#comment Numerical defines, ifs and ifdefs
#comment #####################################################################
#define FRED 1
#if FRED == 1
#else
FAIL __LINE__
#endif
#if FRED == 2
FAIL __LINE__
#else
#endif
#define GEORGE 1
#if defined GEORGE
#else
FAIL __LINE__
#endif
#if ! defined GEORGE
FAIL __LINE__
#else
#endif
#define BILL 3
#if defined BILL
#else
FAIL __LINE__
#endif
#if ! defined BILL
FAIL __LINE__
#else
#endif
#if defined GINGER
FAIL __LINE__
#else
#endif
#if ! defined GINGER
#else
FAIL __LINE__
#endif
#if GEORGE == BILL
FAIL __LINE__
#endif
#if GEORGE != BILL
#else
FAIL __LINE__
#endif
#define HERBERT 34
#define JOHN 34
#if (GEORGE == BILL) && (JOHN == HERBERT)
FAIL __LINE__
#endif
#if (GEORGE != BILL) && (JOHN == HERBERT)
#else
FAIL __LINE__
#endif
#if (GEORGE == BILL) && (JOHN != HERBERT)
FAIL __LINE__
#else
#endif
#if (GEORGE > BILL) && (JOHN != HERBERT)
FAIL __LINE__
#else
#endif
#if (JOHN < BILL)
FAIL __LINE__
#else
#endif
#if (JOHN < 33)
FAIL __LINE__
#else
#endif
#if (JOHN > 33)
#else
FAIL __LINE__
#endif
#ifdef BILL
#else
FAIL __LINE__
#endif
#undef BILL
#ifdef BILL
FAIL __LINE__
#endif
#ifdef PAUL
FAIL __LINE__
#else
#endif
#define ZERO 0
#if("ZERO" ne "0")
FAIL __LINE__
#endif
#comment Fancy Perl regexp if statements
#if("ZERO" =~ /\s/)
FAIL __LINE__
#elif("ZERO" =~ /\d/)
#else
FAIL __LINE__
#endif
#comment This next test is to check recursion is avoided, this used to throw
#comment filepp into a recursive loop
#define RECURS1 RECURS2 RECURS2
#define RECURS2 RECURS1 RECURS1
#if "RECURS1" eq "RECURS2"
#endif
#comment #####################################################################
#comment Macros with arguments and perl string comparisons
#comment #####################################################################
#define ARTHUR(bill, ben) bill and ben
#if (defined ARTHUR)
#else
FAIL __LINE__
#endif
#if !defined (ARTHUR)
FAIL __LINE__
#else
#ifdef ARTHUR
#else
FAIL __LINE__
#endif
#ifndef ARTHUR
FAIL __LINE__
#else
#endif
#endif
#if "ARTHUR" eq "ARTHUR"
#else
FAIL __LINE__
#endif
#if("ARTHUR" eq "ARTHUR")
#else
FAIL __LINE__
#endif
#if "ARTHUR(bill,ben)" ne "bill and ben"
FAIL __LINE__
#endif
#warning testsuite should now show warning about macro 'ARTHUR':
#if "ARTHUR()" ne " and "
FAIL __LINE__
#endif
#warning testsuite should now show warning about macro 'ARTHUR':
#if "ARTHUR(ben)" eq "bill and ben"
FAIL __LINE__
#endif
#warning testsuite should now show warning about macro 'ARTHUR':
#if "ARTHUR(bill ben)" eq "bill and ben"
FAIL __LINE__
#endif
#if "ARTHUR(fred, ben)" eq "bill and ben"
FAIL __LINE__
#endif
#define DEREK(VAL1, VAL2) :VAL1:VAL2:
#if "DEREK(func(arg1,arg2),scalar)" ne ":func(arg1,arg2):scalar:"
FAIL __LINE__
#endif
#define NOTARGS() NO ARGS IN THIS ONE
#if ("NOTARGS()" ne "NO ARGS IN THIS ONE")
FAIL __LINE__
#endif
#define MANYARGS(ONE, TWO, THREE, FOUR) ONE and TWO TWO and THREE and FOUR
#if "MANYARGS(1,2,3,4())" ne "1 and 2 2 and 3 and 4()"
FAIL __LINE__
#endif
#if "MANYARGS (spaces, tabs tabs, , and gaps)" ne \
"spaces and tabs tabs tabs tabs and and and gaps"
FAIL __LINE__
#endif
#define NOARGS (ONE, TWO) ONE TWO
#if "NOARGS" ne "(ONE, TWO) ONE TWO"
FAIL __LINE__
#endif
#define RECURSION(AGAIN) AGAIN
#if "RECURSION(RECURSION(RECURSION(OK)))" ne "OK"
FAIL __LINE__
#endif
#comment #####################################################################
#comment macros with any number of args
#comment #####################################################################
#define testmac(arg1, arg2, arg3...) <arg1> <arg2> <arg3>
#if("testmac(one, two, three, four, five) more stuff after" ne \
"<one> <two> <three, four, five> more stuff after")
FAIL __LINE__
#endif
#define eprintf(format, lastarg...) fprintf(stderr, format, ##lastarg)
#if "eprintf(%s, string);" ne "fprintf(stderr, %s, string);"
FAIL __LINE__
#endif
#if "eprintf(%s%d, string, int);" ne "fprintf(stderr, %s%d, string, int);"
FAIL __LINE__
#endif
#if "eprintf(empty);" ne "fprintf(stderr, empty);"
FAIL __LINE__
#endif
#define error(string, args...) fprintf(stderr, string, args);
#if "error(%d\,%s, i, string)" ne "fprintf(stderr, %d,%s, i, string);"
FAIL __LINE__
#endif
#define error(string, args...) fprintf(stderr, string, ##args);
#if "error(empty)" ne "fprintf(stderr, empty);"
FAIL __LINE__
#endif
#comment #####################################################################
#comment Nested ifs
#comment #####################################################################
#if 1
#if 0
FAIL __LINE__
#else
#endif
#else
FAIL __LINE__
#endif
#comment #####################################################################
#if 0
FAIL __LINE__
#if 1
FAIL __LINE__
#else
FAIL __LINE__
#endif
FAIL __LINE__
#else
#endif
#comment #####################################################################
#ifndef ARTHUR
FAIL __LINE__
#ifndef PHIL
FAIL __LINE__
#else
FAIL __LINE__
#endif
FAIL __LINE__
#else
#endif
#comment #####################################################################
#ifndef PHIL
#ifndef ARTHUR
FAIL __LINE__
#else
#endif
#else
FAIL __LINE__
#endif
#comment #####################################################################
#ifndef ARTHUR
FAIL __LINE__
#ifndef PHIL
FAIL __LINE__
#else
FAIL __LINE__
#endif
#else
#endif
#comment #####################################################################
#comment elsif
#comment #####################################################################
#if 1
#if 0
FAIL __LINE__
#elif 1
#if 0
FAIL __LINE__
#elif 1
#else
FAIL __LINE__
#endif
#else
FAIL __LINE__
#endif
#elif 1
FAIL __LINE__
#elif 1
FAIL __LINE__
#endif
#define OUTER_IF
#define INNER_IF 1
#if defined(OUTER_IF)
# if (INNER_IF==1)
# define INNER_IF_TEST
# elif (INNER_IF==2)
FAIL __LINE__
# else
FAIL __LINE__
# endif
# define OUTER_IF_TEST
#else
# if (0)
FAIL __LINE__
# endif
FAIL __LINE__
#endif
#ifndef INNER_IF_TEST
FAIL __LINE__
#endif
#ifndef OUTER_IF_TEST
FAIL __LINE__
#endif
#comment #####################################################################
#comment Includes
#comment #####################################################################
#include "testinc"
#ifndef INCLUDED
FAIL __LINE__
#endif
#comment #####################################################################
#comment Non-ascii
#comment #####################################################################
#comment define POUND
#comment
#comment #####################################################################
#comment White space
#comment #####################################################################
# if 1
# else
FAIL __LINE__
\
# endif
#ifndef \
GEORGE
FAIL __LINE__
#endif
#define TAB tab
#if "TAB" ne "tab"
FAIL __LINE__
#endif
#comment #####################################################################
#comment Pragma, Modules and keywords
#comment #####################################################################
#pragma filepp UseModule testmod.pm
#TEST comment This should be parsed as a TESTEND
normal comment
#TEST if TESTEND
0
FAIL __LINE__
#TEST endif
#TEST pragma filepp SetCharPerlre 1
#TEST pragma filepp SetKeywordchar #
#pragma filepp SetContchar \\\\
#comment Normal line \
continution (perlre)
#if \
0
FAIL __LINE__
#endif
#pragma filepp SetCharPerlre 0
#pragma filepp SetContchar NULL
#pragma filepp SetContchar \
#comment Normal line \
continution
#if \
0
FAIL __LINE__
#endif
#pragma filepp SetOptLineEndchar */
#pragma filepp SetKeywordchar /*#
/*#define OPTCHARS test*/
/*#pragma filepp SetKeywordchar #*/
#pragma filepp SetOptLineEndchar
#if ("OPTCHARS" ne "test")
FAIL __LINE__
#endif
#comment #####################################################################
#comment Safemode
#comment #####################################################################
#pragma filepp SafeMode
#pragma filepp SetKeywordchar UNSAFE
#comment FAIL __LINE__
#comment #####################################################################
#comment End of tests
#comment #####################################################################
|