Handle this typehints
[hiphop-php.git] / hphp / test / quick / continuation_serialize.php
blob8e5a6931e1f5fc1eedad515afe6d95758b012254
1 <?hh
4 async function static_result_create($result) {
5 return $result;
8 async function static_exception_create($exception) {
9 throw $exception;
12 function main() {
13 // Make new wait handles with valid values.
14 $srwh = static_result_create(42);
15 $r = HH\Asio\join($srwh);
16 var_dump($r); // Shows 42 correctly.
18 $sewh = static_exception_create(new Exception("Hi!"));
19 try {
20 $r = HH\Asio\join($sewh);
21 } catch (Exception $e) {
22 var_dump($e->getMessage()); // Shows "Hi!" correctly.
25 // Serialize the handles and let them go.
26 $s1 = serialize($srwh);
27 $s2 = serialize($sewh);
28 var_dump($s1);
29 var_dump($s2);
30 $srwh = null;
31 $erwh = null;
33 // Deserialize the handles in the reverse order, so they lay over
34 // each other's memory. We want to confirm that all fields are
35 // initialized correctly and that the destructor does not segfault.
36 $sewh = unserialize($s2);
37 var_dump($sewh);
38 $sewh = null; // Let it go
39 $srwh = unserialize($s1);
40 var_dump($srwh);
41 $srwh = null; // Let it go
43 // Confirm that we can't deserialize one of these as well.
44 $c1 = unserialize("O:9:\"Generator\":0:{}");
45 var_dump($c1);
48 main();