From 73a2e7eb9a63da3fc0303fe231d2b94170e3e293 Mon Sep 17 00:00:00 2001 From: Paul Cavallaro Date: Fri, 18 Jul 2014 19:24:14 -0700 Subject: [PATCH] Add intmap tests for warnings Reviewed By: andrewparoski, eletuchy Differential Revision: D1435641 --- hphp/runtime/base/mixed-array.cpp | 53 +++++---------- hphp/runtime/vm/jit/minstr-translator.cpp | 3 +- .../intmap_array/IntMap_addNumericStringKey.php | 26 ++++++++ .../IntMap_addNumericStringKey.php.expectf | 25 +++++++ hphp/test/slow/intmap_array/IntMap_addString.php | 16 +++++ .../slow/intmap_array/IntMap_addString.php.expectf | 13 ++++ hphp/test/slow/intmap_array/IntMap_append.php | 10 +++ .../slow/intmap_array/IntMap_append.php.expectf | 7 ++ hphp/test/slow/intmap_array/IntMap_appendRef.php | 15 +++++ .../slow/intmap_array/IntMap_appendRef.php.expectf | 27 ++++++++ .../slow/intmap_array/IntMap_array_diff_key.php | 15 +++++ .../intmap_array/IntMap_array_diff_key.php.expectf | 16 +++++ hphp/test/slow/intmap_array/IntMap_array_map.php | 13 ++++ .../slow/intmap_array/IntMap_array_map.php.expectf | 12 ++++ hphp/test/slow/intmap_array/IntMap_array_merge.php | 16 +++++ .../intmap_array/IntMap_array_merge.php.expectf | 34 ++++++++++ hphp/test/slow/intmap_array/IntMap_array_shift.php | 9 +++ .../intmap_array/IntMap_array_shift.php.expectf | 2 + .../slow/intmap_array/IntMap_array_unshift.php | 8 +++ .../intmap_array/IntMap_array_unshift.php.expectf | 1 + hphp/test/slow/intmap_array/IntMap_asort.php | 12 ++++ .../slow/intmap_array/IntMap_asort.php.expectf | 12 ++++ hphp/test/slow/intmap_array/IntMap_cow.php | 77 ++++++++++++++++++++++ hphp/test/slow/intmap_array/IntMap_cow.php.expectf | 29 ++++++++ .../test/slow/intmap_array/IntMap_elementByRef.php | 14 ++++ .../intmap_array/IntMap_elementByRef.php.expectf | 29 ++++++++ hphp/test/slow/intmap_array/IntMap_foreach.php | 16 +++++ .../slow/intmap_array/IntMap_foreach.php.expectf | 6 ++ .../test/slow/intmap_array/IntMap_foreachByRef.php | 18 +++++ .../intmap_array/IntMap_foreachByRef.php.expectf | 7 ++ hphp/test/slow/intmap_array/IntMap_grow.php | 22 +++++++ .../test/slow/intmap_array/IntMap_grow.php.expectf | 3 + hphp/test/slow/intmap_array/IntMap_idx.php | 19 ++++++ hphp/test/slow/intmap_array/IntMap_idx.php.expectf | 7 ++ hphp/test/slow/intmap_array/IntMap_idx.php.norepo | 0 hphp/test/slow/intmap_array/IntMap_isset.php | 37 +++++++++++ .../slow/intmap_array/IntMap_isset.php.expectf | 14 ++++ hphp/test/slow/intmap_array/IntMap_ksort.php | 12 ++++ .../slow/intmap_array/IntMap_ksort.php.expectf | 12 ++++ hphp/test/slow/intmap_array/IntMap_mixedValues.php | 11 ++++ .../intmap_array/IntMap_mixedValues.php.expectf | 17 +++++ hphp/test/slow/intmap_array/IntMap_plusEq.php | 35 ++++++++++ .../slow/intmap_array/IntMap_plusEq.php.expectf | 10 +++ hphp/test/slow/intmap_array/IntMap_plusOp.php | 21 ++++++ .../slow/intmap_array/IntMap_plusOp.php.expectf | 28 ++++++++ hphp/test/slow/intmap_array/IntMap_pop.php | 21 ++++++ hphp/test/slow/intmap_array/IntMap_pop.php.expectf | 7 ++ .../intmap_array/IntMap_readNumericStringKey.php | 16 +++++ .../IntMap_readNumericStringKey.php.expectf | 5 ++ hphp/test/slow/intmap_array/IntMap_setRef.php | 15 +++++ .../slow/intmap_array/IntMap_setRef.php.expectf | 27 ++++++++ hphp/test/slow/intmap_array/IntMap_sort.php | 11 ++++ .../test/slow/intmap_array/IntMap_sort.php.expectf | 7 ++ hphp/test/slow/intmap_array/IntMap_uasort.php | 18 +++++ .../slow/intmap_array/IntMap_uasort.php.expectf | 12 ++++ hphp/test/slow/intmap_array/IntMap_uksort.php | 18 +++++ .../slow/intmap_array/IntMap_uksort.php.expectf | 12 ++++ hphp/test/slow/intmap_array/IntMap_unset.php | 51 ++++++++++++++ .../slow/intmap_array/IntMap_unset.php.expectf | 15 +++++ hphp/test/slow/intmap_array/IntMap_usort.php | 18 +++++ .../slow/intmap_array/IntMap_usort.php.expectf | 7 ++ 61 files changed, 1011 insertions(+), 38 deletions(-) create mode 100644 hphp/test/slow/intmap_array/IntMap_addNumericStringKey.php create mode 100644 hphp/test/slow/intmap_array/IntMap_addNumericStringKey.php.expectf create mode 100644 hphp/test/slow/intmap_array/IntMap_addString.php create mode 100644 hphp/test/slow/intmap_array/IntMap_addString.php.expectf create mode 100644 hphp/test/slow/intmap_array/IntMap_append.php create mode 100644 hphp/test/slow/intmap_array/IntMap_append.php.expectf create mode 100644 hphp/test/slow/intmap_array/IntMap_appendRef.php create mode 100644 hphp/test/slow/intmap_array/IntMap_appendRef.php.expectf create mode 100644 hphp/test/slow/intmap_array/IntMap_array_diff_key.php create mode 100644 hphp/test/slow/intmap_array/IntMap_array_diff_key.php.expectf create mode 100644 hphp/test/slow/intmap_array/IntMap_array_map.php create mode 100644 hphp/test/slow/intmap_array/IntMap_array_map.php.expectf create mode 100644 hphp/test/slow/intmap_array/IntMap_array_merge.php create mode 100644 hphp/test/slow/intmap_array/IntMap_array_merge.php.expectf create mode 100644 hphp/test/slow/intmap_array/IntMap_array_shift.php create mode 100644 hphp/test/slow/intmap_array/IntMap_array_shift.php.expectf create mode 100644 hphp/test/slow/intmap_array/IntMap_array_unshift.php create mode 100644 hphp/test/slow/intmap_array/IntMap_array_unshift.php.expectf create mode 100644 hphp/test/slow/intmap_array/IntMap_asort.php create mode 100644 hphp/test/slow/intmap_array/IntMap_asort.php.expectf create mode 100644 hphp/test/slow/intmap_array/IntMap_cow.php create mode 100644 hphp/test/slow/intmap_array/IntMap_cow.php.expectf create mode 100644 hphp/test/slow/intmap_array/IntMap_elementByRef.php create mode 100644 hphp/test/slow/intmap_array/IntMap_elementByRef.php.expectf create mode 100644 hphp/test/slow/intmap_array/IntMap_foreach.php create mode 100644 hphp/test/slow/intmap_array/IntMap_foreach.php.expectf create mode 100644 hphp/test/slow/intmap_array/IntMap_foreachByRef.php create mode 100644 hphp/test/slow/intmap_array/IntMap_foreachByRef.php.expectf create mode 100644 hphp/test/slow/intmap_array/IntMap_grow.php create mode 100644 hphp/test/slow/intmap_array/IntMap_grow.php.expectf create mode 100644 hphp/test/slow/intmap_array/IntMap_idx.php create mode 100644 hphp/test/slow/intmap_array/IntMap_idx.php.expectf create mode 100644 hphp/test/slow/intmap_array/IntMap_idx.php.norepo create mode 100644 hphp/test/slow/intmap_array/IntMap_isset.php create mode 100644 hphp/test/slow/intmap_array/IntMap_isset.php.expectf create mode 100644 hphp/test/slow/intmap_array/IntMap_ksort.php create mode 100644 hphp/test/slow/intmap_array/IntMap_ksort.php.expectf create mode 100644 hphp/test/slow/intmap_array/IntMap_mixedValues.php create mode 100644 hphp/test/slow/intmap_array/IntMap_mixedValues.php.expectf create mode 100644 hphp/test/slow/intmap_array/IntMap_plusEq.php create mode 100644 hphp/test/slow/intmap_array/IntMap_plusEq.php.expectf create mode 100644 hphp/test/slow/intmap_array/IntMap_plusOp.php create mode 100644 hphp/test/slow/intmap_array/IntMap_plusOp.php.expectf create mode 100644 hphp/test/slow/intmap_array/IntMap_pop.php create mode 100644 hphp/test/slow/intmap_array/IntMap_pop.php.expectf create mode 100644 hphp/test/slow/intmap_array/IntMap_readNumericStringKey.php create mode 100644 hphp/test/slow/intmap_array/IntMap_readNumericStringKey.php.expectf create mode 100644 hphp/test/slow/intmap_array/IntMap_setRef.php create mode 100644 hphp/test/slow/intmap_array/IntMap_setRef.php.expectf create mode 100644 hphp/test/slow/intmap_array/IntMap_sort.php create mode 100644 hphp/test/slow/intmap_array/IntMap_sort.php.expectf create mode 100644 hphp/test/slow/intmap_array/IntMap_uasort.php create mode 100644 hphp/test/slow/intmap_array/IntMap_uasort.php.expectf create mode 100644 hphp/test/slow/intmap_array/IntMap_uksort.php create mode 100644 hphp/test/slow/intmap_array/IntMap_uksort.php.expectf create mode 100644 hphp/test/slow/intmap_array/IntMap_unset.php create mode 100644 hphp/test/slow/intmap_array/IntMap_unset.php.expectf create mode 100644 hphp/test/slow/intmap_array/IntMap_usort.php create mode 100644 hphp/test/slow/intmap_array/IntMap_usort.php.expectf diff --git a/hphp/runtime/base/mixed-array.cpp b/hphp/runtime/base/mixed-array.cpp index 894fa97317f..f3bc6364dbc 100644 --- a/hphp/runtime/base/mixed-array.cpp +++ b/hphp/runtime/base/mixed-array.cpp @@ -1029,69 +1029,50 @@ void MixedArray::downgradeAndWarn(ArrayData* ad, const Reason r) { void MixedArray::warnUsage(const Reason r) { switch (r) { case Reason::kForeachByRef: - raise_warning("Trying to foreach by reference over an IntMap array which " - "does not support taking elements by reference. Downgrading " - "to normal array"); + raise_warning("Foreach by reference over a miarray, converting to array"); break; case Reason::kPrepend: - raise_warning("Trying to prepend to an IntMap array. " - "Downgrading to normal array"); + raise_warning("Using array_unshift on a miarray, converting to array"); break; case Reason::kPop: - raise_warning("Trying to pop from an IntMap array. " - "Downgrading to normal array"); + raise_warning("Using array_pop on a miarray, converting to array"); break; case Reason::kTakeByRef: - raise_warning("Trying to take an element by reference from an IntMap array " - "which does not support taking elements by reference. " - "Downgrading to normal array"); + raise_warning("Taking an element by reference from a miarray, " + "converting to array"); break; case Reason::kSetRef: - raise_warning("Trying to add a reference value to an IntMap array which " - "does not support references. Downgrading to normal array"); + raise_warning("Adding a reference to a miarray, converting to array"); break; case Reason::kAppendRef: - raise_warning("Trying to append a reference to IntMap array which does not " - "support reference values nor appending. Downgrading to " - "normal array"); + raise_warning("Appending a reference to a miarray, converting to array"); break; case Reason::kAppend: - raise_warning("Trying to append to IntMap array which does not support " - "appending to. Downgrading to normal array"); + raise_warning("Appending to a miarray, converting to array"); break; case Reason::kNvGetStr: - raise_warning("Trying to read string key on IntMap array which only has " - "integer keys. Downgrading to normal array"); + raise_warning("Reading string key from a miarray, converting to array"); break; case Reason::kExistsStr: - raise_warning("Trying to check for existence of string on IntMap array " - "which only supports integer keys. Downgrading to normal " - "array"); + raise_warning("Reading string key from a miarray, converting to array"); break; case Reason::kSetStr: - raise_warning("Trying to add a string key to IntMap array which only has " - "integer keys. Downgrading to normal array"); + raise_warning("Adding a string key to a miarray, converting to array"); break; case Reason::kRemoveStr: - raise_warning("Trying to remove a string key from IntMap array which only " - "has integer keys. Downgrading to normal array"); + raise_warning("Removing a string key from a miarray, converting to array"); break; case Reason::kDequeue: - raise_warning("Trying to dequeue from an IntMap array. " - "Downgrading to normal array"); + raise_warning("Using array_shift on a miarray, converting to array"); break; case Reason::kSort: - raise_warning("Trying to sort an IntMap array which will re-order keys. " - "Downgrading to normal array"); + raise_warning("Using sort on a miarray, converting to array"); break; case Reason::kUsort: - raise_warning("Trying to usort an IntMap array which will re-order keys. " - "Downgrading to normal array"); + raise_warning("Using usort on a miarray, converting to array"); break; case Reason::kNumericString: - raise_warning("Trying to use a strictly numeric string key with an IntMap " - "array which only supports integer keys. " - "Downgrading to normal array"); + raise_warning("An integer-like string key used with a miarray"); break; case Reason::kRenumber: raise_warning("Trying to renumber IntMap array keys. " @@ -1481,7 +1462,7 @@ ArrayData* MixedArray::SetInt(ArrayData* ad, int64_t k, Cell v, ArrayData* MixedArray::SetIntConverted(ArrayData* ad, int64_t k, Cell v, bool copy) { assert(ad->isIntMapArray()); - MixedArray::downgradeAndWarn(ad, Reason::kNumericString); + MixedArray::warnUsage(Reason::kNumericString); return MixedArray::SetInt(ad, k, v, copy); } diff --git a/hphp/runtime/vm/jit/minstr-translator.cpp b/hphp/runtime/vm/jit/minstr-translator.cpp index 82feb4f77eb..ef760b81a29 100644 --- a/hphp/runtime/vm/jit/minstr-translator.cpp +++ b/hphp/runtime/vm/jit/minstr-translator.cpp @@ -2256,8 +2256,7 @@ static inline typename ShuffleReturn::return_type arraySetImpl( : uncheckedSet(a, key, value, copy); if (converted) { if (UNLIKELY(ret->isIntMapArray())) { - // warn after operation since there may have been a copy - MixedArray::downgradeAndWarn(ret, MixedArray::Reason::kNumericString); + MixedArray::warnUsage(MixedArray::Reason::kNumericString); } } diff --git a/hphp/test/slow/intmap_array/IntMap_addNumericStringKey.php b/hphp/test/slow/intmap_array/IntMap_addNumericStringKey.php new file mode 100644 index 00000000000..61c976ece98 --- /dev/null +++ b/hphp/test/slow/intmap_array/IntMap_addNumericStringKey.php @@ -0,0 +1,26 @@ + + int(10) + [456]=> + int(20) +} + +Warning: An integer-like string key used with a miarray in %s/IntMap_addNumericStringKey.php on line 16 + +Warning: An integer-like string key used with a miarray in %s/IntMap_addNumericStringKey.php on line 17 +array(1) { + [123]=> + int(20) +} + +Warning: An integer-like string key used with a miarray in %s/IntMap_addNumericStringKey.php on line 4 +array(1) { + [123]=> + int(10) +} + +Warning: Appending to a miarray, converting to array in %s/IntMap_addNumericStringKey.php on line 23 \ No newline at end of file diff --git a/hphp/test/slow/intmap_array/IntMap_addString.php b/hphp/test/slow/intmap_array/IntMap_addString.php new file mode 100644 index 00000000000..30b2ed5f5b5 --- /dev/null +++ b/hphp/test/slow/intmap_array/IntMap_addString.php @@ -0,0 +1,16 @@ + + int(10) + ["anotherString"]=> + int(20) +} + +Warning: Adding a string key to a miarray, converting to array in %s/IntMap_addString.php on line 11 +array(1) { + ["string"]=> + string(9) "something" +} \ No newline at end of file diff --git a/hphp/test/slow/intmap_array/IntMap_append.php b/hphp/test/slow/intmap_array/IntMap_append.php new file mode 100644 index 00000000000..8b480bf80a5 --- /dev/null +++ b/hphp/test/slow/intmap_array/IntMap_append.php @@ -0,0 +1,10 @@ + + int(1) + [1]=> + int(2) +} \ No newline at end of file diff --git a/hphp/test/slow/intmap_array/IntMap_appendRef.php b/hphp/test/slow/intmap_array/IntMap_appendRef.php new file mode 100644 index 00000000000..64d6c780231 --- /dev/null +++ b/hphp/test/slow/intmap_array/IntMap_appendRef.php @@ -0,0 +1,15 @@ + + &array(5) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + int(4) + [4]=> + string(3) "sup" + } + [1]=> + &array(4) { + [0]=> + int(5) + [1]=> + int(6) + [2]=> + int(7) + [3]=> + int(8) + } +} \ No newline at end of file diff --git a/hphp/test/slow/intmap_array/IntMap_array_diff_key.php b/hphp/test/slow/intmap_array/IntMap_array_diff_key.php new file mode 100644 index 00000000000..9c38e23730b --- /dev/null +++ b/hphp/test/slow/intmap_array/IntMap_array_diff_key.php @@ -0,0 +1,15 @@ + "sup", "sup" => 100); + $c = array_diff_key($a, + $b); + var_dump($a); + var_dump($b); + var_dump($c); +} + +main(); diff --git a/hphp/test/slow/intmap_array/IntMap_array_diff_key.php.expectf b/hphp/test/slow/intmap_array/IntMap_array_diff_key.php.expectf new file mode 100644 index 00000000000..54289fa4b45 --- /dev/null +++ b/hphp/test/slow/intmap_array/IntMap_array_diff_key.php.expectf @@ -0,0 +1,16 @@ +array(2) { + [1]=> + int(2) + [100]=> + int(200) +} +array(2) { + [100]=> + string(3) "sup" + ["sup"]=> + int(100) +} +array(1) { + [1]=> + int(2) +} \ No newline at end of file diff --git a/hphp/test/slow/intmap_array/IntMap_array_map.php b/hphp/test/slow/intmap_array/IntMap_array_map.php new file mode 100644 index 00000000000..00e7ddb2a11 --- /dev/null +++ b/hphp/test/slow/intmap_array/IntMap_array_map.php @@ -0,0 +1,13 @@ + $x / 2, + $a); + var_dump($b); + var_dump($a); +} + +main(); diff --git a/hphp/test/slow/intmap_array/IntMap_array_map.php.expectf b/hphp/test/slow/intmap_array/IntMap_array_map.php.expectf new file mode 100644 index 00000000000..e7718559900 --- /dev/null +++ b/hphp/test/slow/intmap_array/IntMap_array_map.php.expectf @@ -0,0 +1,12 @@ +array(2) { + [1]=> + int(1) + [100]=> + int(100) +} +array(2) { + [1]=> + int(2) + [100]=> + int(200) +} \ No newline at end of file diff --git a/hphp/test/slow/intmap_array/IntMap_array_merge.php b/hphp/test/slow/intmap_array/IntMap_array_merge.php new file mode 100644 index 00000000000..2b33a84cf5b --- /dev/null +++ b/hphp/test/slow/intmap_array/IntMap_array_merge.php @@ -0,0 +1,16 @@ + "bar", 1 => "one", 2 => 600); + $c = array_merge($a, $b); + var_dump($c); + $d = array_merge($b, $a); + var_dump($d); + $e = array_merge($a, $a); + var_dump($e); +} + +main(); diff --git a/hphp/test/slow/intmap_array/IntMap_array_merge.php.expectf b/hphp/test/slow/intmap_array/IntMap_array_merge.php.expectf new file mode 100644 index 00000000000..b116489d0bf --- /dev/null +++ b/hphp/test/slow/intmap_array/IntMap_array_merge.php.expectf @@ -0,0 +1,34 @@ +array(5) { + [0]=> + string(4) "abcd" + [1]=> + string(4) "efgh" + ["foo"]=> + string(3) "bar" + [2]=> + string(3) "one" + [3]=> + int(600) +} +array(5) { + ["foo"]=> + string(3) "bar" + [0]=> + string(3) "one" + [1]=> + int(600) + [2]=> + string(4) "abcd" + [3]=> + string(4) "efgh" +} +array(4) { + [0]=> + string(4) "abcd" + [1]=> + string(4) "efgh" + [2]=> + string(4) "abcd" + [3]=> + string(4) "efgh" +} \ No newline at end of file diff --git a/hphp/test/slow/intmap_array/IntMap_array_shift.php b/hphp/test/slow/intmap_array/IntMap_array_shift.php new file mode 100644 index 00000000000..102ab63513f --- /dev/null +++ b/hphp/test/slow/intmap_array/IntMap_array_shift.php @@ -0,0 +1,9 @@ + + string(4) "efgh" + [1]=> + string(4) "abcd" +} +array(2) { + [1]=> + string(4) "abcd" + [0]=> + string(4) "efgh" +} \ No newline at end of file diff --git a/hphp/test/slow/intmap_array/IntMap_cow.php b/hphp/test/slow/intmap_array/IntMap_cow.php new file mode 100644 index 00000000000..c6d94c7a850 --- /dev/null +++ b/hphp/test/slow/intmap_array/IntMap_cow.php @@ -0,0 +1,77 @@ + + &array(5) { + [0]=> + int(0) + [1]=> + int(1) + [2]=> + int(2) + [3]=> + int(3) + [4]=> + int(4) + } + [1]=> + &array(5) { + [0]=> + int(5) + [1]=> + int(6) + [2]=> + int(7) + [3]=> + int(8) + [4]=> + int(9) + } +} \ No newline at end of file diff --git a/hphp/test/slow/intmap_array/IntMap_foreach.php b/hphp/test/slow/intmap_array/IntMap_foreach.php new file mode 100644 index 00000000000..5a31dac18a4 --- /dev/null +++ b/hphp/test/slow/intmap_array/IntMap_foreach.php @@ -0,0 +1,16 @@ + $val) { + var_dump($key); + var_dump($val); + } + foreach ($a as $val) { + var_dump($val); + } +} + +main(); diff --git a/hphp/test/slow/intmap_array/IntMap_foreach.php.expectf b/hphp/test/slow/intmap_array/IntMap_foreach.php.expectf new file mode 100644 index 00000000000..db5e60f653e --- /dev/null +++ b/hphp/test/slow/intmap_array/IntMap_foreach.php.expectf @@ -0,0 +1,6 @@ +int(0) +int(1) +int(1) +int(2) +int(1) +int(2) \ No newline at end of file diff --git a/hphp/test/slow/intmap_array/IntMap_foreachByRef.php b/hphp/test/slow/intmap_array/IntMap_foreachByRef.php new file mode 100644 index 00000000000..82402f05f98 --- /dev/null +++ b/hphp/test/slow/intmap_array/IntMap_foreachByRef.php @@ -0,0 +1,18 @@ + + &int(-1) + [1]=> + string(3) "sup" +} \ No newline at end of file diff --git a/hphp/test/slow/intmap_array/IntMap_grow.php b/hphp/test/slow/intmap_array/IntMap_grow.php new file mode 100644 index 00000000000..da1ad883503 --- /dev/null +++ b/hphp/test/slow/intmap_array/IntMap_grow.php @@ -0,0 +1,22 @@ + + int(0) + [0]=> + int(1) +} +array(2) { + [0]=> + int(1) + [1]=> + int(0) +} \ No newline at end of file diff --git a/hphp/test/slow/intmap_array/IntMap_mixedValues.php b/hphp/test/slow/intmap_array/IntMap_mixedValues.php new file mode 100644 index 00000000000..43eb3bb655c --- /dev/null +++ b/hphp/test/slow/intmap_array/IntMap_mixedValues.php @@ -0,0 +1,11 @@ + + int(10) + [-20]=> + array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + int(4) + } + [50]=> + string(11) "some string" +} \ No newline at end of file diff --git a/hphp/test/slow/intmap_array/IntMap_plusEq.php b/hphp/test/slow/intmap_array/IntMap_plusEq.php new file mode 100644 index 00000000000..8c939871887 --- /dev/null +++ b/hphp/test/slow/intmap_array/IntMap_plusEq.php @@ -0,0 +1,35 @@ + "bar"); + + $b = hphp_miarray(); + $c = hphp_miarray(); + $b[0] = 0; + $c[1] = 1; + $b += $c; + + $d = hphp_miarray(); + $e = array("foo" => "bar"); + $d[1] = "foo"; + $e += $d; + + $f = hphp_miarray(); + $f[100] = "sup"; + $f += array(0 => 1); + + $g = hphp_miarray(); + cowPlusEq($g); + $g += array(0,1,2,3); + var_dump($g); +} + +main(); diff --git a/hphp/test/slow/intmap_array/IntMap_plusEq.php.expectf b/hphp/test/slow/intmap_array/IntMap_plusEq.php.expectf new file mode 100644 index 00000000000..67aca7d69d0 --- /dev/null +++ b/hphp/test/slow/intmap_array/IntMap_plusEq.php.expectf @@ -0,0 +1,10 @@ +array(4) { + [0]=> + int(0) + [1]=> + int(1) + [2]=> + int(2) + [3]=> + int(3) +} \ No newline at end of file diff --git a/hphp/test/slow/intmap_array/IntMap_plusOp.php b/hphp/test/slow/intmap_array/IntMap_plusOp.php new file mode 100644 index 00000000000..f7f657c6e7d --- /dev/null +++ b/hphp/test/slow/intmap_array/IntMap_plusOp.php @@ -0,0 +1,21 @@ + "bar"); + var_dump($b); + $b = array("foo" => "bar") + $a; + var_dump($b); + + $c = hphp_miarray(); + $d = hphp_miarray(); + $c[0] = 0; + $d[1] = 1; + $e = $c + $d; + var_dump($e); +} + +main(); diff --git a/hphp/test/slow/intmap_array/IntMap_plusOp.php.expectf b/hphp/test/slow/intmap_array/IntMap_plusOp.php.expectf new file mode 100644 index 00000000000..ecf4b730a62 --- /dev/null +++ b/hphp/test/slow/intmap_array/IntMap_plusOp.php.expectf @@ -0,0 +1,28 @@ +array(2) { + [1]=> + string(4) "abcd" + [0]=> + string(4) "efgh" +} +array(3) { + [1]=> + string(4) "abcd" + [0]=> + string(4) "efgh" + ["foo"]=> + string(3) "bar" +} +array(3) { + ["foo"]=> + string(3) "bar" + [1]=> + string(4) "abcd" + [0]=> + string(4) "efgh" +} +array(2) { + [0]=> + int(0) + [1]=> + int(1) +} \ No newline at end of file diff --git a/hphp/test/slow/intmap_array/IntMap_pop.php b/hphp/test/slow/intmap_array/IntMap_pop.php new file mode 100644 index 00000000000..4bac2c6ecbc --- /dev/null +++ b/hphp/test/slow/intmap_array/IntMap_pop.php @@ -0,0 +1,21 @@ + + &array(5) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + int(4) + [4]=> + string(3) "sup" + } + [1]=> + &array(4) { + [0]=> + int(5) + [1]=> + int(6) + [2]=> + int(7) + [3]=> + int(8) + } +} \ No newline at end of file diff --git a/hphp/test/slow/intmap_array/IntMap_sort.php b/hphp/test/slow/intmap_array/IntMap_sort.php new file mode 100644 index 00000000000..bb5d7ce178b --- /dev/null +++ b/hphp/test/slow/intmap_array/IntMap_sort.php @@ -0,0 +1,11 @@ + + int(0) + [1]=> + int(1) +} \ No newline at end of file diff --git a/hphp/test/slow/intmap_array/IntMap_uasort.php b/hphp/test/slow/intmap_array/IntMap_uasort.php new file mode 100644 index 00000000000..51c37fd9a5c --- /dev/null +++ b/hphp/test/slow/intmap_array/IntMap_uasort.php @@ -0,0 +1,18 @@ + + int(2) + [500]=> + int(0) +} +array(2) { + [500]=> + int(0) + [1]=> + int(2) +} \ No newline at end of file diff --git a/hphp/test/slow/intmap_array/IntMap_uksort.php b/hphp/test/slow/intmap_array/IntMap_uksort.php new file mode 100644 index 00000000000..b493326f2e0 --- /dev/null +++ b/hphp/test/slow/intmap_array/IntMap_uksort.php @@ -0,0 +1,18 @@ + + int(3) + [5]=> + int(49) +} +array(2) { + [5]=> + int(49) + [200]=> + int(3) +} \ No newline at end of file diff --git a/hphp/test/slow/intmap_array/IntMap_unset.php b/hphp/test/slow/intmap_array/IntMap_unset.php new file mode 100644 index 00000000000..0d7f98e5551 --- /dev/null +++ b/hphp/test/slow/intmap_array/IntMap_unset.php @@ -0,0 +1,51 @@ + $val) { + if ($val) { + unset($arr[$key]); + } else { + unset($arr['123']); + } + } + return $arr; +} + +function main() { + $a = hphp_miarray(); + $a[1] = "moo"; + unset($a["1"]); + + $a = hphp_miarray(); + $a[1] = "moo"; + unset($a[1]); + var_dump($a); + + $a = hphp_miarray(); + $a[1] = "moo"; + unset($a["foo"]); + + $a = hphp_miarray(); + $key = "1"; + $a[1] = "moo"; + unset($a[$key]); + + $a = hphp_miarray(); + $key = 1; + $a[1] = "moo"; + unset($a[$key]); + var_dump($a); + + $a = hphp_miarray(); + $key = "foo"; + $a[1] = "moo"; + unset($a[$key]); + + $a = hphp_miarray(); + $a[1] = true; + $a[2] = false; + $b = cow_unset($a); + $a[] = "warning"; +} + +main(); diff --git a/hphp/test/slow/intmap_array/IntMap_unset.php.expectf b/hphp/test/slow/intmap_array/IntMap_unset.php.expectf new file mode 100644 index 00000000000..171bb6125d4 --- /dev/null +++ b/hphp/test/slow/intmap_array/IntMap_unset.php.expectf @@ -0,0 +1,15 @@ +Warning: An integer-like string key used with a miarray in %s/IntMap_unset.php on line 17 +array(0) { +} + +Warning: Removing a string key from a miarray, converting to array in %s/IntMap_unset.php on line 26 + +Warning: An integer-like string key used with a miarray in %s/IntMap_unset.php on line 31 +array(0) { +} + +Warning: Removing a string key from a miarray, converting to array in %s/IntMap_unset.php on line 42 + +Warning: An integer-like string key used with a miarray in %s/IntMap_unset.php on line 8 + +Warning: Appending to a miarray, converting to array in %s/IntMap_unset.php on line 48 \ No newline at end of file diff --git a/hphp/test/slow/intmap_array/IntMap_usort.php b/hphp/test/slow/intmap_array/IntMap_usort.php new file mode 100644 index 00000000000..a7c9e6aabdb --- /dev/null +++ b/hphp/test/slow/intmap_array/IntMap_usort.php @@ -0,0 +1,18 @@ + + int(0) + [1]=> + int(1) +} \ No newline at end of file -- 2.11.4.GIT