Updating submodules
[hiphop-php.git] / hphp / test / slow / ext_array / array_intersect_key_coercion.php
blobb8efb5b53b17d394ef793071df4eb4fd38f432d1
1 <?hh
3 function nextBit(inout int $x): bool {
4 $ret = (bool)($x & 1);
5 $x >>= 1;
6 return $ret;
9 function testOne(int $case): void {
10 $left = nextBit(inout $case) ? Map{} : dict[];
11 $right = nextBit(inout $case) ? Map{} : dict[];
12 if (nextBit(inout $case)) $left['a'] = 'a';
13 if (nextBit(inout $case)) $left[1] = 'i';
14 if (nextBit(inout $case)) $left['1'] = 's';
15 if (nextBit(inout $case)) $right['a'] = 'x';
16 if (nextBit(inout $case)) $right[1] = 'y';
17 if (nextBit(inout $case)) $right['1'] = 'z';
19 // skip boring cases
20 if (count($left) === 0 || count($right) === 0) return;
22 $res = array_intersect_key($left, $right);
23 echo
24 $left is Map<_> ? 'm' : 'd',
25 isset($left['a']) ? 'a' : ' ',
26 isset($left[1]) ? 'i' : ' ',
27 isset($left['1']) ? 's' : ' ',
28 ' + ',
29 $right is Map<_> ? 'm' : 'd',
30 isset($right['a']) ? 'a' : ' ',
31 isset($right[1]) ? 'i' : ' ',
32 isset($right['1']) ? 's' : ' ',
33 ' = \'',
34 $res['a'] ?? ' ',
35 $res[1] ?? ' ',
36 $res['1'] ?? ' ',
37 "'\n";
40 <<__EntryPoint>>
41 function main(): void {
42 for ($i = 0; $i < 256; $i++) testOne($i);