fix leak
[m6w6/ext-psi] / tests / parser / validate001.phpt
1 --TEST--
2 validate types
3 --SKIPIF--
4 <?php
5 extension_loaded("psi") or die("skip - need ext/psi");
6 ?>
7 --FILE--
8 ===TEST===
9 <?php
10
11 function validate($check, $psi) {
12 if ($check !== psi_validate_string($psi)) {
13 printf("Assertion failed!\nExpected: %s\n\n%s\n\n",
14 $check ? "true" : "false", $psi);
15 }
16 }
17
18 validate(true, "typedef void *bar;");
19 validate(true, "typedef long foo;");
20 validate(true, "typedef struct foo bar;");
21 validate(true, "typedef struct {int a;} foo;");
22 validate(true, "struct a::(8,8); \ntypedef struct a a_t;");
23 validate(true, "typedef struct a a_t; \nstruct a::(8,8);");
24
25 validate(true,
26 <<<PSI
27 enum {
28 A,
29 B,
30 C
31 }
32 PSI
33 );
34
35 validate(true,
36 <<<PSI
37 struct a {
38 int i;
39 }
40 struct b {
41 long l;
42 }
43 typedef struct b b;
44 union v {
45 struct a a;
46 b b;
47 struct {
48 double d;
49 } s;
50 union {
51 long l;
52 double d;
53 } u;
54 }
55 PSI
56 );
57
58 validate(true, "typedef int foo(int bar);");
59 validate(true, "typedef int (foo)(int bar);");
60 validate(true, "typedef int (*foo)(int bar);");
61 validate(true, "typedef int *(*foo)(int bar);");
62 validate(true, "typedef int *(*bar)(int baz); \ntypedef int *(*foo)(bar bar);");
63 validate(true, "typedef int bar(int baz); \ntypedef int *(*foo)(bar bar);");
64
65 ?>
66 ===DONE===
67 --EXPECTF--
68 ===TEST===
69 ===DONE===