msgpack/php/tests/023.phpt

46 lines
801 B
Plaintext
Raw Normal View History

2010-07-17 18:46:28 +09:00
--TEST--
Resource
--SKIPIF--
--FILE--
<?php
if(!extension_loaded('msgpack')) {
dl('msgpack.' . PHP_SHLIB_SUFFIX);
}
error_reporting(0);
function test($type, $variable, $test) {
$serialized = msgpack_serialize($variable);
$unserialized = msgpack_unserialize($serialized);
echo $type, PHP_EOL;
echo bin2hex($serialized), PHP_EOL;
var_dump($unserialized);
echo $test || $unserialized === null ? 'OK' : 'FAIL', PHP_EOL;
}
if (function_exists('curl_init')) {
$test = 'curl';
2010-12-27 11:09:14 +09:00
$res = curl_init('http://php.net/');
} else {
$test = 'dir';
$res = opendir('/tmp');
2010-07-17 18:46:28 +09:00
}
test('resource', $res, false);
switch ($test) {
case 'curl':
curl_close($res);
break;
2010-12-27 11:09:14 +09:00
default:
closedir($res);
2010-07-17 18:46:28 +09:00
break;
}
?>
--EXPECT--
resource
c0
NULL
OK