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 echo "Assertion failed!\n";
18 validate(false, "typedef void foo;");
19 validate(true, "typedef void *bar;");
20 validate(false, "typedef long int;");
21 validate(true, "typedef long foo;");
22 validate(false, "typedef struct foo bar;");
23 validate(true, "typedef struct {int a;} foo;");
24 validate(false, "struct a; \n typedef struct a a_t;");
25 validate(true, "struct a::(8,8); \n typedef struct a a_t;");
26 validate(true, "typedef struct a a_t; \n struct a::(8,8);");
70 validate(true, "typedef int foo(int bar);");
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(false, "typedef int *(*foo)(int *(*bar)(int baz));");
75 validate(true, "typedef int *(*bar)(int baz); \n typedef int *(*foo)(bar bar);");
76 validate(false, "typedef int bar(int baz); \n typedef int *(*foo)(bar bar);");
82 @unlink(__DIR__."/001.psi");
87 Warning: PSI syntax error: Unexpected token ';' in %s001.psi on line 1
89 Warning: PSI syntax error: Unexpected token 'int' in %s001.psi on line 1
91 Warning: Type 'bar' cannot be aliased to struct 'foo' 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 '(' in %s001.psi on line 1