Permalink
Browse files

Add test cases for HackArrDVArrs

Summary:
Add test cases for the HackArrDVArrs option. These test cases are cloned from
the normal d/varray test cases (with a few low value omissions), with
HackArrDVArrs enabled, and the expect files modified as needed.

Reviewed By: paulbiss

Differential Revision: D6970274

fbshipit-source-id: b95de146631c319118fa3b5141e0d914ed5f941f
  • Loading branch information...
ricklavoie authored and hhvm-bot committed Feb 15, 2018
1 parent 68269b3 commit 9f9d44f59287abcd5fa2a0e422e52e0b279072e6
Showing with 10,990 additions and 1 deletion.
  1. +1 −1 hphp/test/slow/dv_array/hhbbc4.php
  2. +55 −0 hphp/test/slow/dv_array/xhp.php
  3. +153 −0 hphp/test/slow/dv_array/xhp.php.expect
  4. +86 −0 hphp/test/slow/dv_array_hack_arr/apc.inc
  5. +4 −0 hphp/test/slow/dv_array_hack_arr/apc1.php
  6. +1 −0 hphp/test/slow/dv_array_hack_arr/apc1.php.expect
  7. +1 −0 hphp/test/slow/dv_array_hack_arr/apc1.php.hphp_opts
  8. +2 −0 hphp/test/slow/dv_array_hack_arr/apc1.php.opts
  9. +4 −0 hphp/test/slow/dv_array_hack_arr/apc2.php
  10. +1 −0 hphp/test/slow/dv_array_hack_arr/apc2.php.expect
  11. +1 −0 hphp/test/slow/dv_array_hack_arr/apc2.php.hphp_opts
  12. +3 −0 hphp/test/slow/dv_array_hack_arr/apc2.php.opts
  13. +7 −0 hphp/test/slow/dv_array_hack_arr/arr_to_varray_cast.php
  14. +5 −0 hphp/test/slow/dv_array_hack_arr/arr_to_varray_cast.php.expect
  15. +1 −0 hphp/test/slow/dv_array_hack_arr/arr_to_varray_cast.php.hphp_opts
  16. +1 −0 hphp/test/slow/dv_array_hack_arr/arr_to_varray_cast.php.opts
  17. +39 −0 hphp/test/slow/dv_array_hack_arr/array_merge.php
  18. +4,762 −0 hphp/test/slow/dv_array_hack_arr/array_merge.php.expect
  19. +1 −0 hphp/test/slow/dv_array_hack_arr/array_merge.php.hphp_opts
  20. +1 −0 hphp/test/slow/dv_array_hack_arr/array_merge.php.opts
  21. +55 −0 hphp/test/slow/dv_array_hack_arr/basic-parsing.php
  22. 0 hphp/test/slow/dv_array_hack_arr/basic-parsing.php.expect
  23. +1 −0 hphp/test/slow/dv_array_hack_arr/basic-parsing.php.hphp_opts
  24. +1 −0 hphp/test/slow/dv_array_hack_arr/basic-parsing.php.opts
  25. +65 −0 hphp/test/slow/dv_array_hack_arr/builtin-annotations.php
  26. +70 −0 hphp/test/slow/dv_array_hack_arr/builtin-annotations.php.expectf
  27. +1 −0 hphp/test/slow/dv_array_hack_arr/builtin-annotations.php.hphp_opts
  28. +1 −0 hphp/test/slow/dv_array_hack_arr/builtin-annotations.php.opts
  29. +33 −0 hphp/test/slow/dv_array_hack_arr/constants.php
  30. +47 −0 hphp/test/slow/dv_array_hack_arr/constants.php.expect
  31. +1 −0 hphp/test/slow/dv_array_hack_arr/constants.php.hphp_opts
  32. +1 −0 hphp/test/slow/dv_array_hack_arr/constants.php.opts
  33. +160 −0 hphp/test/slow/dv_array_hack_arr/convert.php
  34. +842 −0 hphp/test/slow/dv_array_hack_arr/convert.php.expectf
  35. +1 −0 hphp/test/slow/dv_array_hack_arr/convert.php.hphp_opts
  36. +1 −0 hphp/test/slow/dv_array_hack_arr/convert.php.opts
  37. +9 −0 hphp/test/slow/dv_array_hack_arr/cuf-safe-array.php
  38. +6 −0 hphp/test/slow/dv_array_hack_arr/cuf-safe-array.php.expect
  39. +1 −0 hphp/test/slow/dv_array_hack_arr/cuf-safe-array.php.hphp_opts
  40. +1 −0 hphp/test/slow/dv_array_hack_arr/cuf-safe-array.php.opts
  41. +83 −0 hphp/test/slow/dv_array_hack_arr/enums.php
  42. +126 −0 hphp/test/slow/dv_array_hack_arr/enums.php.expect
  43. +1 −0 hphp/test/slow/dv_array_hack_arr/enums.php.hphp_opts
  44. +1 −0 hphp/test/slow/dv_array_hack_arr/enums.php.opts
  45. +55 −0 hphp/test/slow/dv_array_hack_arr/genva.php
  46. +30 −0 hphp/test/slow/dv_array_hack_arr/genva.php.expect
  47. +1 −0 hphp/test/slow/dv_array_hack_arr/genva.php.hphp_opts
  48. +2 −0 hphp/test/slow/dv_array_hack_arr/genva.php.opts
  49. +85 −0 hphp/test/slow/dv_array_hack_arr/giant.php
  50. +15 −0 hphp/test/slow/dv_array_hack_arr/giant.php.expect
  51. +1 −0 hphp/test/slow/dv_array_hack_arr/giant.php.hphp_opts
  52. +1 −0 hphp/test/slow/dv_array_hack_arr/giant.php.opts
  53. +30 −0 hphp/test/slow/dv_array_hack_arr/hhbbc1.php
  54. +7 −0 hphp/test/slow/dv_array_hack_arr/hhbbc1.php.expect
  55. +1 −0 hphp/test/slow/dv_array_hack_arr/hhbbc1.php.hphp_opts
  56. +1 −0 hphp/test/slow/dv_array_hack_arr/hhbbc1.php.opts
  57. +20 −0 hphp/test/slow/dv_array_hack_arr/hhbbc2.php
  58. +1 −0 hphp/test/slow/dv_array_hack_arr/hhbbc2.php.expect
  59. +1 −0 hphp/test/slow/dv_array_hack_arr/hhbbc2.php.hphp_opts
  60. +1 −0 hphp/test/slow/dv_array_hack_arr/hhbbc2.php.opts
  61. +24 −0 hphp/test/slow/dv_array_hack_arr/hhbbc3.php
  62. +14 −0 hphp/test/slow/dv_array_hack_arr/hhbbc3.php.expect
  63. +1 −0 hphp/test/slow/dv_array_hack_arr/hhbbc3.php.hphp_opts
  64. +1 −0 hphp/test/slow/dv_array_hack_arr/hhbbc3.php.opts
  65. +17 −0 hphp/test/slow/dv_array_hack_arr/hhbbc4.php
  66. +12 −0 hphp/test/slow/dv_array_hack_arr/hhbbc4.php.expect
  67. +1 −0 hphp/test/slow/dv_array_hack_arr/hhbbc4.php.hphp_opts
  68. +1 −0 hphp/test/slow/dv_array_hack_arr/hhbbc4.php.opts
  69. +211 −0 hphp/test/slow/dv_array_hack_arr/is-a.php
  70. +783 −0 hphp/test/slow/dv_array_hack_arr/is-a.php.expect
  71. +1 −0 hphp/test/slow/dv_array_hack_arr/is-a.php.hphp_opts
  72. +1 −0 hphp/test/slow/dv_array_hack_arr/is-a.php.opts
  73. +41 −0 hphp/test/slow/dv_array_hack_arr/literal.php
  74. +149 −0 hphp/test/slow/dv_array_hack_arr/literal.php.expect
  75. +1 −0 hphp/test/slow/dv_array_hack_arr/literal.php.hphp_opts
  76. +1 −0 hphp/test/slow/dv_array_hack_arr/literal.php.opts
  77. +7 −0 hphp/test/slow/dv_array_hack_arr/nested_in_container.php
  78. +10 −0 hphp/test/slow/dv_array_hack_arr/nested_in_container.php.expect
  79. +1 −0 hphp/test/slow/dv_array_hack_arr/nested_in_container.php.hphp_opts
  80. +1 −0 hphp/test/slow/dv_array_hack_arr/nested_in_container.php.opts
  81. +128 −0 hphp/test/slow/dv_array_hack_arr/serialize.php
  82. +728 −0 hphp/test/slow/dv_array_hack_arr/serialize.php.expect
  83. +1 −0 hphp/test/slow/dv_array_hack_arr/serialize.php.hphp_opts
  84. +1 −0 hphp/test/slow/dv_array_hack_arr/serialize.php.opts
  85. +38 −0 hphp/test/slow/dv_array_hack_arr/shapes.php
  86. +24 −0 hphp/test/slow/dv_array_hack_arr/shapes.php.expect
  87. +1 −0 hphp/test/slow/dv_array_hack_arr/shapes.php.hphp_opts
  88. +1 −0 hphp/test/slow/dv_array_hack_arr/shapes.php.opts
  89. +196 −0 hphp/test/slow/dv_array_hack_arr/type-hint.php
  90. +992 −0 hphp/test/slow/dv_array_hack_arr/type-hint.php.expect
  91. +1 −0 hphp/test/slow/dv_array_hack_arr/type-hint.php.hphp_opts
  92. +1 −0 hphp/test/slow/dv_array_hack_arr/type-hint.php.opts
  93. +69 −0 hphp/test/slow/dv_array_hack_arr/type-structure.php
  94. +14 −0 hphp/test/slow/dv_array_hack_arr/type-structure.php.expect
  95. +1 −0 hphp/test/slow/dv_array_hack_arr/type-structure.php.hphp_opts
  96. +1 −0 hphp/test/slow/dv_array_hack_arr/type-structure.php.opts
  97. +45 −0 hphp/test/slow/dv_array_hack_arr/variadics.php
  98. +413 −0 hphp/test/slow/dv_array_hack_arr/variadics.php.expect
  99. +1 −0 hphp/test/slow/dv_array_hack_arr/variadics.php.hphp_opts
  100. +1 −0 hphp/test/slow/dv_array_hack_arr/variadics.php.opts
  101. +55 −0 hphp/test/slow/dv_array_hack_arr/xhp.php
  102. +109 −0 hphp/test/slow/dv_array_hack_arr/xhp.php.expect
  103. +1 −0 hphp/test/slow/dv_array_hack_arr/xhp.php.hphp_opts
  104. +1 −0 hphp/test/slow/dv_array_hack_arr/xhp.php.opts
