File: issue083.phpt

package info (click to toggle)
php-msgpack 1%3A2.2.0~rc2-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,200 kB
  • sloc: ansic: 3,817; xml: 416; makefile: 2
file content (41 lines) | stat: -rw-r--r-- 512 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
--TEST--
Issue #83 (Arrays and negative index)
--SKIPIF--
<?php
if (!extension_loaded("msgpack")) {
    die("skip");
}
?>
--FILE--
<?php

var_dump(msgpack_unpack(msgpack_pack([-1=>-1,1=>1])));

$a = [
    -1 => -1,
    0,
    1 => 1,
    2
];
// next free element == 3 and count() == 3, but it's still not an MP array
unset($a[1]);
var_dump(msgpack_unpack(msgpack_pack($a)));

?>
OK
--EXPECT--
array(2) {
  [-1]=>
  int(-1)
  [1]=>
  int(1)
}
array(3) {
  [-1]=>
  int(-1)
  [0]=>
  int(0)
  [2]=>
  int(2)
}
OK