5 extension_loaded("psi") or die("skip - need ext/psi");
11 function validate($check, $psi) {
12 $file = __DIR__."/001.psi";
13 file_put_contents($file, $psi);
14 if ($check !== psi_validate($file)) {
15 printf("Assertion failed!\nExpected: %s\n\n%s\n\n",
16 $check ? "true" : "false", $psi);
20 validate(false, "typedef void foo;");
21 validate(true, "typedef void *bar;");
22 validate(false, "typedef long int;");
23 validate(true, "typedef long foo;");
24 validate(true, "typedef struct foo bar;");
25 validate(true, "typedef struct {int a;} foo;");
26 validate(false, "struct a; \ntypedef struct a a_t;");
27 validate(true, "struct a::(8,8); \ntypedef struct a a_t;");
28 validate(true, "typedef struct a a_t; \nstruct a::(8,8);");
72 validate(true, "typedef int foo(int bar);");
73 validate(true, "typedef int (foo)(int bar);");
74 validate(true, "typedef int (*foo)(int bar);");
75 validate(true, "typedef int *(*foo)(int bar);");
76 validate(false, "typedef int *(*foo)(int *(*bar)(int baz));");
77 validate(true, "typedef int *(*bar)(int baz); \ntypedef int *(*foo)(bar bar);");
78 validate(true, "typedef int bar(int baz); \ntypedef int *(*foo)(bar bar);");
84 @unlink(__DIR__."/001.psi");
89 Warning: PSI syntax error: Unexpected token ';' at pos 17 in %s001.psi on line 1
91 Warning: PSI syntax error: Unexpected token 'int' at pos 14 in %s001.psi on line 1
93 Warning: Cannot compute size of empty struct 'a' in %s001.psi on line 1
95 Warning: Unknown variable 'X' in numeric expression in %s001.psi on line 4
97 Warning: PSI syntax error: Unexpected token '(' at pos 26 in %s001.psi on line 1
99 Warning: PSI syntax error: Unexpected token '(' at pos 32 in %s001.psi on line 1