015.phpt 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. --TEST--
  2. FFI 015: Incomplete type usage
  3. --EXTENSIONS--
  4. ffi
  5. --INI--
  6. ffi.enable=1
  7. --FILE--
  8. <?php
  9. try {
  10. FFI::cdef("struct DIR; static struct DIR dir;");
  11. echo "ok\n";
  12. } catch (Throwable $e) {
  13. echo get_class($e) . ": " . $e->getMessage()."\n";
  14. }
  15. try {
  16. FFI::cdef("struct DIR; static struct DIR *ptr;");
  17. echo "ok\n";
  18. } catch (Throwable $e) {
  19. echo get_class($e) . ": " . $e->getMessage()."\n";
  20. }
  21. try {
  22. FFI::cdef("struct DIR; typedef struct DIR DIR; static DIR dir;");
  23. echo "ok\n";
  24. } catch (Throwable $e) {
  25. echo get_class($e) . ": " . $e->getMessage()."\n";
  26. }
  27. try {
  28. FFI::cdef("struct DIR; typedef struct DIR DIR; static DIR *ptr;");
  29. echo "ok\n";
  30. } catch (Throwable $e) {
  31. echo get_class($e) . ": " . $e->getMessage()."\n";
  32. }
  33. try {
  34. FFI::cdef("struct DIR; static struct DIR foo();");
  35. echo "ok\n";
  36. } catch (Throwable $e) {
  37. echo get_class($e) . ": " . $e->getMessage()."\n";
  38. }
  39. try {
  40. FFI::cdef("struct DIR; static struct DIR* foo();");
  41. echo "ok\n";
  42. } catch (Throwable $e) {
  43. echo get_class($e) . ": " . $e->getMessage()."\n";
  44. }
  45. try {
  46. FFI::cdef("struct DIR; static void foo(struct DIR);");
  47. echo "ok\n";
  48. } catch (Throwable $e) {
  49. echo get_class($e) . ": " . $e->getMessage()."\n";
  50. }
  51. try {
  52. FFI::cdef("struct DIR; static void foo(struct DIR*);");
  53. echo "ok\n";
  54. } catch (Throwable $e) {
  55. echo get_class($e) . ": " . $e->getMessage()."\n";
  56. }
  57. ?>
  58. ok
  59. --EXPECT--
  60. FFI\ParserException: Incomplete struct "DIR" at line 1
  61. ok
  62. FFI\ParserException: Incomplete struct "DIR" at line 1
  63. ok
  64. ok
  65. ok
  66. ok
  67. ok
  68. ok