summaryrefslogtreecommitdiff
path: root/php/tests
diff options
context:
space:
mode:
authoradvect <advect@gmail.com>2010-09-29 08:47:06 +0900
committeradvect <advect@gmail.com>2010-09-29 08:47:06 +0900
commit2a0a84763479e6eebd30f685e5f64afd7e7cb3bc (patch)
treeec04dceb4c7b378dcabdcab8ad15b9754ae06599 /php/tests
parent2ccb09434fcd313fdd48b7edbebec9d18408cf9d (diff)
downloadmsgpack-python-2a0a84763479e6eebd30f685e5f64afd7e7cb3bc.tar.gz
php: update 0.3.0
Diffstat (limited to 'php/tests')
-rw-r--r--php/tests/009.phpt18
-rw-r--r--php/tests/009b.phpt101
-rw-r--r--php/tests/014.phpt2
-rw-r--r--php/tests/015.phpt2
-rw-r--r--php/tests/015b.phpt2
-rw-r--r--php/tests/018.phpt2
-rw-r--r--php/tests/024.phpt6
-rw-r--r--php/tests/024b.phpt165
-rw-r--r--php/tests/026.phpt6
-rw-r--r--php/tests/026b.phpt107
-rw-r--r--php/tests/027.phpt2
-rw-r--r--php/tests/028.phpt6
-rw-r--r--php/tests/028b.phpt167
-rw-r--r--php/tests/029.phpt37
-rw-r--r--php/tests/030.phpt3
-rw-r--r--php/tests/060.phpt18
-rw-r--r--php/tests/060b.phpt313
-rw-r--r--php/tests/061.phpt8
-rw-r--r--php/tests/061b.phpt318
-rw-r--r--php/tests/070.phpt8
-rw-r--r--php/tests/070b.phpt297
-rw-r--r--php/tests/071.phpt8
-rw-r--r--php/tests/071b.phpt299
-rw-r--r--php/tests/072.phpt8
-rw-r--r--php/tests/072b.phpt339
-rw-r--r--php/tests/073.phpt346
-rw-r--r--php/tests/073b.phpt340
-rw-r--r--php/tests/080.phpt301
-rw-r--r--php/tests/081.phpt303
-rw-r--r--php/tests/082.phpt346
-rw-r--r--php/tests/083.phpt347
-rw-r--r--php/tests/084.phpt301
-rw-r--r--php/tests/085.phpt344
-rw-r--r--php/tests/086.phpt345
-rw-r--r--php/tests/087.phpt302
-rw-r--r--php/tests/088.phpt345
-rw-r--r--php/tests/089.phpt347
37 files changed, 6171 insertions, 38 deletions
diff --git a/php/tests/009.phpt b/php/tests/009.phpt
index 6baad5e..9992988 100644
--- a/php/tests/009.phpt
+++ b/php/tests/009.phpt
@@ -1,6 +1,10 @@
--TEST--
-Check for reference serialisation
+Check for reference serialization
--SKIPIF--
+<?php
+if (version_compare(PHP_VERSION, '5.3.3') >= 0) {
+ echo "skip tests in PHP 5.3.2 and lower";
+}
--FILE--
<?php
if(!extension_loaded('msgpack')) {
@@ -48,7 +52,7 @@ array(2) {
}
OK
array(&$a, &$a)
-82008100a3666f6f0182c001c002
+820082c00100a3666f6f0182c0020002
array(2) {
[0]=>
&array(1) {
@@ -63,16 +67,16 @@ array(2) {
}
OK
cyclic
-81008100810082c001c002
+810082c0010082c0010082c0020002
array(1) {
[0]=>
&array(1) {
[0]=>
- array(1) {
+ &array(1) {
[0]=>
&array(1) {
[0]=>
- array(1) {
+ &array(1) {
[0]=>
*RECURSION*
}
@@ -101,11 +105,11 @@ array(1) {
[0]=>
&array(1) {
[0]=>
- array(1) {
+ &array(1) {
[0]=>
&array(1) {
[0]=>
- array(1) {
+ &array(1) {
[0]=>
*RECURSION*
}
diff --git a/php/tests/009b.phpt b/php/tests/009b.phpt
new file mode 100644
index 0000000..7765d62
--- /dev/null
+++ b/php/tests/009b.phpt
@@ -0,0 +1,101 @@
+--TEST--
+Check for reference serialization
+--SKIPIF--
+<?php
+if (version_compare(PHP_VERSION, '5.3.2') <= 0) {
+ echo "skip tests in PHP 5.3.3";
+}
+--FILE--
+<?php
+if(!extension_loaded('msgpack')) {
+ dl('msgpack.' . PHP_SHLIB_SUFFIX);
+}
+
+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 == $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 = array(null);
+$b = array(&$a);
+$a[0] = &$b;
+
+test('cyclic', $a, true);
+
+var_dump($a);
+var_dump(msgpack_unserialize(msgpack_serialize($a)));
+
+--EXPECT--
+array($a, $a)
+82008100a3666f6f018100a3666f6f
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+}
+OK
+array(&$a, &$a)
+820082c00100a3666f6f0182c0020002
+array(2) {
+ [0]=>
+ &array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+ [1]=>
+ &array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+}
+OK
+cyclic
+810082c0010082c0010082c0020002
+array(1) {
+ [0]=>
+ &array(1) {
+ [0]=>
+ &array(1) {
+ [0]=>
+ *RECURSION*
+ }
+ }
+}
+OK
+array(1) {
+ [0]=>
+ &array(1) {
+ [0]=>
+ &array(1) {
+ [0]=>
+ *RECURSION*
+ }
+ }
+}
+array(1) {
+ [0]=>
+ &array(1) {
+ [0]=>
+ &array(1) {
+ [0]=>
+ *RECURSION*
+ }
+ }
+}
diff --git a/php/tests/014.phpt b/php/tests/014.phpt
index c663579..b9c7c67 100644
--- a/php/tests/014.phpt
+++ b/php/tests/014.phpt
@@ -34,7 +34,7 @@ test('object', $a, false);
?>
--EXPECTF--
object
-820083c0a34f626aa16101a162020182c001c002
+820084c001c0a34f626aa16101a162020182c0020002
array(2) {
[0]=>
&object(Obj)#%d (2) {
diff --git a/php/tests/015.phpt b/php/tests/015.phpt
index 828800a..634a8b1 100644
--- a/php/tests/015.phpt
+++ b/php/tests/015.phpt
@@ -51,7 +51,7 @@ var_dump($_SESSION);
?>
--EXPECT--
2
-81a3666f6f02
+82c001a3666f6f02
array(1) {
["foo"]=>
int(2)
diff --git a/php/tests/015b.phpt b/php/tests/015b.phpt
index 829584b..7ced312 100644
--- a/php/tests/015b.phpt
+++ b/php/tests/015b.phpt
@@ -51,7 +51,7 @@ var_dump($_SESSION);
?>
--EXPECT--
2
-81a3666f6f02
+82c001a3666f6f02
array(1) {
["foo"]=>
int(2)
diff --git a/php/tests/018.phpt b/php/tests/018.phpt
index 84ccafa..f5ff4b7 100644
--- a/php/tests/018.phpt
+++ b/php/tests/018.phpt
@@ -74,7 +74,7 @@ object(Obj)#%d (3) {
}
OK
wrong
-82c0a34f706ac0
+82c0a34f706a
object(Opj)#%d (2) {
["a"]=>
NULL
diff --git a/php/tests/024.phpt b/php/tests/024.phpt
index 30fab75..9b185f7 100644
--- a/php/tests/024.phpt
+++ b/php/tests/024.phpt
@@ -1,6 +1,10 @@
--TEST--
Recursive objects
--SKIPIF--
+<?php
+if (version_compare(PHP_VERSION, '5.3.3') >= 0) {
+ echo "skip tests in PHP 5.3.2 and lower";
+}
--FILE--
<?php
if(!extension_loaded('msgpack')) {
@@ -151,7 +155,7 @@ object(Obj3)#%d (1) {
}
OK
objectselfrec
-83c0a44f626a34a7004f626a34006164a9004f626a34006f626a82c002c001
+83c0a44f626a34a7004f626a34006164a9004f626a34006f626a82c0020001
object(Obj4)#%d (2) {
[%r"?a"?:("Obj4":)?private"?%r]=>
int(100)
diff --git a/php/tests/024b.phpt b/php/tests/024b.phpt
new file mode 100644
index 0000000..7c691be
--- /dev/null
+++ b/php/tests/024b.phpt
@@ -0,0 +1,165 @@
+--TEST--
+Recursive objects
+--SKIPIF--
+<?php
+if (version_compare(PHP_VERSION, '5.3.2') <= 0) {
+ echo "skip tests in PHP 5.3.3";
+}
+--FILE--
+<?php
+if(!extension_loaded('msgpack')) {
+ dl('msgpack.' . PHP_SHLIB_SUFFIX);
+}
+
+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 == $variable ? 'OK' : 'ERROR', PHP_EOL;
+}
+
+class Obj {
+ public $a;
+ protected $b;
+ private $c;
+
+ function __construct($a, $b, $c) {
+ $this->a = $a;
+ $this->b = $b;
+ $this->c = $c;
+ }
+}
+
+class Obj2 {
+ public $aa;
+ protected $bb;
+ private $cc;
+ private $obj;
+
+ function __construct($a, $b, $c) {
+ $this->a = $a;
+ $this->b = $b;
+ $this->c = $c;
+
+ $this->obj = new Obj($a, $b, $c);
+ }
+}
+
+class Obj3 {
+ private $objs;
+
+ function __construct($a, $b, $c) {
+ $this->objs = array();
+
+ for ($i = $a; $i < $c; $i += $b) {
+ $this->objs[] = new Obj($a, $i, $c);
+ }
+ }
+}
+
+class Obj4 {
+ private $a;
+ private $obj;
+
+ function __construct($a) {
+ $this->a = $a;
+ }
+
+ public function set($obj) {
+ $this->obj = $obj;
+ }
+}
+
+$o2 = new Obj2(1, 2, 3);
+test('objectrec', $o2, false);
+
+$o3 = new Obj3(0, 1, 4);
+test('objectrecarr', $o3, false);
+
+$o4 = new Obj4(100);
+$o4->set($o4);
+test('objectselfrec', $o4, true);
+?>
+--EXPECTF--
+objectrec
+88c0a44f626a32a26161c0a5002a006262c0a8004f626a32006363c0a9004f626a32006f626a84c0a34f626aa16101a4002a006202a6004f626a006303a16101a16202a16303
+object(Obj2)#%d (7) {
+ ["aa"]=>
+ NULL
+ [%r"?bb"?:protected"?%r]=>
+ NULL
+ [%r"?cc"?:("Obj2":)?private"?%r]=>
+ NULL
+ [%r"?obj"?:("Obj2":)?private"?%r]=>
+ object(Obj)#%d (3) {
+ ["a"]=>
+ int(1)
+ [%r"?b"?:protected"?%r]=>
+ int(2)
+ [%r"?c"?:("Obj":)?private"?%r]=>
+ int(3)
+ }
+ ["a"]=>
+ int(1)
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+}
+OK
+objectrecarr
+82c0a44f626a33aa004f626a33006f626a73840084c0a34f626aa16100a4002a006200a6004f626a0063040184c0a34f626aa16100a4002a006201a6004f626a0063040284c0a34f626aa16100a4002a006202a6004f626a0063040384c0a34f626aa16100a4002a006203a6004f626a006304
+object(Obj3)#%d (1) {
+ [%r"?objs"?:("Obj3":)?private"?%r]=>
+ array(4) {
+ [0]=>
+ object(Obj)#%d (3) {
+ ["a"]=>
+ int(0)
+ [%r"?b"?:protected"?%r]=>
+ int(0)
+ [%r"?c"?:("Obj":)?private"?%r]=>
+ int(4)
+ }
+ [1]=>
+ object(Obj)#%d (3) {
+ ["a"]=>
+ int(0)
+ [%r"?b"?:protected"?%r]=>
+ int(1)
+ [%r"?c"?:("Obj":)?private"?%r]=>
+ int(4)
+ }
+ [2]=>
+ object(Obj)#%d (3) {
+ ["a"]=>
+ int(0)
+ [%r"?b"?:protected"?%r]=>
+ int(2)
+ [%r"?c"?:("Obj":)?private"?%r]=>
+ int(4)
+ }
+ [3]=>
+ object(Obj)#%d (3) {
+ ["a"]=>
+ int(0)
+ [%r"?b"?:protected"?%r]=>
+ int(3)
+ [%r"?c"?:("Obj":)?private"?%r]=>
+ int(4)
+ }
+ }
+}
+OK
+objectselfrec
+83c0a44f626a34a7004f626a34006164a9004f626a34006f626a82c0020001
+object(Obj4)#%d (2) {
+ [%r"?a"?:("Obj4":)?private"?%r]=>
+ int(100)
+ [%r"?obj"?:("Obj4":)?private"?%r]=>
+ *RECURSION*
+}
+OK
diff --git a/php/tests/026.phpt b/php/tests/026.phpt
index 2d3bb73..c243ef5 100644
--- a/php/tests/026.phpt
+++ b/php/tests/026.phpt
@@ -2,6 +2,10 @@
Cyclic array test
--INI--
--SKIPIF--
+<?php
+if (version_compare(PHP_VERSION, '5.3.3') >= 0) {
+ echo "skip tests in PHP 5.3.2 and lower";
+}
--FILE--
<?php
if(!extension_loaded('msgpack')) {
@@ -39,7 +43,7 @@ var_dump($k);
?>
--EXPECT--
array
-82a16182a162a163a164a165a16682a16182a162a163a164a165a16682c001c005
+82a16182a162a163a164a165a16683c001a16182a162a163a164a165a16682c0020005
array(2) {
["a"]=>
array(2) {
diff --git a/php/tests/026b.phpt b/php/tests/026b.phpt
new file mode 100644
index 0000000..f7a3381
--- /dev/null
+++ b/php/tests/026b.phpt
@@ -0,0 +1,107 @@
+--TEST--
+Cyclic array test
+--INI--
+--SKIPIF--
+<?php
+if (version_compare(PHP_VERSION, '5.3.2') <= 0) {
+ echo "skip tests in PHP 5.3.3";
+}
+--FILE--
+<?php
+if(!extension_loaded('msgpack')) {
+ dl('msgpack.' . PHP_SHLIB_SUFFIX);
+}
+
+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 == $variable ? 'OK' : 'ERROR', PHP_EOL;
+}
+
+$a = array(
+ 'a' => array(
+ 'b' => 'c',
+ 'd' => 'e'
+ ),
+);
+
+$a['f'] = &$a;
+
+test('array', $a, true);
+
+$a = array("foo" => &$b);
+$b = array(1, 2, $a);
+var_dump($a);
+var_dump($k = msgpack_unserialize(msgpack_serialize($a)));
+
+$k["foo"][1] = "b";
+var_dump($k);
+?>
+--EXPECT--
+array
+82a16182a162a163a164a165a16683c001a16182a162a163a164a165a16682c0020005
+array(2) {
+ ["a"]=>
+ array(2) {
+ ["b"]=>
+ string(1) "c"
+ ["d"]=>
+ string(1) "e"
+ }
+ ["f"]=>
+ &array(2) {
+ ["a"]=>
+ array(2) {
+ ["b"]=>
+ string(1) "c"
+ ["d"]=>
+ string(1) "e"
+ }
+ ["f"]=>
+ *RECURSION*
+ }
+}
+OK
+array(1) {
+ ["foo"]=>
+ &array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ *RECURSION*
+ }
+}
+array(1) {
+ ["foo"]=>
+ &array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ array(1) {
+ ["foo"]=>
+ *RECURSION*
+ }
+ }
+}
+array(1) {
+ ["foo"]=>
+ &array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ string(1) "b"
+ [2]=>
+ array(1) {
+ ["foo"]=>
+ *RECURSION*
+ }
+ }
+}
diff --git a/php/tests/027.phpt b/php/tests/027.phpt
index ecb8784..c9c7cbd 100644
--- a/php/tests/027.phpt
+++ b/php/tests/027.phpt
@@ -64,7 +64,7 @@ var_dump($_SESSION);
--EXPECT--
bool(true)
read
-wrote: 82a3666f6f01a474657374a6666f6f626172
+wrote: 83c001a3666f6f01a474657374a6666f6f626172
array(2) {
["foo"]=>
int(1)
diff --git a/php/tests/028.phpt b/php/tests/028.phpt
index 56805f9..00db675 100644
--- a/php/tests/028.phpt
+++ b/php/tests/028.phpt
@@ -1,6 +1,10 @@
--TEST--
Serialize object into session, full set
--SKIPIF--
+<?php
+if (version_compare(PHP_VERSION, '5.3.3') >= 0) {
+ echo "skip tests in PHP 5.3.2 and lower";
+}
--FILE--
<?php
if(!extension_loaded('msgpack')) {
@@ -96,7 +100,7 @@ var_dump($_SESSION);
?>
--EXPECTF--
read
-write: 83a36f6c6484c0a3466f6fa700466f6f00643184c0a3426172a2643182c002c002a70042617200643282c002c002a5002a00643382c002c002a5002a00643282c002c003a2643382c002c003a474657374a6666f6f626172a36e657784c0a3426172a2643184c0a3466f6fa700466f6f00643182c002c00aa5002a00643282c002c00aa2643382c002c00aa70042617200643282c002c00ba5002a00643382c002c00b
+write: 84c001a36f6c6484c0a3466f6fa700466f6f00643184c0a3426172a2643182c0020002a70042617200643282c0020002a5002a00643382c0020002a5002a00643282c0020003a2643382c0020003a474657374a6666f6f626172a36e657784c0a3426172a2643184c0a3466f6fa700466f6f00643182c002000aa5002a00643282c002000aa2643382c002000aa70042617200643282c002000ba5002a00643382c002000b
array(3) {
["old"]=>
object(Foo)#3 (3) {
diff --git a/php/tests/028b.phpt b/php/tests/028b.phpt
new file mode 100644
index 0000000..7331a57
--- /dev/null
+++ b/php/tests/028b.phpt
@@ -0,0 +1,167 @@
+--TEST--
+Serialize object into session, full set
+--SKIPIF--
+<?php
+if (version_compare(PHP_VERSION, '5.3.2') <= 0) {
+ echo "skip tests in PHP 5.3.3";
+}
+--FILE--
+<?php
+if(!extension_loaded('msgpack')) {
+ dl('msgpack.' . PHP_SHLIB_SUFFIX);
+}
+
+class Foo {
+ private static $s1 = array();
+ protected static $s2 = array();
+ public static $s3 = array();
+
+ private $d1;
+ protected $d2;
+ public $d3;
+
+ public function __construct($foo) {
+ $this->d1 = $foo;
+ $this->d2 = $foo;
+ $this->d3 = $foo;
+ }
+}
+
+class Bar {
+ private static $s1 = array();
+ protected static $s2 = array();
+ public static $s3 = array();
+
+ public $d1;
+ private $d2;
+ protected $d3;
+
+ public function __construct() {
+ }
+
+ public function set($foo) {
+ $this->d1 = $foo;
+ $this->d2 = $foo;
+ $this->d3 = $foo;
+ }
+}
+
+$output = '';
+
+function open($path, $name) {
+ return true;
+}
+
+function close() {
+ return true;
+}
+
+function read($id) {
+ global $output;
+ $output .= "read" . PHP_EOL;
+ $a = new Bar();
+ $b = new Foo($a);
+ $a->set($b);
+ $session = array('old' => $b);
+ return msgpack_serialize($session);
+}
+
+function write($id, $data) {
+ global $output;
+ $output .= "write: ";
+ $output .= bin2hex($data) . PHP_EOL;
+ return true;
+}
+
+function destroy($id) {
+ return true;
+}
+
+function gc($time) {
+ return true;
+}
+
+ini_set('session.serialize_handler', 'msgpack');
+
+session_set_save_handler('open', 'close', 'read', 'write', 'destroy', 'gc');
+
+session_start();
+
+$_SESSION['test'] = "foobar";
+$a = new Bar();
+$b = new Foo($a);
+$a->set($b);
+$_SESSION['new'] = $a;
+
+session_write_close();
+
+echo $output;
+var_dump($_SESSION);
+?>
+--EXPECTF--
+read
+write: 84c001a36f6c6484c0a3466f6fa700466f6f00643184c0a3426172a2643182c0020002a70042617200643282c0020002a5002a00643382c0020002a5002a00643282c0020003a2643382c0020003a474657374a6666f6f626172a36e657784c0a3426172a2643184c0a3466f6fa700466f6f00643182c002000aa5002a00643282c002000aa2643382c002000aa70042617200643282c002000ba5002a00643382c002000b
+array(3) {
+ ["old"]=>
+ object(Foo)#3 (3) {
+ [%r"?d1"?:("Foo":)?private"?%r]=>
+ object(Bar)#4 (3) {
+ ["d1"]=>
+ *RECURSION*
+ [%r"?d2"?:("Bar":)?private"?%r]=>
+ *RECURSION*
+ [%r"?d3"?:protected"?%r]=>
+ *RECURSION*
+ }
+ [%r"?d2"?:protected"?%r]=>
+ object(Bar)#4 (3) {
+ ["d1"]=>
+ *RECURSION*
+ [%r"?d2"?:("Bar":)?private"?%r]=>
+ *RECURSION*
+ [%r"?d3"?:protected"?%r]=>
+ *RECURSION*
+ }
+ ["d3"]=>
+ object(Bar)#4 (3) {
+ ["d1"]=>
+ *RECURSION*
+ [%r"?d2"?:("Bar":)?private"?%r]=>
+ *RECURSION*
+ [%r"?d3"?:protected"?%r]=>
+ *RECURSION*
+ }
+ }
+ ["test"]=>
+ string(6) "foobar"
+ ["new"]=>
+ object(Bar)#5 (3) {
+ ["d1"]=>
+ object(Foo)#6 (3) {
+ [%r"?d1"?:("Foo":)?private"?%r]=>
+ *RECURSION*
+ [%r"?d2"?:protected"?%r]=>
+ *RECURSION*
+ ["d3"]=>
+ *RECURSION*
+ }
+ [%r"?d2"?:("Bar":)?private"?%r]=>
+ object(Foo)#6 (3) {
+ [%r"?d1"?:("Foo":)?private"?%r]=>
+ *RECURSION*
+ [%r"?d2"?:protected"?%r]=>
+ *RECURSION*
+ ["d3"]=>
+ *RECURSION*
+ }
+ [%r"?d3"?:protected"?%r]=>
+ object(Foo)#6 (3) {
+ [%r"?d1"?:("Foo":)?private"?%r]=>
+ *RECURSION*
+ [%r"?d2"?:protected"?%r]=>
+ *RECURSION*
+ ["d3"]=>
+ *RECURSION*
+ }
+ }
+}
diff --git a/php/tests/029.phpt b/php/tests/029.phpt
index 3bd1e9d..686abb9 100644
--- a/php/tests/029.phpt
+++ b/php/tests/029.phpt
@@ -9,12 +9,39 @@ phpinfo(INFO_MODULES);
$str = ob_get_clean();
$array = explode("\n", $str);
-$array = preg_grep('/^msgpack/', $array);
-echo implode("\n", $array), PHP_EOL;
+$section = false;
+$blank = 0;
+foreach ($array as $key => $val)
+{
+ if (strcmp($val, 'msgpack') == 0 || $section)
+ {
+ $section = true;
+ }
+ else
+ {
+ continue;
+ }
+ if (empty($val))
+ {
+ $blank++;
+ if ($blank == 3)
+ {
+ $section = false;
+ }
+ }
+
+ echo $val, PHP_EOL;
+}
--EXPECTF--
msgpack
-msgpack support => enabled
-msgpack version => %s
-msgpack Session Support => enabled
+
+MessagePack Support => enabled
+Session Support => enabled
+extension Version => %s
+header Version => %s
+
+Directive => Local Value => Master Value
+msgpack.error_display => On => On
+msgpack.php_only => On => On
diff --git a/php/tests/030.phpt b/php/tests/030.phpt
index ec8622d..3b8d986 100644
--- a/php/tests/030.phpt
+++ b/php/tests/030.phpt
@@ -56,9 +56,6 @@ foreach ($datas as $data) {
}
?>
--EXPECTF--
-output at 2:
-array(0) {
-}
output at 3:
array(1) {
[0]=>
diff --git a/php/tests/060.phpt b/php/tests/060.phpt
index c0fda4c..649d788 100644
--- a/php/tests/060.phpt
+++ b/php/tests/060.phpt
@@ -1,6 +1,10 @@
--TEST--
Check for buffered streaming unserialization
--SKIPIF--
+<?php
+if (version_compare(PHP_VERSION, '5.3.3') >= 0) {
+ echo "skip tests in PHP 5.3.2 and lower";
+}
--FILE--
<?php
if(!extension_loaded('msgpack')) {
@@ -41,8 +45,8 @@ function test($type, $variable, $test = null) {
test('null', null);
-test('boo:l true', true);
-test('bool: true', false);
+test('bool: true', true);
+test('bool: false', false);
test('zero: 0', 0);
test('small: 1', 1);
@@ -57,9 +61,9 @@ test('double: 123.456', 123.456);
test('empty: ""', "");
test('string: "foobar"', "foobar");
-test('empty: array', array(), false);
-test('empty: array(1, 2, 3)', array(1, 2, 3), false);
-test('empty: array(array(1, 2, 3), arr...', array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9)), false);
+test('array', array(), false);
+test('array(1, 2, 3)', array(1, 2, 3), false);
+test('array(array(1, 2, 3), arr...', array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9)), false);
test('array("foo", "foo", "foo")', array("foo", "foo", "foo"), false);
test('array("one" => 1, "two" => 2))', array("one" => 1, "two" => 2), false);
@@ -234,11 +238,11 @@ array(1) {
[0]=>
&array(1) {
[0]=>
- array(1) {
+ &array(1) {
[0]=>
&array(1) {
[0]=>
- array(1) {
+ &array(1) {
[0]=>
*RECURSION*
}
diff --git a/php/tests/060b.phpt b/php/tests/060b.phpt
new file mode 100644
index 0000000..0b947c8
--- /dev/null
+++ b/php/tests/060b.phpt
@@ -0,0 +1,313 @@
+--TEST--
+Check for buffered streaming unserialization
+--SKIPIF--
+<?php
+if (version_compare(PHP_VERSION, '5.3.2') <= 0) {
+ echo "skip tests in PHP 5.3.3";
+}
+--FILE--
+<?php
+if(!extension_loaded('msgpack')) {
+ dl('msgpack.' . PHP_SHLIB_SUFFIX);
+}
+
+function test($type, $variable, $test = null) {
+ $serialized = msgpack_serialize($variable);
+
+ $unpacker = new MessagePackUnpacker();
+
+ $length = strlen($serialized);
+
+ for ($i = 0; $i < $length;) {
+ $len = rand(1, 10);
+ $str = substr($serialized, $i, $len);
+
+ $unpacker->feed($str);
+ if ($unpacker->execute())
+ {
+ $unserialized = $unpacker->data();
+ var_dump($unserialized);
+ $unpacker->reset();
+ }
+
+ $i += $len;
+ }
+
+ if (!is_bool($test))
+ {
+ echo $unserialized === $variable ? 'OK' : 'ERROR', PHP_EOL;
+ }
+ else
+ {
+ echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
+ }
+}
+
+test('null', null);
+
+test('bool: true', true);
+test('bool: false', false);
+
+test('zero: 0', 0);
+test('small: 1', 1);
+test('small: -1', -1);
+test('medium: 1000', 1000);
+test('medium: -1000', -1000);
+test('large: 100000', 100000);
+test('large: -100000', -100000);
+
+test('double: 123.456', 123.456);
+
+test('empty: ""', "");
+test('string: "foobar"', "foobar");
+
+test('array', array(), false);
+test('array(1, 2, 3)', array(1, 2, 3), false);
+test('array(array(1, 2, 3), arr...', array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9)), false);
+
+test('array("foo", "foo", "foo")', array("foo", "foo", "foo"), false);
+test('array("one" => 1, "two" => 2))', array("one" => 1, "two" => 2), false);
+test('array("kek" => "lol", "lol" => "kek")', array("kek" => "lol", "lol" => "kek"), false);
+test('array("" => "empty")', array("" => "empty"), false);
+
+$a = array('foo');
+test('array($a, $a)', array($a, $a), false);
+test('array(&$a, &$a)', array(&$a, &$a), false);
+
+$a = array(null);
+$b = array(&$a);
+$a[0] = &$b;
+
+test('cyclic', $a, true);
+
+$a = array(
+ 'a' => array(
+ 'b' => 'c',
+ 'd' => 'e'
+ ),
+ 'f' => array(
+ 'g' => 'h'
+ )
+ );
+
+test('array', $a, false);
+
+class Obj {
+ public $a;
+ protected $b;
+ private $c;
+
+ function __construct($a, $b, $c) {
+ $this->a = $a;
+ $this->b = $b;
+ $this->c = $c;
+ }
+}
+
+test('object', new Obj(1, 2, 3), false);
+
+test('object', array(new Obj(1, 2, 3), new Obj(4, 5, 6)), false);
+
+$o = new Obj(1, 2, 3);
+
+test('object', array(&$o, &$o), false);
+--EXPECTF--
+NULL
+OK
+bool(true)
+OK
+bool(false)
+OK
+int(0)
+OK
+int(1)
+OK
+int(-1)
+OK
+int(1000)
+OK
+int(-1000)
+OK
+int(100000)
+OK
+int(-100000)
+OK
+float(123.456)
+OK
+string(0) ""
+OK
+string(6) "foobar"
+OK
+array(0) {
+}
+OK
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
+OK
+array(3) {
+ [0]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+ [1]=>
+ array(3) {
+ [0]=>
+ int(4)
+ [1]=>
+ int(5)
+ [2]=>
+ int(6)
+ }
+ [2]=>
+ array(3) {
+ [0]=>
+ int(7)
+ [1]=>
+ int(8)
+ [2]=>
+ int(9)
+ }
+}
+OK
+array(3) {
+ [0]=>
+ string(3) "foo"
+ [1]=>
+ string(3) "foo"
+ [2]=>
+ string(3) "foo"
+}
+OK
+array(2) {
+ ["one"]=>
+ int(1)
+ ["two"]=>
+ int(2)
+}
+OK
+array(2) {
+ ["kek"]=>
+ string(3) "lol"
+ ["lol"]=>
+ string(3) "kek"
+}
+OK
+array(1) {
+ [""]=>
+ string(5) "empty"
+}
+OK
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+}
+OK
+array(2) {
+ [0]=>
+ &array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+ [1]=>
+ &array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+}
+OK
+array(1) {
+ [0]=>
+ &array(1) {
+ [0]=>
+ &array(1) {
+ [0]=>
+ *RECURSION*
+ }
+ }
+}
+OK
+array(2) {
+ ["a"]=>
+ array(2) {
+ ["b"]=>
+ string(1) "c"
+ ["d"]=>
+ string(1) "e"
+ }
+ ["f"]=>
+ array(1) {
+ ["g"]=>
+ string(1) "h"
+ }
+}
+OK
+object(Obj)#%d (3) {
+ ["a"]=>
+ int(1)
+ [%r"?b"?:protected"?%r]=>
+ int(2)
+ [%r"?c"?:("Obj":)?private"?%r]=>
+ int(3)
+}
+OK
+array(2) {
+ [0]=>
+ object(Obj)#%d (3) {
+ ["a"]=>
+ int(1)
+ [%r"?b"?:protected"?%r]=>
+ int(2)
+ [%r"?c"?:("Obj":)?private"?%r]=>
+ int(3)
+ }
+ [1]=>
+ object(Obj)#%d (3) {
+ ["a"]=>
+ int(4)
+ [%r"?b"?:protected"?%r]=>
+ int(5)
+ [%r"?c"?:("Obj":)?private"?%r]=>
+ int(6)
+ }
+}
+OK
+array(2) {
+ [0]=>
+ &object(Obj)#%d (3) {
+ ["a"]=>
+ int(1)
+ [%r"?b"?:protected"?%r]=>
+ int(2)
+ [%r"?c"?:("Obj":)?private"?%r]=>
+ int(3)
+ }
+ [1]=>
+ &object(Obj)#%d (3) {
+ ["a"]=>
+ int(1)
+ [%r"?b"?:protected"?%r]=>
+ int(2)
+ [%r"?c"?:("Obj":)?private"?%r]=>
+ int(3)
+ }
+}
+OK
diff --git a/php/tests/061.phpt b/php/tests/061.phpt
index ded494e..7ecc0c9 100644
--- a/php/tests/061.phpt
+++ b/php/tests/061.phpt
@@ -1,6 +1,10 @@
--TEST--
Check for unbuffered streaming unserialization
--SKIPIF--
+<?php
+if (version_compare(PHP_VERSION, '5.3.3') >= 0) {
+ echo "skip tests in PHP 5.3.2 and lower";
+}
--FILE--
<?php
if(!extension_loaded('msgpack')) {
@@ -239,11 +243,11 @@ array(1) {
[0]=>
&array(1) {
[0]=>
- array(1) {
+ &array(1) {
[0]=>
&array(1) {
[0]=>
- array(1) {
+ &array(1) {
[0]=>
*RECURSION*
}
diff --git a/php/tests/061b.phpt b/php/tests/061b.phpt
new file mode 100644
index 0000000..efb3a9b
--- /dev/null
+++ b/php/tests/061b.phpt
@@ -0,0 +1,318 @@
+--TEST--
+Check for unbuffered streaming unserialization
+--SKIPIF--
+<?php
+if (version_compare(PHP_VERSION, '5.3.2') <= 0) {
+ echo "skip tests in PHP 5.3.3";
+}
+--FILE--
+<?php
+if(!extension_loaded('msgpack')) {
+ dl('msgpack.' . PHP_SHLIB_SUFFIX);
+}
+
+function test($type, $variable, $test = null) {
+ $serialized = msgpack_serialize($variable);
+
+ $unpacker = new MessagePackUnpacker();
+
+ $length = strlen($serialized);
+
+ $str = "";
+ $offset = 0;
+
+ for ($i = 0; $i < $length;) {
+ $len = rand(1, 10);
+ $str .= substr($serialized, $i, $len);
+
+ if ($unpacker->execute($str, $offset))
+ {
+ $unserialized = $unpacker->data();
+ var_dump($unserialized);
+
+ $unpacker->reset();
+ $str = "";
+ $offset = 0;
+ }
+
+ $i += $len;
+ }
+
+ if (!is_bool($test))
+ {
+ echo $unserialized === $variable ? 'OK' : 'ERROR', PHP_EOL;
+ }
+ else
+ {
+ echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
+ }
+}
+
+test('null', null);
+
+test('boo:l true', true);
+test('bool: true', false);
+
+test('zero: 0', 0);
+test('small: 1', 1);
+test('small: -1', -1);
+test('medium: 1000', 1000);
+test('medium: -1000', -1000);
+test('large: 100000', 100000);
+test('large: -100000', -100000);
+
+test('double: 123.456', 123.456);
+
+test('empty: ""', "");
+test('string: "foobar"', "foobar");
+
+test('empty: array', array(), false);
+test('empty: array(1, 2, 3)', array(1, 2, 3), false);
+test('empty: array(array(1, 2, 3), arr...', array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9)), false);
+
+test('array("foo", "foo", "foo")', array("foo", "foo", "foo"), false);
+test('array("one" => 1, "two" => 2))', array("one" => 1, "two" => 2), false);
+test('array("kek" => "lol", "lol" => "kek")', array("kek" => "lol", "lol" => "kek"), false);
+test('array("" => "empty")', array("" => "empty"), false);
+
+$a = array('foo');
+test('array($a, $a)', array($a, $a), false);
+test('array(&$a, &$a)', array(&$a, &$a), false);
+
+$a = array(null);
+$b = array(&$a);
+$a[0] = &$b;
+
+test('cyclic', $a, true);
+
+$a = array(
+ 'a' => array(
+ 'b' => 'c',
+ 'd' => 'e'
+ ),
+ 'f' => array(
+ 'g' => 'h'
+ )
+ );
+
+test('array', $a, false);
+
+class Obj {
+ public $a;
+ protected $b;
+ private $c;
+
+ function __construct($a, $b, $c) {
+ $this->a = $a;
+ $this->b = $b;
+ $this->c = $c;
+ }
+}
+
+test('object', new Obj(1, 2, 3), false);
+
+test('object', array(new Obj(1, 2, 3), new Obj(4, 5, 6)), false);
+
+$o = new Obj(1, 2, 3);
+
+test('object', array(&$o, &$o), false);
+--EXPECTF--
+NULL
+OK
+bool(true)
+OK
+bool(false)
+OK
+int(0)
+OK
+int(1)
+OK
+int(-1)
+OK
+int(1000)
+OK
+int(-1000)
+OK
+int(100000)
+OK
+int(-100000)
+OK
+float(123.456)
+OK
+string(0) ""
+OK
+string(6) "foobar"
+OK
+array(0) {
+}
+OK
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
+OK
+array(3) {
+ [0]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+ [1]=>
+ array(3) {
+ [0]=>
+ int(4)
+ [1]=>
+ int(5)
+ [2]=>
+ int(6)
+ }
+ [2]=>
+ array(3) {
+ [0]=>
+ int(7)
+ [1]=>
+ int(8)
+ [2]=>
+ int(9)
+ }
+}
+OK
+array(3) {
+ [0]=>
+ string(3) "foo"
+ [1]=>
+ string(3) "foo"
+ [2]=>
+ string(3) "foo"
+}
+OK
+array(2) {
+ ["one"]=>
+ int(1)
+ ["two"]=>
+ int(2)
+}
+OK
+array(2) {
+ ["kek"]=>
+ string(3) "lol"
+ ["lol"]=>
+ string(3) "kek"
+}
+OK
+array(1) {
+ [""]=>
+ string(5) "empty"
+}
+OK
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+}
+OK
+array(2) {
+ [0]=>
+ &array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+ [1]=>
+ &array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+}
+OK
+array(1) {
+ [0]=>
+ &array(1) {
+ [0]=>
+ &array(1) {
+ [0]=>
+ *RECURSION*
+ }
+ }
+}
+OK
+array(2) {
+ ["a"]=>
+ array(2) {
+ ["b"]=>
+ string(1) "c"
+ ["d"]=>
+ string(1) "e"
+ }
+ ["f"]=>
+ array(1) {
+ ["g"]=>
+ string(1) "h"
+ }
+}
+OK
+object(Obj)#%d (3) {
+ ["a"]=>
+ int(1)
+ [%r"?b"?:protected"?%r]=>
+ int(2)
+ [%r"?c"?:("Obj":)?private"?%r]=>
+ int(3)
+}
+OK
+array(2) {
+ [0]=>
+ object(Obj)#%d (3) {
+ ["a"]=>
+ int(1)
+ [%r"?b"?:protected"?%r]=>
+ int(2)
+ [%r"?c"?:("Obj":)?private"?%r]=>
+ int(3)
+ }
+ [1]=>
+ object(Obj)#%d (3) {
+ ["a"]=>
+ int(4)
+ [%r"?b"?:protected"?%r]=>
+ int(5)
+ [%r"?c"?:("Obj":)?private"?%r]=>
+ int(6)
+ }
+}
+OK
+array(2) {
+ [0]=>
+ &object(Obj)#%d (3) {
+ ["a"]=>
+ int(1)
+ [%r"?b"?:protected"?%r]=>
+ int(2)
+ [%r"?c"?:("Obj":)?private"?%r]=>
+ int(3)
+ }
+ [1]=>
+ &object(Obj)#%d (3) {
+ ["a"]=>
+ int(1)
+ [%r"?b"?:protected"?%r]=>
+ int(2)
+ [%r"?c"?:("Obj":)?private"?%r]=>
+ int(3)
+ }
+}
+OK
diff --git a/php/tests/070.phpt b/php/tests/070.phpt
index 4a00ddf..893023b 100644
--- a/php/tests/070.phpt
+++ b/php/tests/070.phpt
@@ -1,6 +1,10 @@
--TEST--
Check for alias functions
--SKIPIF--
+<?php
+if (version_compare(PHP_VERSION, '5.3.3') >= 0) {
+ echo "skip tests in PHP 5.3.2 and lower";
+}
--FILE--
<?php
if(!extension_loaded('msgpack')) {
@@ -218,11 +222,11 @@ array(1) {
[0]=>
&array(1) {
[0]=>
- array(1) {
+ &array(1) {
[0]=>
&array(1) {
[0]=>
- array(1) {
+ &array(1) {
[0]=>
*RECURSION*
}
diff --git a/php/tests/070b.phpt b/php/tests/070b.phpt
new file mode 100644
index 0000000..109ddc1
--- /dev/null
+++ b/php/tests/070b.phpt
@@ -0,0 +1,297 @@
+--TEST--
+Check for alias functions
+--SKIPIF--
+<?php
+if (version_compare(PHP_VERSION, '5.3.2') <= 0) {
+ echo "skip tests in PHP 5.3.3";
+}
+--FILE--
+<?php
+if(!extension_loaded('msgpack')) {
+ dl('msgpack.' . PHP_SHLIB_SUFFIX);
+}
+
+function test($type, $variable, $test = null) {
+ $serialized = msgpack_pack($variable);
+ $unserialized = msgpack_unpack($serialized);
+
+ var_dump($unserialized);
+
+ if (!is_bool($test))
+ {
+ echo $unserialized === $variable ? 'OK' : 'ERROR', PHP_EOL;
+ }
+ else
+ {
+ echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
+ }
+}
+
+test('null', null);
+
+test('boo:l true', true);
+test('bool: true', false);
+
+test('zero: 0', 0);
+test('small: 1', 1);
+test('small: -1', -1);
+test('medium: 1000', 1000);
+test('medium: -1000', -1000);
+test('large: 100000', 100000);
+test('large: -100000', -100000);
+
+test('double: 123.456', 123.456);
+
+test('empty: ""', "");
+test('string: "foobar"', "foobar");
+
+test('empty: array', array(), false);
+test('empty: array(1, 2, 3)', array(1, 2, 3), false);
+test('empty: array(array(1, 2, 3), arr...', array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9)), false);
+
+test('array("foo", "foo", "foo")', array("foo", "foo", "foo"), false);
+test('array("one" => 1, "two" => 2))', array("one" => 1, "two" => 2), false);
+test('array("kek" => "lol", "lol" => "kek")', array("kek" => "lol", "lol" => "kek"), false);
+test('array("" => "empty")', array("" => "empty"), false);
+
+$a = array('foo');
+test('array($a, $a)', array($a, $a), false);
+test('array(&$a, &$a)', array(&$a, &$a), false);
+
+$a = array(null);
+$b = array(&$a);
+$a[0] = &$b;
+
+test('cyclic', $a, true);
+
+$a = array(
+ 'a' => array(
+ 'b' => 'c',
+ 'd' => 'e'
+ ),
+ 'f' => array(
+ 'g' => 'h'
+ )
+ );
+
+test('array', $a, false);
+
+class Obj {
+ public $a;
+ protected $b;
+ private $c;
+
+ function __construct($a, $b, $c) {
+ $this->a = $a;
+ $this->b = $b;
+ $this->c = $c;
+ }
+}
+
+test('object', new Obj(1, 2, 3), false);
+
+test('object', array(new Obj(1, 2, 3), new Obj(4, 5, 6)), false);
+
+$o = new Obj(1, 2, 3);
+
+test('object', array(&$o, &$o), false);
+--EXPECTF--
+NULL
+OK
+bool(true)
+OK
+bool(false)
+OK
+int(0)
+OK
+int(1)
+OK
+int(-1)
+OK
+int(1000)
+OK
+int(-1000)
+OK
+int(100000)
+OK
+int(-100000)
+OK
+float(123.456)
+OK
+string(0) ""
+OK
+string(6) "foobar"
+OK
+array(0) {
+}
+OK
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
+OK
+array(3) {
+ [0]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+ [1]=>
+ array(3) {
+ [0]=>
+ int(4)
+ [1]=>
+ int(5)
+ [2]=>
+ int(6)
+ }
+ [2]=>
+ array(3) {
+ [0]=>
+ int(7)
+ [1]=>
+ int(8)
+ [2]=>
+ int(9)
+ }
+}
+OK
+array(3) {
+ [0]=>
+ string(3) "foo"
+ [1]=>
+ string(3) "foo"
+ [2]=>
+ string(3) "foo"
+}
+OK
+array(2) {
+ ["one"]=>
+ int(1)
+ ["two"]=>
+ int(2)
+}
+OK
+array(2) {
+ ["kek"]=>
+ string(3) "lol"
+ ["lol"]=>
+ string(3) "kek"
+}
+OK
+array(1) {
+ [""]=>
+ string(5) "empty"
+}
+OK
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+}
+OK
+array(2) {
+ [0]=>
+ &array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+ [1]=>
+ &array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+}
+OK
+array(1) {
+ [0]=>
+ &array(1) {
+ [0]=>
+ &array(1) {
+ [0]=>
+ *RECURSION*
+ }
+ }
+}
+OK
+array(2) {
+ ["a"]=>
+ array(2) {
+ ["b"]=>
+ string(1) "c"
+ ["d"]=>
+ string(1) "e"
+ }
+ ["f"]=>
+ array(1) {
+ ["g"]=>
+ string(1) "h"
+ }
+}
+OK
+object(Obj)#%d (3) {
+ ["a"]=>
+ int(1)
+ [%r"?b"?:protected"?%r]=>
+ int(2)
+ [%r"?c"?:("Obj":)?private"?%r]=>
+ int(3)
+}
+OK
+array(2) {
+ [0]=>
+ object(Obj)#%d (3) {
+ ["a"]=>
+ int(1)
+ [%r"?b"?:protected"?%r]=>
+ int(2)
+ [%r"?c"?:("Obj":)?private"?%r]=>
+ int(3)
+ }
+ [1]=>
+ object(Obj)#%d (3) {
+ ["a"]=>
+ int(4)
+ [%r"?b"?:protected"?%r]=>
+ int(5)
+ [%r"?c"?:("Obj":)?private"?%r]=>
+ int(6)
+ }
+}
+OK
+array(2) {
+ [0]=>
+ &object(Obj)#%d (3) {
+ ["a"]=>
+ int(1)
+ [%r"?b"?:protected"?%r]=>
+ int(2)
+ [%r"?c"?:("Obj":)?private"?%r]=>
+ int(3)
+ }
+ [1]=>
+ &object(Obj)#%d (3) {
+ ["a"]=>
+ int(1)
+ [%r"?b"?:protected"?%r]=>
+ int(2)
+ [%r"?c"?:("Obj":)?private"?%r]=>
+ int(3)
+ }
+}
+OK
diff --git a/php/tests/071.phpt b/php/tests/071.phpt
index cca351a..431303b 100644
--- a/php/tests/071.phpt
+++ b/php/tests/071.phpt
@@ -1,6 +1,10 @@
--TEST--
Check for class methods
--SKIPIF--
+<?php
+if (version_compare(PHP_VERSION, '5.3.3') >= 0) {
+ echo "skip tests in PHP 5.3.2 and lower";
+}
--FILE--
<?php
if(!extension_loaded('msgpack')) {
@@ -220,11 +224,11 @@ array(1) {
[0]=>
&array(1) {
[0]=>
- array(1) {
+ &array(1) {
[0]=>
&array(1) {
[0]=>
- array(1) {
+ &array(1) {
[0]=>
*RECURSION*
}
diff --git a/php/tests/071b.phpt b/php/tests/071b.phpt
new file mode 100644
index 0000000..770d06e
--- /dev/null
+++ b/php/tests/071b.phpt
@@ -0,0 +1,299 @@
+--TEST--
+Check for class methods
+--SKIPIF--
+<?php
+if (version_compare(PHP_VERSION, '5.3.2') <= 0) {
+ echo "skip tests in PHP 5.3.3";
+}
+--FILE--
+<?php
+if(!extension_loaded('msgpack')) {
+ dl('msgpack.' . PHP_SHLIB_SUFFIX);
+}
+
+function test($type, $variable, $test = null) {
+ $msgpack = new MessagePack();
+
+ $serialized = $msgpack->pack($variable);
+ $unserialized = $msgpack->unpack($serialized);
+
+ var_dump($unserialized);
+
+ if (!is_bool($test))
+ {
+ echo $unserialized === $variable ? 'OK' : 'ERROR', PHP_EOL;
+ }
+ else
+ {
+ echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
+ }
+}
+
+test('null', null);
+
+test('boo:l true', true);
+test('bool: true', false);
+
+test('zero: 0', 0);
+test('small: 1', 1);
+test('small: -1', -1);
+test('medium: 1000', 1000);
+test('medium: -1000', -1000);
+test('large: 100000', 100000);
+test('large: -100000', -100000);
+
+test('double: 123.456', 123.456);
+
+test('empty: ""', "");
+test('string: "foobar"', "foobar");
+
+test('empty: array', array(), false);
+test('empty: array(1, 2, 3)', array(1, 2, 3), false);
+test('empty: array(array(1, 2, 3), arr...', array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9)), false);
+
+test('array("foo", "foo", "foo")', array("foo", "foo", "foo"), false);
+test('array("one" => 1, "two" => 2))', array("one" => 1, "two" => 2), false);
+test('array("kek" => "lol", "lol" => "kek")', array("kek" => "lol", "lol" => "kek"), false);
+test('array("" => "empty")', array("" => "empty"), false);
+
+$a = array('foo');
+test('array($a, $a)', array($a, $a), false);
+test('array(&$a, &$a)', array(&$a, &$a), false);
+
+$a = array(null);
+$b = array(&$a);
+$a[0] = &$b;
+
+test('cyclic', $a, true);
+
+$a = array(
+ 'a' => array(
+ 'b' => 'c',
+ 'd' => 'e'
+ ),
+ 'f' => array(
+ 'g' => 'h'
+ )
+ );
+
+test('array', $a, false);
+
+class Obj {
+ public $a;
+ protected $b;
+ private $c;
+
+ function __construct($a, $b, $c) {
+ $this->a = $a;
+ $this->b = $b;
+ $this->c = $c;
+ }
+}
+
+test('object', new Obj(1, 2, 3), false);
+
+test('object', array(new Obj(1, 2, 3), new Obj(4, 5, 6)), false);
+
+$o = new Obj(1, 2, 3);
+
+test('object', array(&$o, &$o), false);
+--EXPECTF--
+NULL
+OK
+bool(true)
+OK
+bool(false)
+OK
+int(0)
+OK
+int(1)
+OK
+int(-1)
+OK
+int(1000)
+OK
+int(-1000)
+OK
+int(100000)
+OK
+int(-100000)
+OK
+float(123.456)
+OK
+string(0) ""
+OK
+string(6) "foobar"
+OK
+array(0) {
+}
+OK
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
+OK
+array(3) {
+ [0]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+ [1]=>
+ array(3) {
+ [0]=>
+ int(4)
+ [1]=>
+ int(5)
+ [2]=>
+ int(6)
+ }
+ [2]=>
+ array(3) {
+ [0]=>
+ int(7)
+ [1]=>
+ int(8)
+ [2]=>
+ int(9)
+ }
+}
+OK
+array(3) {
+ [0]=>
+ string(3) "foo"
+ [1]=>
+ string(3) "foo"
+ [2]=>
+ string(3) "foo"
+}
+OK
+array(2) {
+ ["one"]=>
+ int(1)
+ ["two"]=>
+ int(2)
+}
+OK
+array(2) {
+ ["kek"]=>
+ string(3) "lol"
+ ["lol"]=>
+ string(3) "kek"
+}
+OK
+array(1) {
+ [""]=>
+ string(5) "empty"
+}
+OK
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+}
+OK
+array(2) {
+ [0]=>
+ &array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+ [1]=>
+ &array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+}
+OK
+array(1) {
+ [0]=>
+ &array(1) {
+ [0]=>
+ &array(1) {
+ [0]=>
+ *RECURSION*
+ }
+ }
+}
+OK
+array(2) {
+ ["a"]=>
+ array(2) {
+ ["b"]=>
+ string(1) "c"
+ ["d"]=>
+ string(1) "e"
+ }
+ ["f"]=>
+ array(1) {
+ ["g"]=>
+ string(1) "h"
+ }
+}
+OK
+object(Obj)#%d (3) {
+ ["a"]=>
+ int(1)
+ [%r"?b"?:protected"?%r]=>
+ int(2)
+ [%r"?c"?:("Obj":)?private"?%r]=>
+ int(3)
+}
+OK
+array(2) {
+ [0]=>
+ object(Obj)#%d (3) {
+ ["a"]=>
+ int(1)
+ [%r"?b"?:protected"?%r]=>
+ int(2)
+ [%r"?c"?:("Obj":)?private"?%r]=>
+ int(3)
+ }
+ [1]=>
+ object(Obj)#%d (3) {
+ ["a"]=>
+ int(4)
+ [%r"?b"?:protected"?%r]=>
+ int(5)
+ [%r"?c"?:("Obj":)?private"?%r]=>
+ int(6)
+ }
+}
+OK
+array(2) {
+ [0]=>
+ &object(Obj)#%d (3) {
+ ["a"]=>
+ int(1)
+ [%r"?b"?:protected"?%r]=>
+ int(2)
+ [%r"?c"?:("Obj":)?private"?%r]=>
+ int(3)
+ }
+ [1]=>
+ &object(Obj)#%d (3) {
+ ["a"]=>
+ int(1)
+ [%r"?b"?:protected"?%r]=>
+ int(2)
+ [%r"?c"?:("Obj":)?private"?%r]=>
+ int(3)
+ }
+}
+OK
diff --git a/php/tests/072.phpt b/php/tests/072.phpt
index d8cb1b9..ea79a56 100644
--- a/php/tests/072.phpt
+++ b/php/tests/072.phpt
@@ -1,6 +1,10 @@
--TEST--
Check for class methods unpacker
--SKIPIF--
+<?php
+if (version_compare(PHP_VERSION, '5.3.3') >= 0) {
+ echo "skip tests in PHP 5.3.2 and lower";
+}
--FILE--
<?php
if(!extension_loaded('msgpack')) {
@@ -260,11 +264,11 @@ array(1) {
[0]=>
&array(1) {
[0]=>
- array(1) {
+ &array(1) {
[0]=>
&array(1) {
[0]=>
- array(1) {
+ &array(1) {
[0]=>
*RECURSION*
}
diff --git a/php/tests/072b.phpt b/php/tests/072b.phpt
new file mode 100644
index 0000000..c7b0c3c
--- /dev/null
+++ b/php/tests/072b.phpt
@@ -0,0 +1,339 @@
+--TEST--
+Check for class methods unpacker
+--SKIPIF--
+<?php
+if (version_compare(PHP_VERSION, '5.3.2') <= 0) {
+ echo "skip tests in PHP 5.3.3";
+}
+--FILE--
+<?php
+if(!extension_loaded('msgpack')) {
+ dl('msgpack.' . PHP_SHLIB_SUFFIX);
+}
+
+function test($type, $variable, $test = null) {
+ $msgpack = new MessagePack();
+
+ $serialized = $msgpack->pack($variable);
+ $unpacker = $msgpack->unpacker();
+
+ $length = strlen($serialized);
+
+ if (rand(0, 1))
+ {
+ for ($i = 0; $i < $length;) {
+ $len = rand(1, 10);
+ $str = substr($serialized, $i, $len);
+
+ $unpacker->feed($str);
+ if ($unpacker->execute())
+ {
+ $unserialized = $unpacker->data();
+ var_dump($unserialized);
+ $unpacker->reset();
+ }
+
+ $i += $len;
+ }
+ }
+ else
+ {
+ $str = "";
+ $offset = 0;
+
+ for ($i = 0; $i < $length;) {
+ $len = rand(1, 10);
+ $str .= substr($serialized, $i, $len);
+
+ if ($unpacker->execute($str, $offset))
+ {
+ $unserialized = $unpacker->data();
+ var_dump($unserialized);
+
+ $unpacker->reset();
+ $str = "";
+ $offset = 0;
+ }
+
+ $i += $len;
+ }
+ }
+
+ if (!is_bool($test))
+ {
+ echo $unserialized === $variable ? 'OK' : 'ERROR', PHP_EOL;
+ }
+ else
+ {
+ echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
+ }
+}
+
+test('null', null);
+
+test('boo:l true', true);
+test('bool: true', false);
+
+test('zero: 0', 0);
+test('small: 1', 1);
+test('small: -1', -1);
+test('medium: 1000', 1000);
+test('medium: -1000', -1000);
+test('large: 100000', 100000);
+test('large: -100000', -100000);
+
+test('double: 123.456', 123.456);
+
+test('empty: ""', "");
+test('string: "foobar"', "foobar");
+
+test('empty: array', array(), false);
+test('empty: array(1, 2, 3)', array(1, 2, 3), false);
+test('empty: array(array(1, 2, 3), arr...', array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9)), false);
+
+test('array("foo", "foo", "foo")', array("foo", "foo", "foo"), false);
+test('array("one" => 1, "two" => 2))', array("one" => 1, "two" => 2), false);
+test('array("kek" => "lol", "lol" => "kek")', array("kek" => "lol", "lol" => "kek"), false);
+test('array("" => "empty")', array("" => "empty"), false);
+
+$a = array('foo');
+test('array($a, $a)', array($a, $a), false);
+test('array(&$a, &$a)', array(&$a, &$a), false);
+
+$a = array(null);
+$b = array(&$a);
+$a[0] = &$b;
+
+test('cyclic', $a, true);
+
+$a = array(
+ 'a' => array(
+ 'b' => 'c',
+ 'd' => 'e'
+ ),
+ 'f' => array(
+ 'g' => 'h'
+ )
+ );
+
+test('array', $a, false);
+
+class Obj {
+ public $a;
+ protected $b;
+ private $c;
+
+ function __construct($a, $b, $c) {
+ $this->a = $a;
+ $this->b = $b;
+ $this->c = $c;
+ }
+}
+
+test('object', new Obj(1, 2, 3), false);
+
+test('object', array(new Obj(1, 2, 3), new Obj(4, 5, 6)), false);
+
+$o = new Obj(1, 2, 3);
+
+test('object', array(&$o, &$o), false);
+--EXPECTF--
+NULL
+OK
+bool(true)
+OK
+bool(false)
+OK
+int(0)
+OK
+int(1)
+OK
+int(-1)
+OK
+int(1000)
+OK
+int(-1000)
+OK
+int(100000)
+OK
+int(-100000)
+OK
+float(123.456)
+OK
+string(0) ""
+OK
+string(6) "foobar"
+OK
+array(0) {
+}
+OK
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
+OK
+array(3) {
+ [0]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+ [1]=>
+ array(3) {
+ [0]=>
+ int(4)
+ [1]=>
+ int(5)
+ [2]=>
+ int(6)
+ }
+ [2]=>
+ array(3) {
+ [0]=>
+ int(7)
+ [1]=>
+ int(8)
+ [2]=>
+ int(9)
+ }
+}
+OK
+array(3) {
+ [0]=>
+ string(3) "foo"
+ [1]=>
+ string(3) "foo"
+ [2]=>
+ string(3) "foo"
+}
+OK
+array(2) {
+ ["one"]=>
+ int(1)
+ ["two"]=>
+ int(2)
+}
+OK
+array(2) {
+ ["kek"]=>
+ string(3) "lol"
+ ["lol"]=>
+ string(3) "kek"
+}
+OK
+array(1) {
+ [""]=>
+ string(5) "empty"
+}
+OK
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+}
+OK
+array(2) {
+ [0]=>
+ &array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+ [1]=>
+ &array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+}
+OK
+array(1) {
+ [0]=>
+ &array(1) {
+ [0]=>
+ &array(1) {
+ [0]=>
+ *RECURSION*
+ }
+ }
+}
+OK
+array(2) {
+ ["a"]=>
+ array(2) {
+ ["b"]=>
+ string(1) "c"
+ ["d"]=>
+ string(1) "e"
+ }
+ ["f"]=>
+ array(1) {
+ ["g"]=>
+ string(1) "h"
+ }
+}
+OK
+object(Obj)#%d (3) {
+ ["a"]=>
+ int(1)
+ [%r"?b"?:protected"?%r]=>
+ int(2)
+ [%r"?c"?:("Obj":)?private"?%r]=>
+ int(3)
+}
+OK
+array(2) {
+ [0]=>
+ object(Obj)#%d (3) {
+ ["a"]=>
+ int(1)
+ [%r"?b"?:protected"?%r]=>
+ int(2)
+ [%r"?c"?:("Obj":)?private"?%r]=>
+ int(3)
+ }
+ [1]=>
+ object(Obj)#%d (3) {
+ ["a"]=>
+ int(4)
+ [%r"?b"?:protected"?%r]=>
+ int(5)
+ [%r"?c"?:("Obj":)?private"?%r]=>
+ int(6)
+ }
+}
+OK
+array(2) {
+ [0]=>
+ &object(Obj)#%d (3) {
+ ["a"]=>
+ int(1)
+ [%r"?b"?:protected"?%r]=>
+ int(2)
+ [%r"?c"?:("Obj":)?private"?%r]=>
+ int(3)
+ }
+ [1]=>
+ &object(Obj)#%d (3) {
+ ["a"]=>
+ int(1)
+ [%r"?b"?:protected"?%r]=>
+ int(2)
+ [%r"?c"?:("Obj":)?private"?%r]=>
+ int(3)
+ }
+}
+OK
diff --git a/php/tests/073.phpt b/php/tests/073.phpt
new file mode 100644
index 0000000..d3a7637
--- /dev/null
+++ b/php/tests/073.phpt
@@ -0,0 +1,346 @@
+--TEST--
+Check for class unpacker
+--SKIPIF--
+<?php
+if (version_compare(PHP_VERSION, '5.3.3') >= 0) {
+ echo "skip tests in PHP 5.3.2 and lower";
+}
+--FILE--
+<?php
+if(!extension_loaded('msgpack')) {
+ dl('msgpack.' . PHP_SHLIB_SUFFIX);
+}
+
+function test($type, $variable, $test = null) {
+ $msgpack = new MessagePack();
+
+ $serialized = $msgpack->pack($variable);
+
+ $unpacker = new MessagePackUnpacker();
+
+ $length = strlen($serialized);
+
+ if (rand(0, 1))
+ {
+ for ($i = 0; $i < $length;) {
+ $len = rand(1, 10);
+ $str = substr($serialized, $i, $len);
+
+ $unpacker->feed($str);
+ if ($unpacker->execute())
+ {
+ $unserialized = $unpacker->data();
+ var_dump($unserialized);
+ $unpacker->reset();
+ }
+
+ $i += $len;
+ }
+ }
+ else
+ {
+ $str = "";
+ $offset = 0;
+
+ for ($i = 0; $i < $length;) {
+ $len = rand(1, 10);
+ $str .= substr($serialized, $i, $len);
+
+ if ($unpacker->execute($str, $offset))
+ {
+ $unserialized = $unpacker->data();
+ var_dump($unserialized);
+
+ $unpacker->reset();
+ $str = "";
+ $offset = 0;
+ }
+
+ $i += $len;
+ }
+ }
+
+ if (!is_bool($test))
+ {
+ echo $unserialized === $variable ? 'OK' : 'ERROR', PHP_EOL;
+ }
+ else
+ {
+ echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
+ }
+}
+
+test('null', null);
+
+test('boo:l true', true);
+test('bool: true', false);
+
+test('zero: 0', 0);
+test('small: 1', 1);
+test('small: -1', -1);
+test('medium: 1000', 1000);
+test('medium: -1000', -1000);
+test('large: 100000', 100000);
+test('large: -100000', -100000);
+
+test('double: 123.456', 123.456);
+
+test('empty: ""', "");
+test('string: "foobar"', "foobar");
+
+test('empty: array', array(), false);
+test('empty: array(1, 2, 3)', array(1, 2, 3), false);
+test('empty: array(array(1, 2, 3), arr...', array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9)), false);
+
+test('array("foo", "foo", "foo")', array("foo", "foo", "foo"), false);
+test('array("one" => 1, "two" => 2))', array("one" => 1, "two" => 2), false);
+test('array("kek" => "lol", "lol" => "kek")', array("kek" => "lol", "lol" => "kek"), false);
+test('array("" => "empty")', array("" => "empty"), false);
+
+$a = array('foo');
+test('array($a, $a)', array($a, $a), false);
+test('array(&$a, &$a)', array(&$a, &$a), false);
+
+$a = array(null);
+$b = array(&$a);
+$a[0] = &$b;
+
+test('cyclic', $a, true);
+
+$a = array(
+ 'a' => array(
+ 'b' => 'c',
+ 'd' => 'e'
+ ),
+ 'f' => array(
+ 'g' => 'h'
+ )
+ );
+
+test('array', $a, false);
+
+class Obj {
+ public $a;
+ protected $b;
+ private $c;
+
+ function __construct($a, $b, $c) {
+ $this->a = $a;
+ $this->b = $b;
+ $this->c = $c;
+ }
+}
+
+test('object', new Obj(1, 2, 3), false);
+
+test('object', array(new Obj(1, 2, 3), new Obj(4, 5, 6)), false);
+
+$o = new Obj(1, 2, 3);
+
+test('object', array(&$o, &$o), false);
+--EXPECTF--
+NULL
+OK
+bool(true)
+OK
+bool(false)
+OK
+int(0)
+OK
+int(1)
+OK
+int(-1)
+OK
+int(1000)
+OK
+int(-1000)
+OK
+int(100000)
+OK
+int(-100000)
+OK
+float(123.456)
+OK
+string(0) ""
+OK
+string(6) "foobar"
+OK
+array(0) {
+}
+OK
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
+OK
+array(3) {
+ [0]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+ [1]=>
+ array(3) {
+ [0]=>
+ int(4)
+ [1]=>
+ int(5)
+ [2]=>
+ int(6)
+ }
+ [2]=>
+ array(3) {
+ [0]=>
+ int(7)
+ [1]=>
+ int(8)
+ [2]=>
+ int(9)
+ }
+}
+OK
+array(3) {
+ [0]=>
+ string(3) "foo"
+ [1]=>
+ string(3) "foo"
+ [2]=>
+ string(3) "foo"
+}
+OK
+array(2) {
+ ["one"]=>
+ int(1)
+ ["two"]=>
+ int(2)
+}
+OK
+array(2) {
+ ["kek"]=>
+ string(3) "lol"
+ ["lol"]=>
+ string(3) "kek"
+}
+OK
+array(1) {
+ [""]=>
+ string(5) "empty"
+}
+OK
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+}
+OK
+array(2) {
+ [0]=>
+ &array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+ [1]=>
+ &array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+}
+OK
+array(1) {
+ [0]=>
+ &array(1) {
+ [0]=>
+ &array(1) {
+ [0]=>
+ &array(1) {
+ [0]=>
+ &array(1) {
+ [0]=>
+ *RECURSION*
+ }
+ }
+ }
+ }
+}
+OK
+array(2) {
+ ["a"]=>
+ array(2) {
+ ["b"]=>
+ string(1) "c"
+ ["d"]=>
+ string(1) "e"
+ }
+ ["f"]=>
+ array(1) {
+ ["g"]=>
+ string(1) "h"
+ }
+}
+OK
+object(Obj)#%d (3) {
+ ["a"]=>
+ int(1)
+ [%r"?b"?:protected"?%r]=>
+ int(2)
+ [%r"?c"?:("Obj":)?private"?%r]=>
+ int(3)
+}
+OK
+array(2) {
+ [0]=>
+ object(Obj)#%d (3) {
+ ["a"]=>
+ int(1)
+ [%r"?b"?:protected"?%r]=>
+ int(2)
+ [%r"?c"?:("Obj":)?private"?%r]=>
+ int(3)
+ }
+ [1]=>
+ object(Obj)#%d (3) {
+ ["a"]=>
+ int(4)
+ [%r"?b"?:protected"?%r]=>
+ int(5)
+ [%r"?c"?:("Obj":)?private"?%r]=>
+ int(6)
+ }
+}
+OK
+array(2) {
+ [0]=>
+ &object(Obj)#%d (3) {
+ ["a"]=>
+ int(1)
+ [%r"?b"?:protected"?%r]=>
+ int(2)
+ [%r"?c"?:("Obj":)?private"?%r]=>
+ int(3)
+ }
+ [1]=>
+ &object(Obj)#%d (3) {
+ ["a"]=>
+ int(1)
+ [%r"?b"?:protected"?%r]=>
+ int(2)
+ [%r"?c"?:("Obj":)?private"?%r]=>
+ int(3)
+ }
+}
+OK
diff --git a/php/tests/073b.phpt b/php/tests/073b.phpt
new file mode 100644
index 0000000..131a534
--- /dev/null
+++ b/php/tests/073b.phpt
@@ -0,0 +1,340 @@
+--TEST--
+Check for class unpacker
+--SKIPIF--
+<?php
+if (version_compare(PHP_VERSION, '5.3.2') <= 0) {
+ echo "skip tests in PHP 5.3.3";
+}
+--FILE--
+<?php
+if(!extension_loaded('msgpack')) {
+ dl('msgpack.' . PHP_SHLIB_SUFFIX);
+}
+
+function test($type, $variable, $test = null) {
+ $msgpack = new MessagePack();
+
+ $serialized = $msgpack->pack($variable);
+
+ $unpacker = new MessagePackUnpacker();
+
+ $length = strlen($serialized);
+
+ if (rand(0, 1))
+ {
+ for ($i = 0; $i < $length;) {
+ $len = rand(1, 10);
+ $str = substr($serialized, $i, $len);
+
+ $unpacker->feed($str);
+ if ($unpacker->execute())
+ {
+ $unserialized = $unpacker->data();
+ var_dump($unserialized);
+ $unpacker->reset();
+ }
+
+ $i += $len;
+ }
+ }
+ else
+ {
+ $str = "";
+ $offset = 0;
+
+ for ($i = 0; $i < $length;) {
+ $len = rand(1, 10);
+ $str .= substr($serialized, $i, $len);
+
+ if ($unpacker->execute($str, $offset))
+ {
+ $unserialized = $unpacker->data();
+ var_dump($unserialized);
+
+ $unpacker->reset();
+ $str = "";
+ $offset = 0;
+ }
+
+ $i += $len;
+ }
+ }
+
+ if (!is_bool($test))
+ {
+ echo $unserialized === $variable ? 'OK' : 'ERROR', PHP_EOL;
+ }
+ else
+ {
+ echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
+ }
+}
+
+test('null', null);
+
+test('boo:l true', true);
+test('bool: true', false);
+
+test('zero: 0', 0);
+test('small: 1', 1);
+test('small: -1', -1);
+test('medium: 1000', 1000);
+test('medium: -1000', -1000);
+test('large: 100000', 100000);
+test('large: -100000', -100000);
+
+test('double: 123.456', 123.456);
+
+test('empty: ""', "");
+test('string: "foobar"', "foobar");
+
+test('empty: array', array(), false);
+test('empty: array(1, 2, 3)', array(1, 2, 3), false);
+test('empty: array(array(1, 2, 3), arr...', array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9)), false);
+
+test('array("foo", "foo", "foo")', array("foo", "foo", "foo"), false);
+test('array("one" => 1, "two" => 2))', array("one" => 1, "two" => 2), false);
+test('array("kek" => "lol", "lol" => "kek")', array("kek" => "lol", "lol" => "kek"), false);
+test('array("" => "empty")', array("" => "empty"), false);
+
+$a = array('foo');
+test('array($a, $a)', array($a, $a), false);
+test('array(&$a, &$a)', array(&$a, &$a), false);
+
+$a = array(null);
+$b = array(&$a);
+$a[0] = &$b;
+
+test('cyclic', $a, true);
+
+$a = array(
+ 'a' => array(
+ 'b' => 'c',
+ 'd' => 'e'
+ ),
+ 'f' => array(
+ 'g' => 'h'
+ )
+ );
+
+test('array', $a, false);
+
+class Obj {
+ public $a;
+ protected $b;
+ private $c;
+
+ function __construct($a, $b, $c) {
+ $this->a = $a;
+ $this->b = $b;
+ $this->c = $c;
+ }
+}
+
+test('object', new Obj(1, 2, 3), false);
+
+test('object', array(new Obj(1, 2, 3), new Obj(4, 5, 6)), false);
+
+$o = new Obj(1, 2, 3);
+
+test('object', array(&$o, &$o), false);
+--EXPECTF--
+NULL
+OK
+bool(true)
+OK
+bool(false)
+OK
+int(0)
+OK
+int(1)
+OK
+int(-1)
+OK
+int(1000)
+OK
+int(-1000)
+OK
+int(100000)
+OK
+int(-100000)
+OK
+float(123.456)
+OK
+string(0) ""
+OK
+string(6) "foobar"
+OK
+array(0) {
+}
+OK
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
+OK
+array(3) {
+ [0]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+ [1]=>
+ array(3) {
+ [0]=>
+ int(4)
+ [1]=>
+ int(5)
+ [2]=>
+ int(6)
+ }
+ [2]=>
+ array(3) {
+ [0]=>
+ int(7)
+ [1]=>
+ int(8)
+ [2]=>
+ int(9)
+ }
+}
+OK
+array(3) {
+ [0]=>
+ string(3) "foo"
+ [1]=>
+ string(3) "foo"
+ [2]=>
+ string(3) "foo"
+}
+OK
+array(2) {
+ ["one"]=>
+ int(1)
+ ["two"]=>
+ int(2)
+}
+OK
+array(2) {
+ ["kek"]=>
+ string(3) "lol"
+ ["lol"]=>
+ string(3) "kek"
+}
+OK
+array(1) {
+ [""]=>
+ string(5) "empty"
+}
+OK
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+}
+OK
+array(2) {
+ [0]=>
+ &array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+ [1]=>
+ &array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+}
+OK
+array(1) {
+ [0]=>
+ &array(1) {
+ [0]=>
+ &array(1) {
+ [0]=>
+ *RECURSION*
+ }
+ }
+}
+OK
+array(2) {
+ ["a"]=>
+ array(2) {
+ ["b"]=>
+ string(1) "c"
+ ["d"]=>
+ string(1) "e"
+ }
+ ["f"]=>
+ array(1) {
+ ["g"]=>
+ string(1) "h"
+ }
+}
+OK
+object(Obj)#%d (3) {
+ ["a"]=>
+ int(1)
+ [%r"?b"?:protected"?%r]=>
+ int(2)
+ [%r"?c"?:("Obj":)?private"?%r]=>
+ int(3)
+}
+OK
+array(2) {
+ [0]=>
+ object(Obj)#%d (3) {
+ ["a"]=>
+ int(1)
+ [%r"?b"?:protected"?%r]=>
+ int(2)
+ [%r"?c"?:("Obj":)?private"?%r]=>
+ int(3)
+ }
+ [1]=>
+ object(Obj)#%d (3) {
+ ["a"]=>
+ int(4)
+ [%r"?b"?:protected"?%r]=>
+ int(5)
+ [%r"?c"?:("Obj":)?private"?%r]=>
+ int(6)
+ }
+}
+OK
+array(2) {
+ [0]=>
+ &object(Obj)#%d (3) {
+ ["a"]=>
+ int(1)
+ [%r"?b"?:protected"?%r]=>
+ int(2)
+ [%r"?c"?:("Obj":)?private"?%r]=>
+ int(3)
+ }
+ [1]=>
+ &object(Obj)#%d (3) {
+ ["a"]=>
+ int(1)
+ [%r"?b"?:protected"?%r]=>
+ int(2)
+ [%r"?c"?:("Obj":)?private"?%r]=>
+ int(3)
+ }
+}
+OK
diff --git a/php/tests/080.phpt b/php/tests/080.phpt
new file mode 100644
index 0000000..aba1cb6
--- /dev/null
+++ b/php/tests/080.phpt
@@ -0,0 +1,301 @@
+--TEST--
+disabled php only (ini_set)
+--SKIPIF--
+--FILE--
+<?php
+if(!extension_loaded('msgpack')) {
+ dl('msgpack.' . PHP_SHLIB_SUFFIX);
+}
+
+ini_set('msgpack.php_only', 0);
+
+function test($type, $variable, $test = null) {
+ $serialized = msgpack_pack($variable);
+ $unserialized = msgpack_unpack($serialized);
+
+ var_dump($unserialized);
+
+ if (!is_bool($test))
+ {
+ echo $unserialized === $variable ? 'OK' : 'ERROR', PHP_EOL;
+ }
+ else
+ {
+ echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
+ }
+}
+
+test('null', null);
+
+test('boo:l true', true);
+test('bool: true', false);
+
+test('zero: 0', 0);
+test('small: 1', 1);
+test('small: -1', -1);
+test('medium: 1000', 1000);
+test('medium: -1000', -1000);
+test('large: 100000', 100000);
+test('large: -100000', -100000);
+
+test('double: 123.456', 123.456);
+
+test('empty: ""', "");
+test('string: "foobar"', "foobar");
+
+test('empty: array', array(), false);
+test('empty: array(1, 2, 3)', array(1, 2, 3), false);
+test('empty: array(array(1, 2, 3), arr...', array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9)), false);
+
+test('array("foo", "foo", "foo")', array("foo", "foo", "foo"), false);
+test('array("one" => 1, "two" => 2))', array("one" => 1, "two" => 2), false);
+test('array("kek" => "lol", "lol" => "kek")', array("kek" => "lol", "lol" => "kek"), false);
+test('array("" => "empty")', array("" => "empty"), false);
+
+$a = array('foo');
+test('array($a, $a)', array($a, $a), false);
+test('array(&$a, &$a)', array(&$a, &$a), false);
+
+$a = array(null);
+$b = array(&$a);
+$a[0] = &$b;
+
+test('cyclic', $a, true);
+
+$a = array(
+ 'a' => array(
+ 'b' => 'c',
+ 'd' => 'e'
+ ),
+ 'f' => array(
+ 'g' => 'h'
+ )
+ );
+
+test('array', $a, false);
+
+class Obj {
+ public $a;
+ protected $b;
+ private $c;
+
+ function __construct($a, $b, $c) {
+ $this->a = $a;
+ $this->b = $b;
+ $this->c = $c;
+ }
+}
+
+test('object', new Obj(1, 2, 3), true);
+
+test('object', array(new Obj(1, 2, 3), new Obj(4, 5, 6)), true);
+
+$o = new Obj(1, 2, 3);
+
+test('object', array(&$o, &$o), true);
+--EXPECTF--
+NULL
+OK
+bool(true)
+OK
+bool(false)
+OK
+int(0)
+OK
+int(1)
+OK
+int(-1)
+OK
+int(1000)
+OK
+int(-1000)
+OK
+int(100000)
+OK
+int(-100000)
+OK
+float(123.456)
+OK
+string(0) ""
+OK
+string(6) "foobar"
+OK
+array(0) {
+}
+OK
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
+OK
+array(3) {
+ [0]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+ [1]=>
+ array(3) {
+ [0]=>
+ int(4)
+ [1]=>
+ int(5)
+ [2]=>
+ int(6)
+ }
+ [2]=>
+ array(3) {
+ [0]=>
+ int(7)
+ [1]=>
+ int(8)
+ [2]=>
+ int(9)
+ }
+}
+OK
+array(3) {
+ [0]=>
+ string(3) "foo"
+ [1]=>
+ string(3) "foo"
+ [2]=>
+ string(3) "foo"
+}
+OK
+array(2) {
+ ["one"]=>
+ int(1)
+ ["two"]=>
+ int(2)
+}
+OK
+array(2) {
+ ["kek"]=>
+ string(3) "lol"
+ ["lol"]=>
+ string(3) "kek"
+}
+OK
+array(1) {
+ [""]=>
+ string(5) "empty"
+}
+OK
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+}
+OK
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+}
+OK
+array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ NULL
+ }
+ }
+ }
+ }
+}
+OK
+array(2) {
+ ["a"]=>
+ array(2) {
+ ["b"]=>
+ string(1) "c"
+ ["d"]=>
+ string(1) "e"
+ }
+ ["f"]=>
+ array(1) {
+ ["g"]=>
+ string(1) "h"
+ }
+}
+OK
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
+OK
+array(2) {
+ [0]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+ [1]=>
+ array(3) {
+ [0]=>
+ int(4)
+ [1]=>
+ int(5)
+ [2]=>
+ int(6)
+ }
+}
+OK
+array(2) {
+ [0]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+ [1]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+}
+OK
diff --git a/php/tests/081.phpt b/php/tests/081.phpt
new file mode 100644
index 0000000..d22daaa
--- /dev/null
+++ b/php/tests/081.phpt
@@ -0,0 +1,303 @@
+--TEST--
+disabled php only for class methods (ini_set)
+--SKIPIF--
+--FILE--
+<?php
+if(!extension_loaded('msgpack')) {
+ dl('msgpack.' . PHP_SHLIB_SUFFIX);
+}
+
+ini_set('msgpack.php_only', 0);
+
+function test($type, $variable, $test = null) {
+ $msgpack = new MessagePack();
+
+ $serialized = $msgpack->pack($variable);
+ $unserialized = $msgpack->unpack($serialized);
+
+ var_dump($unserialized);
+
+ if (!is_bool($test))
+ {
+ echo $unserialized === $variable ? 'OK' : 'ERROR', PHP_EOL;
+ }
+ else
+ {
+ echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
+ }
+}
+
+test('null', null);
+
+test('boo:l true', true);
+test('bool: true', false);
+
+test('zero: 0', 0);
+test('small: 1', 1);
+test('small: -1', -1);
+test('medium: 1000', 1000);
+test('medium: -1000', -1000);
+test('large: 100000', 100000);
+test('large: -100000', -100000);
+
+test('double: 123.456', 123.456);
+
+test('empty: ""', "");
+test('string: "foobar"', "foobar");
+
+test('empty: array', array(), false);
+test('empty: array(1, 2, 3)', array(1, 2, 3), false);
+test('empty: array(array(1, 2, 3), arr...', array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9)), false);
+
+test('array("foo", "foo", "foo")', array("foo", "foo", "foo"), false);
+test('array("one" => 1, "two" => 2))', array("one" => 1, "two" => 2), false);
+test('array("kek" => "lol", "lol" => "kek")', array("kek" => "lol", "lol" => "kek"), false);
+test('array("" => "empty")', array("" => "empty"), false);
+
+$a = array('foo');
+test('array($a, $a)', array($a, $a), false);
+test('array(&$a, &$a)', array(&$a, &$a), false);
+
+$a = array(null);
+$b = array(&$a);
+$a[0] = &$b;
+
+test('cyclic', $a, true);
+
+$a = array(
+ 'a' => array(
+ 'b' => 'c',
+ 'd' => 'e'
+ ),
+ 'f' => array(
+ 'g' => 'h'
+ )
+ );
+
+test('array', $a, false);
+
+class Obj {
+ public $a;
+ protected $b;
+ private $c;
+
+ function __construct($a, $b, $c) {
+ $this->a = $a;
+ $this->b = $b;
+ $this->c = $c;
+ }
+}
+
+test('object', new Obj(1, 2, 3), true);
+
+test('object', array(new Obj(1, 2, 3), new Obj(4, 5, 6)), true);
+
+$o = new Obj(1, 2, 3);
+
+test('object', array(&$o, &$o), true);
+--EXPECTF--
+NULL
+OK
+bool(true)
+OK
+bool(false)
+OK
+int(0)
+OK
+int(1)
+OK
+int(-1)
+OK
+int(1000)
+OK
+int(-1000)
+OK
+int(100000)
+OK
+int(-100000)
+OK
+float(123.456)
+OK
+string(0) ""
+OK
+string(6) "foobar"
+OK
+array(0) {
+}
+OK
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
+OK
+array(3) {
+ [0]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+ [1]=>
+ array(3) {
+ [0]=>
+ int(4)
+ [1]=>
+ int(5)
+ [2]=>
+ int(6)
+ }
+ [2]=>
+ array(3) {
+ [0]=>
+ int(7)
+ [1]=>
+ int(8)
+ [2]=>
+ int(9)
+ }
+}
+OK
+array(3) {
+ [0]=>
+ string(3) "foo"
+ [1]=>
+ string(3) "foo"
+ [2]=>
+ string(3) "foo"
+}
+OK
+array(2) {
+ ["one"]=>
+ int(1)
+ ["two"]=>
+ int(2)
+}
+OK
+array(2) {
+ ["kek"]=>
+ string(3) "lol"
+ ["lol"]=>
+ string(3) "kek"
+}
+OK
+array(1) {
+ [""]=>
+ string(5) "empty"
+}
+OK
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+}
+OK
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+}
+OK
+array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ NULL
+ }
+ }
+ }
+ }
+}
+OK
+array(2) {
+ ["a"]=>
+ array(2) {
+ ["b"]=>
+ string(1) "c"
+ ["d"]=>
+ string(1) "e"
+ }
+ ["f"]=>
+ array(1) {
+ ["g"]=>
+ string(1) "h"
+ }
+}
+OK
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
+OK
+array(2) {
+ [0]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+ [1]=>
+ array(3) {
+ [0]=>
+ int(4)
+ [1]=>
+ int(5)
+ [2]=>
+ int(6)
+ }
+}
+OK
+array(2) {
+ [0]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+ [1]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+}
+OK
diff --git a/php/tests/082.phpt b/php/tests/082.phpt
new file mode 100644
index 0000000..45a9d93
--- /dev/null
+++ b/php/tests/082.phpt
@@ -0,0 +1,346 @@
+--TEST--
+disabled php only for class methods unpacker (ini_set)
+--SKIPIF--
+--FILE--
+<?php
+if(!extension_loaded('msgpack')) {
+ dl('msgpack.' . PHP_SHLIB_SUFFIX);
+}
+
+ini_set('msgpack.php_only', 0);
+
+function test($type, $variable, $test = null)
+{
+ $msgpack = new MessagePack();
+
+ $serialized = $msgpack->pack($variable);
+ $unpacker = $msgpack->unpacker();
+
+ $length = strlen($serialized);
+
+ if (rand(0, 1))
+ {
+ for ($i = 0; $i < $length;)
+ {
+ $len = rand(1, 10);
+ $str = substr($serialized, $i, $len);
+
+ $unpacker->feed($str);
+ if ($unpacker->execute())
+ {
+ $unserialized = $unpacker->data();
+ var_dump($unserialized);
+ $unpacker->reset();
+ }
+
+ $i += $len;
+ }
+ }
+ else
+ {
+ $str = "";
+ $offset = 0;
+
+ for ($i = 0; $i < $length;)
+ {
+ $len = rand(1, 10);
+ $str .= substr($serialized, $i, $len);
+
+ if ($unpacker->execute($str, $offset))
+ {
+ $unserialized = $unpacker->data();
+ var_dump($unserialized);
+
+ $unpacker->reset();
+ $str = "";
+ $offset = 0;
+ }
+
+ $i += $len;
+ }
+ }
+
+ if (!is_bool($test))
+ {
+ echo $unserialized === $variable ? 'OK' : 'ERROR', PHP_EOL;
+ }
+ else
+ {
+ echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
+ }
+}
+
+test('null', null);
+
+test('boo:l true', true);
+test('bool: true', false);
+
+test('zero: 0', 0);
+test('small: 1', 1);
+test('small: -1', -1);
+test('medium: 1000', 1000);
+test('medium: -1000', -1000);
+test('large: 100000', 100000);
+test('large: -100000', -100000);
+
+test('double: 123.456', 123.456);
+
+test('empty: ""', "");
+test('string: "foobar"', "foobar");
+
+test('empty: array', array(), false);
+test('empty: array(1, 2, 3)', array(1, 2, 3), false);
+test('empty: array(array(1, 2, 3), arr...', array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9)), false);
+
+test('array("foo", "foo", "foo")', array("foo", "foo", "foo"), false);
+test('array("one" => 1, "two" => 2))', array("one" => 1, "two" => 2), false);
+test('array("kek" => "lol", "lol" => "kek")', array("kek" => "lol", "lol" => "kek"), false);
+test('array("" => "empty")', array("" => "empty"), false);
+
+$a = array('foo');
+test('array($a, $a)', array($a, $a), false);
+test('array(&$a, &$a)', array(&$a, &$a), false);
+
+$a = array(null);
+$b = array(&$a);
+$a[0] = &$b;
+
+test('cyclic', $a, true);
+
+$a = array(
+ 'a' => array(
+ 'b' => 'c',
+ 'd' => 'e'
+ ),
+ 'f' => array(
+ 'g' => 'h'
+ )
+ );
+
+test('array', $a, false);
+
+class Obj {
+ public $a;
+ protected $b;
+ private $c;
+
+ function __construct($a, $b, $c) {
+ $this->a = $a;
+ $this->b = $b;
+ $this->c = $c;
+ }
+}
+
+test('object', new Obj(1, 2, 3), true);
+
+test('object', array(new Obj(1, 2, 3), new Obj(4, 5, 6)), true);
+
+$o = new Obj(1, 2, 3);
+
+test('object', array(&$o, &$o), true);
+--EXPECTF--
+NULL
+OK
+bool(true)
+OK
+bool(false)
+OK
+int(0)
+OK
+int(1)
+OK
+int(-1)
+OK
+int(1000)
+OK
+int(-1000)
+OK
+int(100000)
+OK
+int(-100000)
+OK
+float(123.456)
+OK
+string(0) ""
+OK
+string(6) "foobar"
+OK
+array(0) {
+}
+OK
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
+OK
+array(3) {
+ [0]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+ [1]=>
+ array(3) {
+ [0]=>
+ int(4)
+ [1]=>
+ int(5)
+ [2]=>
+ int(6)
+ }
+ [2]=>
+ array(3) {
+ [0]=>
+ int(7)
+ [1]=>
+ int(8)
+ [2]=>
+ int(9)
+ }
+}
+OK
+array(3) {
+ [0]=>
+ string(3) "foo"
+ [1]=>
+ string(3) "foo"
+ [2]=>
+ string(3) "foo"
+}
+OK
+array(2) {
+ ["one"]=>
+ int(1)
+ ["two"]=>
+ int(2)
+}
+OK
+array(2) {
+ ["kek"]=>
+ string(3) "lol"
+ ["lol"]=>
+ string(3) "kek"
+}
+OK
+array(1) {
+ [""]=>
+ string(5) "empty"
+}
+OK
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+}
+OK
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+}
+OK
+array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ NULL
+ }
+ }
+ }
+ }
+}
+OK
+array(2) {
+ ["a"]=>
+ array(2) {
+ ["b"]=>
+ string(1) "c"
+ ["d"]=>
+ string(1) "e"
+ }
+ ["f"]=>
+ array(1) {
+ ["g"]=>
+ string(1) "h"
+ }
+}
+OK
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
+OK
+array(2) {
+ [0]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+ [1]=>
+ array(3) {
+ [0]=>
+ int(4)
+ [1]=>
+ int(5)
+ [2]=>
+ int(6)
+ }
+}
+OK
+array(2) {
+ [0]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+ [1]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+}
+OK
diff --git a/php/tests/083.phpt b/php/tests/083.phpt
new file mode 100644
index 0000000..203d829
--- /dev/null
+++ b/php/tests/083.phpt
@@ -0,0 +1,347 @@
+--TEST--
+disabled php only for class unpacker (ini_set)
+--SKIPIF--
+--FILE--
+<?php
+if(!extension_loaded('msgpack')) {
+ dl('msgpack.' . PHP_SHLIB_SUFFIX);
+}
+
+ini_set('msgpack.php_only', 0);
+
+function test($type, $variable, $test = null)
+{
+ $msgpack = new MessagePack();
+
+ $serialized = $msgpack->pack($variable);
+
+ $unpacker = new MessagePackUnpacker();
+
+ $length = strlen($serialized);
+
+ if (rand(0, 1))
+ {
+ for ($i = 0; $i < $length;)
+ {
+ $len = rand(1, 10);
+ $str = substr($serialized, $i, $len);
+
+ $unpacker->feed($str);
+ if ($unpacker->execute())
+ {
+ $unserialized = $unpacker->data();
+ var_dump($unserialized);
+ $unpacker->reset();
+ }
+
+ $i += $len;
+ }
+ }
+ else
+ {
+ $str = "";
+ $offset = 0;
+
+ for ($i = 0; $i < $length;)
+ {
+ $len = rand(1, 10);
+ $str .= substr($serialized, $i, $len);
+
+ if ($unpacker->execute($str, $offset))
+ {
+ $unserialized = $unpacker->data();
+ var_dump($unserialized);
+
+ $unpacker->reset();
+ $str = "";
+ $offset = 0;
+ }
+
+ $i += $len;
+ }
+ }
+
+ if (!is_bool($test))
+ {
+ echo $unserialized === $variable ? 'OK' : 'ERROR', PHP_EOL;
+ }
+ else
+ {
+ echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
+ }
+}
+
+test('null', null);
+
+test('boo:l true', true);
+test('bool: true', false);
+
+test('zero: 0', 0);
+test('small: 1', 1);
+test('small: -1', -1);
+test('medium: 1000', 1000);
+test('medium: -1000', -1000);
+test('large: 100000', 100000);
+test('large: -100000', -100000);
+
+test('double: 123.456', 123.456);
+
+test('empty: ""', "");
+test('string: "foobar"', "foobar");
+
+test('empty: array', array(), false);
+test('empty: array(1, 2, 3)', array(1, 2, 3), false);
+test('empty: array(array(1, 2, 3), arr...', array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9)), false);
+
+test('array("foo", "foo", "foo")', array("foo", "foo", "foo"), false);
+test('array("one" => 1, "two" => 2))', array("one" => 1, "two" => 2), false);
+test('array("kek" => "lol", "lol" => "kek")', array("kek" => "lol", "lol" => "kek"), false);
+test('array("" => "empty")', array("" => "empty"), false);
+
+$a = array('foo');
+test('array($a, $a)', array($a, $a), false);
+test('array(&$a, &$a)', array(&$a, &$a), false);
+
+$a = array(null);
+$b = array(&$a);
+$a[0] = &$b;
+
+test('cyclic', $a, true);
+
+$a = array(
+ 'a' => array(
+ 'b' => 'c',
+ 'd' => 'e'
+ ),
+ 'f' => array(
+ 'g' => 'h'
+ )
+ );
+
+test('array', $a, false);
+
+class Obj {
+ public $a;
+ protected $b;
+ private $c;
+
+ function __construct($a, $b, $c) {
+ $this->a = $a;
+ $this->b = $b;
+ $this->c = $c;
+ }
+}
+
+test('object', new Obj(1, 2, 3), true);
+
+test('object', array(new Obj(1, 2, 3), new Obj(4, 5, 6)), true);
+
+$o = new Obj(1, 2, 3);
+
+test('object', array(&$o, &$o), true);
+--EXPECTF--
+NULL
+OK
+bool(true)
+OK
+bool(false)
+OK
+int(0)
+OK
+int(1)
+OK
+int(-1)
+OK
+int(1000)
+OK
+int(-1000)
+OK
+int(100000)
+OK
+int(-100000)
+OK
+float(123.456)
+OK
+string(0) ""
+OK
+string(6) "foobar"
+OK
+array(0) {
+}
+OK
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
+OK
+array(3) {
+ [0]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+ [1]=>
+ array(3) {
+ [0]=>
+ int(4)
+ [1]=>
+ int(5)
+ [2]=>
+ int(6)
+ }
+ [2]=>
+ array(3) {
+ [0]=>
+ int(7)
+ [1]=>
+ int(8)
+ [2]=>
+ int(9)
+ }
+}
+OK
+array(3) {
+ [0]=>
+ string(3) "foo"
+ [1]=>
+ string(3) "foo"
+ [2]=>
+ string(3) "foo"
+}
+OK
+array(2) {
+ ["one"]=>
+ int(1)
+ ["two"]=>
+ int(2)
+}
+OK
+array(2) {
+ ["kek"]=>
+ string(3) "lol"
+ ["lol"]=>
+ string(3) "kek"
+}
+OK
+array(1) {
+ [""]=>
+ string(5) "empty"
+}
+OK
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+}
+OK
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+}
+OK
+array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ NULL
+ }
+ }
+ }
+ }
+}
+OK
+array(2) {
+ ["a"]=>
+ array(2) {
+ ["b"]=>
+ string(1) "c"
+ ["d"]=>
+ string(1) "e"
+ }
+ ["f"]=>
+ array(1) {
+ ["g"]=>
+ string(1) "h"
+ }
+}
+OK
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
+OK
+array(2) {
+ [0]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+ [1]=>
+ array(3) {
+ [0]=>
+ int(4)
+ [1]=>
+ int(5)
+ [2]=>
+ int(6)
+ }
+}
+OK
+array(2) {
+ [0]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+ [1]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+}
+OK
diff --git a/php/tests/084.phpt b/php/tests/084.phpt
new file mode 100644
index 0000000..74d061b
--- /dev/null
+++ b/php/tests/084.phpt
@@ -0,0 +1,301 @@
+--TEST--
+disabled php only for class methods (constract)
+--SKIPIF--
+--FILE--
+<?php
+if(!extension_loaded('msgpack')) {
+ dl('msgpack.' . PHP_SHLIB_SUFFIX);
+}
+
+function test($type, $variable, $test = null) {
+ $msgpack = new MessagePack(false);
+
+ $serialized = $msgpack->pack($variable);
+ $unserialized = $msgpack->unpack($serialized);
+
+ var_dump($unserialized);
+
+ if (!is_bool($test))
+ {
+ echo $unserialized === $variable ? 'OK' : 'ERROR', PHP_EOL;
+ }
+ else
+ {
+ echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
+ }
+}
+
+test('null', null);
+
+test('boo:l true', true);
+test('bool: true', false);
+
+test('zero: 0', 0);
+test('small: 1', 1);
+test('small: -1', -1);
+test('medium: 1000', 1000);
+test('medium: -1000', -1000);
+test('large: 100000', 100000);
+test('large: -100000', -100000);
+
+test('double: 123.456', 123.456);
+
+test('empty: ""', "");
+test('string: "foobar"', "foobar");
+
+test('empty: array', array(), false);
+test('empty: array(1, 2, 3)', array(1, 2, 3), false);
+test('empty: array(array(1, 2, 3), arr...', array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9)), false);
+
+test('array("foo", "foo", "foo")', array("foo", "foo", "foo"), false);
+test('array("one" => 1, "two" => 2))', array("one" => 1, "two" => 2), false);
+test('array("kek" => "lol", "lol" => "kek")', array("kek" => "lol", "lol" => "kek"), false);
+test('array("" => "empty")', array("" => "empty"), false);
+
+$a = array('foo');
+test('array($a, $a)', array($a, $a), false);
+test('array(&$a, &$a)', array(&$a, &$a), false);
+
+$a = array(null);
+$b = array(&$a);
+$a[0] = &$b;
+
+test('cyclic', $a, true);
+
+$a = array(
+ 'a' => array(
+ 'b' => 'c',
+ 'd' => 'e'
+ ),
+ 'f' => array(
+ 'g' => 'h'
+ )
+ );
+
+test('array', $a, false);
+
+class Obj {
+ public $a;
+ protected $b;
+ private $c;
+
+ function __construct($a, $b, $c) {
+ $this->a = $a;
+ $this->b = $b;
+ $this->c = $c;
+ }
+}
+
+test('object', new Obj(1, 2, 3), true);
+
+test('object', array(new Obj(1, 2, 3), new Obj(4, 5, 6)), true);
+
+$o = new Obj(1, 2, 3);
+
+test('object', array(&$o, &$o), true);
+--EXPECTF--
+NULL
+OK
+bool(true)
+OK
+bool(false)
+OK
+int(0)
+OK
+int(1)
+OK
+int(-1)
+OK
+int(1000)
+OK
+int(-1000)
+OK
+int(100000)
+OK
+int(-100000)
+OK
+float(123.456)
+OK
+string(0) ""
+OK
+string(6) "foobar"
+OK
+array(0) {
+}
+OK
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
+OK
+array(3) {
+ [0]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+ [1]=>
+ array(3) {
+ [0]=>
+ int(4)
+ [1]=>
+ int(5)
+ [2]=>
+ int(6)
+ }
+ [2]=>
+ array(3) {
+ [0]=>
+ int(7)
+ [1]=>
+ int(8)
+ [2]=>
+ int(9)
+ }
+}
+OK
+array(3) {
+ [0]=>
+ string(3) "foo"
+ [1]=>
+ string(3) "foo"
+ [2]=>
+ string(3) "foo"
+}
+OK
+array(2) {
+ ["one"]=>
+ int(1)
+ ["two"]=>
+ int(2)
+}
+OK
+array(2) {
+ ["kek"]=>
+ string(3) "lol"
+ ["lol"]=>
+ string(3) "kek"
+}
+OK
+array(1) {
+ [""]=>
+ string(5) "empty"
+}
+OK
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+}
+OK
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+}
+OK
+array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ NULL
+ }
+ }
+ }
+ }
+}
+OK
+array(2) {
+ ["a"]=>
+ array(2) {
+ ["b"]=>
+ string(1) "c"
+ ["d"]=>
+ string(1) "e"
+ }
+ ["f"]=>
+ array(1) {
+ ["g"]=>
+ string(1) "h"
+ }
+}
+OK
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
+OK
+array(2) {
+ [0]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+ [1]=>
+ array(3) {
+ [0]=>
+ int(4)
+ [1]=>
+ int(5)
+ [2]=>
+ int(6)
+ }
+}
+OK
+array(2) {
+ [0]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+ [1]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+}
+OK
diff --git a/php/tests/085.phpt b/php/tests/085.phpt
new file mode 100644
index 0000000..72aacc8
--- /dev/null
+++ b/php/tests/085.phpt
@@ -0,0 +1,344 @@
+--TEST--
+disabled php only for class methods unpacker (constract)
+--SKIPIF--
+--FILE--
+<?php
+if(!extension_loaded('msgpack')) {
+ dl('msgpack.' . PHP_SHLIB_SUFFIX);
+}
+
+function test($type, $variable, $test = null)
+{
+ $msgpack = new MessagePack(false);
+
+ $serialized = $msgpack->pack($variable);
+ $unpacker = $msgpack->unpacker();
+
+ $length = strlen($serialized);
+
+ if (rand(0, 1))
+ {
+ for ($i = 0; $i < $length;)
+ {
+ $len = rand(1, 10);
+ $str = substr($serialized, $i, $len);
+
+ $unpacker->feed($str);
+ if ($unpacker->execute())
+ {
+ $unserialized = $unpacker->data();
+ var_dump($unserialized);
+ $unpacker->reset();
+ }
+
+ $i += $len;
+ }
+ }
+ else
+ {
+ $str = "";
+ $offset = 0;
+
+ for ($i = 0; $i < $length;)
+ {
+ $len = rand(1, 10);
+ $str .= substr($serialized, $i, $len);
+
+ if ($unpacker->execute($str, $offset))
+ {
+ $unserialized = $unpacker->data();
+ var_dump($unserialized);
+
+ $unpacker->reset();
+ $str = "";
+ $offset = 0;
+ }
+
+ $i += $len;
+ }
+ }
+
+ if (!is_bool($test))
+ {
+ echo $unserialized === $variable ? 'OK' : 'ERROR', PHP_EOL;
+ }
+ else
+ {
+ echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
+ }
+}
+
+test('null', null);
+
+test('boo:l true', true);
+test('bool: true', false);
+
+test('zero: 0', 0);
+test('small: 1', 1);
+test('small: -1', -1);
+test('medium: 1000', 1000);
+test('medium: -1000', -1000);
+test('large: 100000', 100000);
+test('large: -100000', -100000);
+
+test('double: 123.456', 123.456);
+
+test('empty: ""', "");
+test('string: "foobar"', "foobar");
+
+test('empty: array', array(), false);
+test('empty: array(1, 2, 3)', array(1, 2, 3), false);
+test('empty: array(array(1, 2, 3), arr...', array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9)), false);
+
+test('array("foo", "foo", "foo")', array("foo", "foo", "foo"), false);
+test('array("one" => 1, "two" => 2))', array("one" => 1, "two" => 2), false);
+test('array("kek" => "lol", "lol" => "kek")', array("kek" => "lol", "lol" => "kek"), false);
+test('array("" => "empty")', array("" => "empty"), false);
+
+$a = array('foo');
+test('array($a, $a)', array($a, $a), false);
+test('array(&$a, &$a)', array(&$a, &$a), false);
+
+$a = array(null);
+$b = array(&$a);
+$a[0] = &$b;
+
+test('cyclic', $a, true);
+
+$a = array(
+ 'a' => array(
+ 'b' => 'c',
+ 'd' => 'e'
+ ),
+ 'f' => array(
+ 'g' => 'h'
+ )
+ );
+
+test('array', $a, false);
+
+class Obj {
+ public $a;
+ protected $b;
+ private $c;
+
+ function __construct($a, $b, $c) {
+ $this->a = $a;
+ $this->b = $b;
+ $this->c = $c;
+ }
+}
+
+test('object', new Obj(1, 2, 3), true);
+
+test('object', array(new Obj(1, 2, 3), new Obj(4, 5, 6)), true);
+
+$o = new Obj(1, 2, 3);
+
+test('object', array(&$o, &$o), true);
+--EXPECTF--
+NULL
+OK
+bool(true)
+OK
+bool(false)
+OK
+int(0)
+OK
+int(1)
+OK
+int(-1)
+OK
+int(1000)
+OK
+int(-1000)
+OK
+int(100000)
+OK
+int(-100000)
+OK
+float(123.456)
+OK
+string(0) ""
+OK
+string(6) "foobar"
+OK
+array(0) {
+}
+OK
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
+OK
+array(3) {
+ [0]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+ [1]=>
+ array(3) {
+ [0]=>
+ int(4)
+ [1]=>
+ int(5)
+ [2]=>
+ int(6)
+ }
+ [2]=>
+ array(3) {
+ [0]=>
+ int(7)
+ [1]=>
+ int(8)
+ [2]=>
+ int(9)
+ }
+}
+OK
+array(3) {
+ [0]=>
+ string(3) "foo"
+ [1]=>
+ string(3) "foo"
+ [2]=>
+ string(3) "foo"
+}
+OK
+array(2) {
+ ["one"]=>
+ int(1)
+ ["two"]=>
+ int(2)
+}
+OK
+array(2) {
+ ["kek"]=>
+ string(3) "lol"
+ ["lol"]=>
+ string(3) "kek"
+}
+OK
+array(1) {
+ [""]=>
+ string(5) "empty"
+}
+OK
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+}
+OK
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+}
+OK
+array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ NULL
+ }
+ }
+ }
+ }
+}
+OK
+array(2) {
+ ["a"]=>
+ array(2) {
+ ["b"]=>
+ string(1) "c"
+ ["d"]=>
+ string(1) "e"
+ }
+ ["f"]=>
+ array(1) {
+ ["g"]=>
+ string(1) "h"
+ }
+}
+OK
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
+OK
+array(2) {
+ [0]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+ [1]=>
+ array(3) {
+ [0]=>
+ int(4)
+ [1]=>
+ int(5)
+ [2]=>
+ int(6)
+ }
+}
+OK
+array(2) {
+ [0]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+ [1]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+}
+OK
diff --git a/php/tests/086.phpt b/php/tests/086.phpt
new file mode 100644
index 0000000..aeaa332
--- /dev/null
+++ b/php/tests/086.phpt
@@ -0,0 +1,345 @@
+--TEST--
+disabled php only for class unpacker (constract)
+--SKIPIF--
+--FILE--
+<?php
+if(!extension_loaded('msgpack')) {
+ dl('msgpack.' . PHP_SHLIB_SUFFIX);
+}
+
+function test($type, $variable, $test = null)
+{
+ $msgpack = new MessagePack(false);
+
+ $serialized = $msgpack->pack($variable);
+
+ $unpacker = new MessagePackUnpacker(false);
+
+ $length = strlen($serialized);
+
+ if (rand(0, 1))
+ {
+ for ($i = 0; $i < $length;)
+ {
+ $len = rand(1, 10);
+ $str = substr($serialized, $i, $len);
+
+ $unpacker->feed($str);
+ if ($unpacker->execute())
+ {
+ $unserialized = $unpacker->data();
+ var_dump($unserialized);
+ $unpacker->reset();
+ }
+
+ $i += $len;
+ }
+ }
+ else
+ {
+ $str = "";
+ $offset = 0;
+
+ for ($i = 0; $i < $length;)
+ {
+ $len = rand(1, 10);
+ $str .= substr($serialized, $i, $len);
+
+ if ($unpacker->execute($str, $offset))
+ {
+ $unserialized = $unpacker->data();
+ var_dump($unserialized);
+
+ $unpacker->reset();
+ $str = "";
+ $offset = 0;
+ }
+
+ $i += $len;
+ }
+ }
+
+ if (!is_bool($test))
+ {
+ echo $unserialized === $variable ? 'OK' : 'ERROR', PHP_EOL;
+ }
+ else
+ {
+ echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
+ }
+}
+
+test('null', null);
+
+test('boo:l true', true);
+test('bool: true', false);
+
+test('zero: 0', 0);
+test('small: 1', 1);
+test('small: -1', -1);
+test('medium: 1000', 1000);
+test('medium: -1000', -1000);
+test('large: 100000', 100000);
+test('large: -100000', -100000);
+
+test('double: 123.456', 123.456);
+
+test('empty: ""', "");
+test('string: "foobar"', "foobar");
+
+test('empty: array', array(), false);
+test('empty: array(1, 2, 3)', array(1, 2, 3), false);
+test('empty: array(array(1, 2, 3), arr...', array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9)), false);
+
+test('array("foo", "foo", "foo")', array("foo", "foo", "foo"), false);
+test('array("one" => 1, "two" => 2))', array("one" => 1, "two" => 2), false);
+test('array("kek" => "lol", "lol" => "kek")', array("kek" => "lol", "lol" => "kek"), false);
+test('array("" => "empty")', array("" => "empty"), false);
+
+$a = array('foo');
+test('array($a, $a)', array($a, $a), false);
+test('array(&$a, &$a)', array(&$a, &$a), false);
+
+$a = array(null);
+$b = array(&$a);
+$a[0] = &$b;
+
+test('cyclic', $a, true);
+
+$a = array(
+ 'a' => array(
+ 'b' => 'c',
+ 'd' => 'e'
+ ),
+ 'f' => array(
+ 'g' => 'h'
+ )
+ );
+
+test('array', $a, false);
+
+class Obj {
+ public $a;
+ protected $b;
+ private $c;
+
+ function __construct($a, $b, $c) {
+ $this->a = $a;
+ $this->b = $b;
+ $this->c = $c;
+ }
+}
+
+test('object', new Obj(1, 2, 3), true);
+
+test('object', array(new Obj(1, 2, 3), new Obj(4, 5, 6)), true);
+
+$o = new Obj(1, 2, 3);
+
+test('object', array(&$o, &$o), true);
+--EXPECTF--
+NULL
+OK
+bool(true)
+OK
+bool(false)
+OK
+int(0)
+OK
+int(1)
+OK
+int(-1)
+OK
+int(1000)
+OK
+int(-1000)
+OK
+int(100000)
+OK
+int(-100000)
+OK
+float(123.456)
+OK
+string(0) ""
+OK
+string(6) "foobar"
+OK
+array(0) {
+}
+OK
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
+OK
+array(3) {
+ [0]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+ [1]=>
+ array(3) {
+ [0]=>
+ int(4)
+ [1]=>
+ int(5)
+ [2]=>
+ int(6)
+ }
+ [2]=>
+ array(3) {
+ [0]=>
+ int(7)
+ [1]=>
+ int(8)
+ [2]=>
+ int(9)
+ }
+}
+OK
+array(3) {
+ [0]=>
+ string(3) "foo"
+ [1]=>
+ string(3) "foo"
+ [2]=>
+ string(3) "foo"
+}
+OK
+array(2) {
+ ["one"]=>
+ int(1)
+ ["two"]=>
+ int(2)
+}
+OK
+array(2) {
+ ["kek"]=>
+ string(3) "lol"
+ ["lol"]=>
+ string(3) "kek"
+}
+OK
+array(1) {
+ [""]=>
+ string(5) "empty"
+}
+OK
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+}
+OK
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+}
+OK
+array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ NULL
+ }
+ }
+ }
+ }
+}
+OK
+array(2) {
+ ["a"]=>
+ array(2) {
+ ["b"]=>
+ string(1) "c"
+ ["d"]=>
+ string(1) "e"
+ }
+ ["f"]=>
+ array(1) {
+ ["g"]=>
+ string(1) "h"
+ }
+}
+OK
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
+OK
+array(2) {
+ [0]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+ [1]=>
+ array(3) {
+ [0]=>
+ int(4)
+ [1]=>
+ int(5)
+ [2]=>
+ int(6)
+ }
+}
+OK
+array(2) {
+ [0]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+ [1]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+}
+OK
diff --git a/php/tests/087.phpt b/php/tests/087.phpt
new file mode 100644
index 0000000..9bb4e49
--- /dev/null
+++ b/php/tests/087.phpt
@@ -0,0 +1,302 @@
+--TEST--
+disabled php only for class methods (set option)
+--SKIPIF--
+--FILE--
+<?php
+if(!extension_loaded('msgpack')) {
+ dl('msgpack.' . PHP_SHLIB_SUFFIX);
+}
+
+function test($type, $variable, $test = null) {
+ $msgpack = new MessagePack();
+ $msgpack->setOption(MessagePack::OPT_PHPONLY, false);
+
+ $serialized = $msgpack->pack($variable);
+ $unserialized = $msgpack->unpack($serialized);
+
+ var_dump($unserialized);
+
+ if (!is_bool($test))
+ {
+ echo $unserialized === $variable ? 'OK' : 'ERROR', PHP_EOL;
+ }
+ else
+ {
+ echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
+ }
+}
+
+test('null', null);
+
+test('boo:l true', true);
+test('bool: true', false);
+
+test('zero: 0', 0);
+test('small: 1', 1);
+test('small: -1', -1);
+test('medium: 1000', 1000);
+test('medium: -1000', -1000);
+test('large: 100000', 100000);
+test('large: -100000', -100000);
+
+test('double: 123.456', 123.456);
+
+test('empty: ""', "");
+test('string: "foobar"', "foobar");
+
+test('empty: array', array(), false);
+test('empty: array(1, 2, 3)', array(1, 2, 3), false);
+test('empty: array(array(1, 2, 3), arr...', array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9)), false);
+
+test('array("foo", "foo", "foo")', array("foo", "foo", "foo"), false);
+test('array("one" => 1, "two" => 2))', array("one" => 1, "two" => 2), false);
+test('array("kek" => "lol", "lol" => "kek")', array("kek" => "lol", "lol" => "kek"), false);
+test('array("" => "empty")', array("" => "empty"), false);
+
+$a = array('foo');
+test('array($a, $a)', array($a, $a), false);
+test('array(&$a, &$a)', array(&$a, &$a), false);
+
+$a = array(null);
+$b = array(&$a);
+$a[0] = &$b;
+
+test('cyclic', $a, true);
+
+$a = array(
+ 'a' => array(
+ 'b' => 'c',
+ 'd' => 'e'
+ ),
+ 'f' => array(
+ 'g' => 'h'
+ )
+ );
+
+test('array', $a, false);
+
+class Obj {
+ public $a;
+ protected $b;
+ private $c;
+
+ function __construct($a, $b, $c) {
+ $this->a = $a;
+ $this->b = $b;
+ $this->c = $c;
+ }
+}
+
+test('object', new Obj(1, 2, 3), true);
+
+test('object', array(new Obj(1, 2, 3), new Obj(4, 5, 6)), true);
+
+$o = new Obj(1, 2, 3);
+
+test('object', array(&$o, &$o), true);
+--EXPECTF--
+NULL
+OK
+bool(true)
+OK
+bool(false)
+OK
+int(0)
+OK
+int(1)
+OK
+int(-1)
+OK
+int(1000)
+OK
+int(-1000)
+OK
+int(100000)
+OK
+int(-100000)
+OK
+float(123.456)
+OK
+string(0) ""
+OK
+string(6) "foobar"
+OK
+array(0) {
+}
+OK
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
+OK
+array(3) {
+ [0]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+ [1]=>
+ array(3) {
+ [0]=>
+ int(4)
+ [1]=>
+ int(5)
+ [2]=>
+ int(6)
+ }
+ [2]=>
+ array(3) {
+ [0]=>
+ int(7)
+ [1]=>
+ int(8)
+ [2]=>
+ int(9)
+ }
+}
+OK
+array(3) {
+ [0]=>
+ string(3) "foo"
+ [1]=>
+ string(3) "foo"
+ [2]=>
+ string(3) "foo"
+}
+OK
+array(2) {
+ ["one"]=>
+ int(1)
+ ["two"]=>
+ int(2)
+}
+OK
+array(2) {
+ ["kek"]=>
+ string(3) "lol"
+ ["lol"]=>
+ string(3) "kek"
+}
+OK
+array(1) {
+ [""]=>
+ string(5) "empty"
+}
+OK
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+}
+OK
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+}
+OK
+array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ NULL
+ }
+ }
+ }
+ }
+}
+OK
+array(2) {
+ ["a"]=>
+ array(2) {
+ ["b"]=>
+ string(1) "c"
+ ["d"]=>
+ string(1) "e"
+ }
+ ["f"]=>
+ array(1) {
+ ["g"]=>
+ string(1) "h"
+ }
+}
+OK
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
+OK
+array(2) {
+ [0]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+ [1]=>
+ array(3) {
+ [0]=>
+ int(4)
+ [1]=>
+ int(5)
+ [2]=>
+ int(6)
+ }
+}
+OK
+array(2) {
+ [0]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+ [1]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+}
+OK
diff --git a/php/tests/088.phpt b/php/tests/088.phpt
new file mode 100644
index 0000000..7cbabb9
--- /dev/null
+++ b/php/tests/088.phpt
@@ -0,0 +1,345 @@
+--TEST--
+disabled php only for class methods unpacker (set option)
+--SKIPIF--
+--FILE--
+<?php
+if(!extension_loaded('msgpack')) {
+ dl('msgpack.' . PHP_SHLIB_SUFFIX);
+}
+
+function test($type, $variable, $test = null)
+{
+ $msgpack = new MessagePack();
+ $msgpack->setOption(MessagePack::OPT_PHPONLY, false);
+
+ $serialized = $msgpack->pack($variable);
+ $unpacker = $msgpack->unpacker();
+
+ $length = strlen($serialized);
+
+ if (rand(0, 1))
+ {
+ for ($i = 0; $i < $length;)
+ {
+ $len = rand(1, 10);
+ $str = substr($serialized, $i, $len);
+
+ $unpacker->feed($str);
+ if ($unpacker->execute())
+ {
+ $unserialized = $unpacker->data();
+ var_dump($unserialized);
+ $unpacker->reset();
+ }
+
+ $i += $len;
+ }
+ }
+ else
+ {
+ $str = "";
+ $offset = 0;
+
+ for ($i = 0; $i < $length;)
+ {
+ $len = rand(1, 10);
+ $str .= substr($serialized, $i, $len);
+
+ if ($unpacker->execute($str, $offset))
+ {
+ $unserialized = $unpacker->data();
+ var_dump($unserialized);
+
+ $unpacker->reset();
+ $str = "";
+ $offset = 0;
+ }
+
+ $i += $len;
+ }
+ }
+
+ if (!is_bool($test))
+ {
+ echo $unserialized === $variable ? 'OK' : 'ERROR', PHP_EOL;
+ }
+ else
+ {
+ echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
+ }
+}
+
+test('null', null);
+
+test('boo:l true', true);
+test('bool: true', false);
+
+test('zero: 0', 0);
+test('small: 1', 1);
+test('small: -1', -1);
+test('medium: 1000', 1000);
+test('medium: -1000', -1000);
+test('large: 100000', 100000);
+test('large: -100000', -100000);
+
+test('double: 123.456', 123.456);
+
+test('empty: ""', "");
+test('string: "foobar"', "foobar");
+
+test('empty: array', array(), false);
+test('empty: array(1, 2, 3)', array(1, 2, 3), false);
+test('empty: array(array(1, 2, 3), arr...', array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9)), false);
+
+test('array("foo", "foo", "foo")', array("foo", "foo", "foo"), false);
+test('array("one" => 1, "two" => 2))', array("one" => 1, "two" => 2), false);
+test('array("kek" => "lol", "lol" => "kek")', array("kek" => "lol", "lol" => "kek"), false);
+test('array("" => "empty")', array("" => "empty"), false);
+
+$a = array('foo');
+test('array($a, $a)', array($a, $a), false);
+test('array(&$a, &$a)', array(&$a, &$a), false);
+
+$a = array(null);
+$b = array(&$a);
+$a[0] = &$b;
+
+test('cyclic', $a, true);
+
+$a = array(
+ 'a' => array(
+ 'b' => 'c',
+ 'd' => 'e'
+ ),
+ 'f' => array(
+ 'g' => 'h'
+ )
+ );
+
+test('array', $a, false);
+
+class Obj {
+ public $a;
+ protected $b;
+ private $c;
+
+ function __construct($a, $b, $c) {
+ $this->a = $a;
+ $this->b = $b;
+ $this->c = $c;
+ }
+}
+
+test('object', new Obj(1, 2, 3), true);
+
+test('object', array(new Obj(1, 2, 3), new Obj(4, 5, 6)), true);
+
+$o = new Obj(1, 2, 3);
+
+test('object', array(&$o, &$o), true);
+--EXPECTF--
+NULL
+OK
+bool(true)
+OK
+bool(false)
+OK
+int(0)
+OK
+int(1)
+OK
+int(-1)
+OK
+int(1000)
+OK
+int(-1000)
+OK
+int(100000)
+OK
+int(-100000)
+OK
+float(123.456)
+OK
+string(0) ""
+OK
+string(6) "foobar"
+OK
+array(0) {
+}
+OK
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
+OK
+array(3) {
+ [0]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+ [1]=>
+ array(3) {
+ [0]=>
+ int(4)
+ [1]=>
+ int(5)
+ [2]=>
+ int(6)
+ }
+ [2]=>
+ array(3) {
+ [0]=>
+ int(7)
+ [1]=>
+ int(8)
+ [2]=>
+ int(9)
+ }
+}
+OK
+array(3) {
+ [0]=>
+ string(3) "foo"
+ [1]=>
+ string(3) "foo"
+ [2]=>
+ string(3) "foo"
+}
+OK
+array(2) {
+ ["one"]=>
+ int(1)
+ ["two"]=>
+ int(2)
+}
+OK
+array(2) {
+ ["kek"]=>
+ string(3) "lol"
+ ["lol"]=>
+ string(3) "kek"
+}
+OK
+array(1) {
+ [""]=>
+ string(5) "empty"
+}
+OK
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+}
+OK
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+}
+OK
+array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ NULL
+ }
+ }
+ }
+ }
+}
+OK
+array(2) {
+ ["a"]=>
+ array(2) {
+ ["b"]=>
+ string(1) "c"
+ ["d"]=>
+ string(1) "e"
+ }
+ ["f"]=>
+ array(1) {
+ ["g"]=>
+ string(1) "h"
+ }
+}
+OK
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
+OK
+array(2) {
+ [0]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+ [1]=>
+ array(3) {
+ [0]=>
+ int(4)
+ [1]=>
+ int(5)
+ [2]=>
+ int(6)
+ }
+}
+OK
+array(2) {
+ [0]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+ [1]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+}
+OK
diff --git a/php/tests/089.phpt b/php/tests/089.phpt
new file mode 100644
index 0000000..f3a0537
--- /dev/null
+++ b/php/tests/089.phpt
@@ -0,0 +1,347 @@
+--TEST--
+disabled php only for class unpacker (set option)
+--SKIPIF--
+--FILE--
+<?php
+if(!extension_loaded('msgpack')) {
+ dl('msgpack.' . PHP_SHLIB_SUFFIX);
+}
+
+function test($type, $variable, $test = null)
+{
+ $msgpack = new MessagePack();
+ $msgpack->setOption(MessagePack::OPT_PHPONLY, false);
+
+ $serialized = $msgpack->pack($variable);
+
+ $unpacker = new MessagePackUnpacker();
+ $unpacker->setOption(MessagePack::OPT_PHPONLY, false);
+
+ $length = strlen($serialized);
+
+ if (rand(0, 1))
+ {
+ for ($i = 0; $i < $length;)
+ {
+ $len = rand(1, 10);
+ $str = substr($serialized, $i, $len);
+
+ $unpacker->feed($str);
+ if ($unpacker->execute())
+ {
+ $unserialized = $unpacker->data();
+ var_dump($unserialized);
+ $unpacker->reset();
+ }
+
+ $i += $len;
+ }
+ }
+ else
+ {
+ $str = "";
+ $offset = 0;
+
+ for ($i = 0; $i < $length;)
+ {
+ $len = rand(1, 10);
+ $str .= substr($serialized, $i, $len);
+
+ if ($unpacker->execute($str, $offset))
+ {
+ $unserialized = $unpacker->data();
+ var_dump($unserialized);
+
+ $unpacker->reset();
+ $str = "";
+ $offset = 0;
+ }
+
+ $i += $len;
+ }
+ }
+
+ if (!is_bool($test))
+ {
+ echo $unserialized === $variable ? 'OK' : 'ERROR', PHP_EOL;
+ }
+ else
+ {
+ echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
+ }
+}
+
+test('null', null);
+
+test('boo:l true', true);
+test('bool: true', false);
+
+test('zero: 0', 0);
+test('small: 1', 1);
+test('small: -1', -1);
+test('medium: 1000', 1000);
+test('medium: -1000', -1000);
+test('large: 100000', 100000);
+test('large: -100000', -100000);
+
+test('double: 123.456', 123.456);
+
+test('empty: ""', "");
+test('string: "foobar"', "foobar");
+
+test('empty: array', array(), false);
+test('empty: array(1, 2, 3)', array(1, 2, 3), false);
+test('empty: array(array(1, 2, 3), arr...', array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9)), false);
+
+test('array("foo", "foo", "foo")', array("foo", "foo", "foo"), false);
+test('array("one" => 1, "two" => 2))', array("one" => 1, "two" => 2), false);
+test('array("kek" => "lol", "lol" => "kek")', array("kek" => "lol", "lol" => "kek"), false);
+test('array("" => "empty")', array("" => "empty"), false);
+
+$a = array('foo');
+test('array($a, $a)', array($a, $a), false);
+test('array(&$a, &$a)', array(&$a, &$a), false);
+
+$a = array(null);
+$b = array(&$a);
+$a[0] = &$b;
+
+test('cyclic', $a, true);
+
+$a = array(
+ 'a' => array(
+ 'b' => 'c',
+ 'd' => 'e'
+ ),
+ 'f' => array(
+ 'g' => 'h'
+ )
+ );
+
+test('array', $a, false);
+
+class Obj {
+ public $a;
+ protected $b;
+ private $c;
+
+ function __construct($a, $b, $c) {
+ $this->a = $a;
+ $this->b = $b;
+ $this->c = $c;
+ }
+}
+
+test('object', new Obj(1, 2, 3), true);
+
+test('object', array(new Obj(1, 2, 3), new Obj(4, 5, 6)), true);
+
+$o = new Obj(1, 2, 3);
+
+test('object', array(&$o, &$o), true);
+--EXPECTF--
+NULL
+OK
+bool(true)
+OK
+bool(false)
+OK
+int(0)
+OK
+int(1)
+OK
+int(-1)
+OK
+int(1000)
+OK
+int(-1000)
+OK
+int(100000)
+OK
+int(-100000)
+OK
+float(123.456)
+OK
+string(0) ""
+OK
+string(6) "foobar"
+OK
+array(0) {
+}
+OK
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
+OK
+array(3) {
+ [0]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+ [1]=>
+ array(3) {
+ [0]=>
+ int(4)
+ [1]=>
+ int(5)
+ [2]=>
+ int(6)
+ }
+ [2]=>
+ array(3) {
+ [0]=>
+ int(7)
+ [1]=>
+ int(8)
+ [2]=>
+ int(9)
+ }
+}
+OK
+array(3) {
+ [0]=>
+ string(3) "foo"
+ [1]=>
+ string(3) "foo"
+ [2]=>
+ string(3) "foo"
+}
+OK
+array(2) {
+ ["one"]=>
+ int(1)
+ ["two"]=>
+ int(2)
+}
+OK
+array(2) {
+ ["kek"]=>
+ string(3) "lol"
+ ["lol"]=>
+ string(3) "kek"
+}
+OK
+array(1) {
+ [""]=>
+ string(5) "empty"
+}
+OK
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+}
+OK
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(3) "foo"
+ }
+}
+OK
+array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ NULL
+ }
+ }
+ }
+ }
+}
+OK
+array(2) {
+ ["a"]=>
+ array(2) {
+ ["b"]=>
+ string(1) "c"
+ ["d"]=>
+ string(1) "e"
+ }
+ ["f"]=>
+ array(1) {
+ ["g"]=>
+ string(1) "h"
+ }
+}
+OK
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
+OK
+array(2) {
+ [0]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+ [1]=>
+ array(3) {
+ [0]=>
+ int(4)
+ [1]=>
+ int(5)
+ [2]=>
+ int(6)
+ }
+}
+OK
+array(2) {
+ [0]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+ [1]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+}
+OK