5 extension_loaded("psi") or die("skip - need ext/psi");
10 function validate($check, $psi) {
11 $file = __DIR__."/001.psi";
12 file_put_contents($file, $psi);
13 if ($check !== psi_validate($file)) {
14 printf("Assertion failed!\nExpected: %s\n\n%s\n\n",
15 $check ? "true" : "false", $psi);
19 validate(false, "typedef void foo;");
20 validate(true, "typedef void *bar;");
21 validate(false, "typedef long int;");
22 validate(true, "typedef long foo;");
23 validate(false, "typedef struct foo bar;");
24 validate(true, "typedef struct {int a;} foo;");
25 validate(false, "struct a; \ntypedef struct a a_t;");
26 validate(true, "struct a::(8,8); \ntypedef struct a a_t;");
27 validate(true, "typedef struct a a_t; \nstruct a::(8,8);");
71 validate(true, "typedef int foo(int bar);");
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(false, "typedef int *(*foo)(int *(*bar)(int baz));");
76 validate(true, "typedef int *(*bar)(int baz); \ntypedef int *(*foo)(bar bar);");
77 validate(false, "typedef int bar(int baz); \ntypedef int *(*foo)(bar bar);");
83 @unlink(__DIR__."/001.psi");
88 Warning: PSI syntax error: Unexpected token ';' in %s001.psi on line 1
90 Warning: PSI syntax error: Unexpected token 'int' in %s001.psi on line 1
92 Warning: Type 'bar' cannot be aliased to struct 'foo' in %s001.psi on line 1
94 Warning: Cannot compute size of empty struct 'a' in %s001.psi on line 1
96 Warning: Unknown variable 'X' in numeric expression in %s001.psi on line 4
98 Warning: PSI syntax error: Unexpected token '(' in %s001.psi on line 1