You've already forked qlg.tsgz.moe
Init Repo
This commit is contained in:
85
vendor/swoole/tests/swoole_serialize/009.phpt
vendored
Executable file
85
vendor/swoole/tests/swoole_serialize/009.phpt
vendored
Executable file
@ -0,0 +1,85 @@
|
||||
--TEST--
|
||||
swoole_serialize: Check for reference serialization
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require __DIR__ . '/../include/skipif.inc';
|
||||
if (!class_exists("swoole_serialize", false))
|
||||
{
|
||||
echo "skip";
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once __DIR__ . '/../include/bootstrap.php';
|
||||
|
||||
ini_set("display_errors", "Off");
|
||||
|
||||
function test($type, $variable, $test) {
|
||||
// $serialized = serialize($variable);
|
||||
// $unserialized = unserialize($serialized);
|
||||
|
||||
$serialized = swoole_serialize::pack($variable);
|
||||
$unserialized = swoole_serialize::unpack($serialized);
|
||||
echo $type, PHP_EOL;
|
||||
var_dump($unserialized);
|
||||
echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
|
||||
}
|
||||
|
||||
$a = array('foo');
|
||||
|
||||
test('array($a, $a)', array($a, $a), false);
|
||||
test('array(&$a, &$a)', array(&$a, &$a), false);
|
||||
|
||||
$a = [];
|
||||
$b = array(&$a);
|
||||
$a[0] = &$b;
|
||||
|
||||
test('cyclic', $a, true);
|
||||
?>
|
||||
--EXPECT--
|
||||
array($a, $a)
|
||||
array(2) {
|
||||
[0]=>
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(3) "foo"
|
||||
}
|
||||
[1]=>
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(3) "foo"
|
||||
}
|
||||
}
|
||||
OK
|
||||
array(&$a, &$a)
|
||||
array(2) {
|
||||
[0]=>
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(3) "foo"
|
||||
}
|
||||
[1]=>
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(3) "foo"
|
||||
}
|
||||
}
|
||||
OK
|
||||
cyclic
|
||||
array(1) {
|
||||
[0]=>
|
||||
array(1) {
|
||||
[0]=>
|
||||
array(1) {
|
||||
[0]=>
|
||||
array(1) {
|
||||
[0]=>
|
||||
array(1) {
|
||||
[0]=>
|
||||
NULL
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
OK
|
Reference in New Issue
Block a user