php-src/ext/ffi/tests/003.phpt
Max Semenik bd9f4fa676 Migrate skip checks to --EXTENSIONS--, p2
For rationale, see https://github.com/php/php-src/pull/6787

Make extension checks lowercase, add a special case for opcache
that has internal name not matching .so filename.

Extensions migrated in part 2:
* dom
* exif
* fileinfo
* ffi
2021-04-01 12:08:24 +01:00

64 lines
1.0 KiB
PHP

--TEST--
FFI 003: Forward tag/typedef declarations
--EXTENSIONS--
ffi
--INI--
ffi.enable=1
--FILE--
<?php
$ffi = FFI::cdef(<<<EOF
struct _a;
struct _a {int x;};
struct _b {int x;};
struct _b;
typedef struct _c c;
struct _c {int x;};
struct _d {int x;};
typedef struct _d d;
struct _e;
struct _f;
typedef struct _f f;
EOF
);
var_dump($ffi->new("struct _a"));
var_dump($ffi->new("struct _b"));
var_dump($ffi->new("c"));
var_dump($ffi->new("d"));
try {
var_dump($ffi->new("struct _e"));
} catch (Throwable $e) {
echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
var_dump($ffi->new("f"));
} catch (Throwable $e) {
echo get_class($e) . ": " . $e->getMessage()."\n";
}
echo "ok\n";
?>
--EXPECTF--
object(FFI\CData:struct _a)#%d (1) {
["x"]=>
int(0)
}
object(FFI\CData:struct _b)#%d (1) {
["x"]=>
int(0)
}
object(FFI\CData:struct _c)#%d (1) {
["x"]=>
int(0)
}
object(FFI\CData:struct _d)#%d (1) {
["x"]=>
int(0)
}
FFI\ParserException: Incomplete struct "_e" at line 1
FFI\ParserException: Incomplete struct "_f" at line 1
ok