Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
1 parent
68269b3
commit 9f9d44f
Showing
104 changed files
with
10,990 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?hh | ||
// Copyright 2004-present Facebook. All Rights Reserved. | ||
|
||
include 'apc.inc'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
============ DONE ================ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
-vHackArrDVArrs=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-vEval.HackArrDVArrs=true | ||
--count=2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?hh | ||
// Copyright 2004-present Facebook. All Rights Reserved. | ||
|
||
include 'apc.inc'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
============ DONE ================ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
-vHackArrDVArrs=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
-vServer.APC.MemModelTreadmill=true | ||
-vEval.HackArrDVArrs=true | ||
--count=2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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))); |
5 changes: 5 additions & 0 deletions
5
hphp/test/slow/dv_array_hack_arr/arr_to_varray_cast.php.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
vec(3) { | ||
int(1) | ||
int(2) | ||
int(3) | ||
} |
1 change: 1 addition & 0 deletions
1
hphp/test/slow/dv_array_hack_arr/arr_to_varray_cast.php.hphp_opts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
-vHackArrDVArrs=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
-vEval.HackArrDVArrs=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.