@@ -6,7 +6,7 @@ private static function get(): varray<string> {
return varray['SP', 'PP', 'SP2', 'PP2', 'I'];
}
public async function gen(): Awaitable<array> {
public async function gen(): Awaitable<darray> {
$x = darray[];
foreach (self::get() as $t) $x[$t] = 'N/A';
return $x;
@@ -0,0 +1,55 @@
<?hh
abstract class :base {
// This is necessary because the generated __xhpAttributeDeclaration() has a
// call to parent::__xhpAttributeDeclaration().
protected static function __xhpAttributeDeclaration() {
return darray[];
}
public static function xhpAttributeDeclaration() {
return static::__xhpAttributeDeclaration();
}
}
class :node1 extends :base {
attribute
mixed checkme;
}
class :node2 extends :base {
attribute
Exception e,
mixed checkme;
}
class :node3 extends :base {
attribute
int num,
mixed checkme,
var beans,
string cheese;
}
class :node4 extends :base {
attribute
int num = 2,
mixed checkme,
var beans,
string cheese = "hi";
}
function test($x) {
echo "====================================================\n";
var_dump($x);
var_dump(is_array($x));
var_dump(is_varray($x));
var_dump(is_darray($x));
var_dump(is_vec($x));
var_dump(is_dict($x));
}
test(:node1::xhpAttributeDeclaration());
test(:node2::xhpAttributeDeclaration());
test(:node3::xhpAttributeDeclaration());
test(:node4::xhpAttributeDeclaration());
@@ -0,0 +1,153 @@
====================================================
array(1) {
["checkme"]=>
array(4) {
[0]=>
int(6)
[1]=>
NULL
[2]=>
NULL
[3]=>
int(0)
}
}
bool(true)
bool(false)
bool(true)
bool(false)
bool(false)
====================================================
array(2) {
["e"]=>
array(4) {
[0]=>
int(5)
[1]=>
string(9) "Exception"
[2]=>
NULL
[3]=>
int(0)
}
["checkme"]=>
array(4) {
[0]=>
int(6)
[1]=>
NULL
[2]=>
NULL
[3]=>
int(0)
}
}
bool(true)
bool(false)
bool(true)
bool(false)
bool(false)
====================================================
array(4) {
["num"]=>
array(4) {
[0]=>
int(3)
[1]=>
NULL
[2]=>
NULL
[3]=>
int(0)
}
["checkme"]=>
array(4) {
[0]=>
int(6)
[1]=>
NULL
[2]=>
NULL
[3]=>
int(0)
}
["beans"]=>
array(4) {
[0]=>
int(6)
[1]=>
NULL
[2]=>
NULL
[3]=>
int(0)
}
["cheese"]=>
array(4) {
[0]=>
int(1)
[1]=>
NULL
[2]=>
NULL
[3]=>
int(0)
}
}
bool(true)
bool(false)
bool(true)
bool(false)
bool(false)
====================================================
array(4) {
["num"]=>
array(4) {
[0]=>
int(3)
[1]=>
NULL
[2]=>
int(2)
[3]=>
int(0)
}
["checkme"]=>
array(4) {
[0]=>
int(6)
[1]=>
NULL
[2]=>
NULL
[3]=>
int(0)
}
["beans"]=>
array(4) {
[0]=>
int(6)
[1]=>
NULL
[2]=>
NULL
[3]=>
int(0)
}
["cheese"]=>
array(4) {
[0]=>
int(1)
[1]=>
NULL
[2]=>
string(2) "hi"
[3]=>
int(0)
}
}
bool(true)
bool(false)
bool(true)
bool(false)
bool(false)
@@ -0,0 +1,86 @@
<?hh
// Copyright 2004-present Facebook. All Rights Reserved.
function fail($a, $a2) {
echo "=========== Comparison Failure ==========\n";
var_dump($a);
var_dump(is_varray($a));
var_dump(is_darray($a));
var_dump(is_array($a));
var_dump(is_vec($a));
var_dump(is_dict($a));
var_dump($a2);
var_dump(is_varray($a2));
var_dump(is_darray($a2));
var_dump(is_array($a2));
var_dump(is_vec($a2));
var_dump(is_dict($a2));
}
function get($key, $a) {
$a2 = apc_fetch($key);
if ($a2 === false) {
echo "=============== Error fetching $key ==============\n";
return;
}
if ($a !== $a2) {
if (count($a) != count($a2) ||
count($a) == 0 ||
!is_object($a[0]) ||
!is_object($a2[0])) {
return fail($a, $a2);
}
}
if (is_varray($a) !== is_varray($a2)) return fail($a, $a2);
if (is_darray($a) !== is_darray($a2)) return fail($a, $a2);
if (is_array($a) !== is_array($a2)) return fail($a, $a2);
if (is_vec($a) !== is_vec($a2)) return fail($a, $a2);
if (is_dict($a) !== is_dict($a2)) return fail($a, $a2);
}
function set_all($values) {
foreach ($values as $k => $v) apc_store($k, $v);
}
function get_all($values) {
foreach ($values as $k => $v) get($k, $v);
}
function launder($v) { return __hhvm_intrinsics\launder_value($v); }
function make_circular_varray() {
$x = new stdclass;
$v = varray[$x];
$x->foo = $v;
return $v;
}
function make_circular_darray() {
$x = new stdclass;
$d = darray[0 => $x];
$x->foo = $d;
return $d;
}
$values = dict[
'varray1' => varray[],
'varray2' => varray[1, 2, 3],
'varray3' => varray['a', 'b', 'c'],
'varray4' => varray[launder(7), launder(8), launder(9)],
'varray5' => make_circular_varray(),
'darray1' => darray[],
'darray2' => darray[0 => 'a', 1 => 'b', 2 => 'c'],
'darray3' => darray['a' => 100, 'b' => 200],
'darray4' => darray[0 => launder('x'), 1 => launder('y'), 2 => launder('z')],
'darray5' => darray[launder('j') => 11, launder('k') => 222],
'darray6' => make_circular_darray()
];
if (apc_fetch('second-time') === false) {
set_all($values);
apc_store('second-time', true);
} else {
get_all($values);
echo "============ DONE ================\n";
}
@@ -0,0 +1,4 @@
<?hh
// Copyright 2004-present Facebook. All Rights Reserved.
include 'apc.inc';
@@ -0,0 +1 @@
============ DONE ================
@@ -0,0 +1 @@
-vHackArrDVArrs=1
@@ -0,0 +1,2 @@
-vEval.HackArrDVArrs=true
--count=2
@@ -0,0 +1,4 @@
<?hh
// Copyright 2004-present Facebook. All Rights Reserved.
include 'apc.inc';
@@ -0,0 +1 @@
============ DONE ================
@@ -0,0 +1 @@
-vHackArrDVArrs=1
@@ -0,0 +1,3 @@
-vServer.APC.MemModelTreadmill=true
-vEval.HackArrDVArrs=true
--count=2
@@ -0,0 +1,7 @@
<?hh
// Copyright 2004-present Facebook. All Rights Reserved.
function test(array $a) { return varray($a); }
$a = ['a' => 1, 'b' => 2, 'c' => 3];
var_dump(test(__hhvm_intrinsics\launder_value($a)));
@@ -0,0 +1,5 @@
vec(3) {
int(1)
int(2)
int(3)
}
@@ -0,0 +1 @@
-vEval.HackArrDVArrs=true
@@ -0,0 +1,39 @@
<?hh
// Copyright 2004-present Facebook. All Rights Reserved.
function test($a, $b) {
echo "====================================================\n";
var_dump($a);
var_dump($b);
$x = array_merge($a, $b);
var_dump($x);
var_dump(is_array($x));
var_dump(is_varray($x));
var_dump(is_darray($x));
}
function test_all() {
$vals = vec[
[],
['a', 'b', 'c'],
[10 => 'a', 20 => 'b', 30 => 'c'],
['a' => 123, 'b' => 456, 'c' => 789],
varray[],
varray['a', 'b', 'c'],
darray[],
darray[10 => 'a', 20 => 'b', 30 => 'c'],
darray['a' => 123, 'b' => 456, 'c' => 789],
vec[],
vec['a', 'b', 'c'],
dict[],
dict[10 => 'a', 20 => 'b', 30 => 'c'],
dict['a' => 123, 'b' => 456, 'c' => 789]
];
foreach ($vals as $v1) {
foreach ($vals as $v2) {
test($v1, $v2);
}
}
}
test_all();
Oops, something went wrong.

0 comments on commit 9f9d44f

Please sign in to comment.