1--TEST--
2WeakMap error conditions
3--FILE--
4<?php
5
6$map = new WeakMap;
7try {
8    $map[1] = 2;
9} catch (TypeError $e) {
10    echo $e->getMessage(), "\n";
11}
12try {
13    var_dump($map[1]);
14} catch (TypeError $e) {
15    echo $e->getMessage(), "\n";
16}
17try {
18    isset($map[1]);
19} catch (TypeError $e) {
20    echo $e->getMessage(), "\n";
21}
22try {
23    unset($map[1]);
24} catch (TypeError $e) {
25    echo $e->getMessage(), "\n";
26}
27
28try {
29    $map[] = 1;
30} catch (Error $e) {
31    echo $e->getMessage(), "\n";
32}
33try {
34    $map[][1] = 1;
35} catch (Error $e) {
36    echo $e->getMessage(), "\n";
37}
38try {
39    var_dump($map[new stdClass]);
40} catch (Error $e) {
41    echo $e->getMessage(), "\n";
42}
43
44var_dump($map->prop);
45var_dump(isset($map->prop));
46unset($map->prop);
47
48try {
49    $map->prop = 1;
50} catch (Error $e) {
51    echo $e->getMessage(), "\n";
52}
53try {
54    $map->prop[] = 1;
55} catch (Error $e) {
56    echo $e->getMessage(), "\n";
57}
58try {
59    $r =& $map->prop;
60} catch (Error $e) {
61    echo $e->getMessage(), "\n";
62}
63
64try {
65    serialize($map);
66} catch (Exception $e) {
67    echo $e->getMessage(), "\n";
68}
69try {
70    unserialize('C:7:"WeakMap":0:{}');
71} catch (Exception $e) {
72    echo $e->getMessage(), "\n";
73}
74
75?>
76--EXPECTF--
77WeakMap key must be an object
78WeakMap key must be an object
79WeakMap key must be an object
80WeakMap key must be an object
81Cannot append to WeakMap
82Cannot append to WeakMap
83Object stdClass#2 not contained in WeakMap
84
85Warning: Undefined property: WeakMap::$prop in %s on line %d
86NULL
87bool(false)
88Cannot create dynamic property WeakMap::$prop
89Cannot create dynamic property WeakMap::$prop
90Cannot create dynamic property WeakMap::$prop
91Serialization of 'WeakMap' is not allowed
92Unserialization of 'WeakMap' is not allowed
93