diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2013-03-14 05:42:27 +0000 |
---|---|---|
committer | <> | 2013-04-03 16:25:08 +0000 |
commit | c4dd7a1a684490673e25aaf4fabec5df138854c4 (patch) | |
tree | 4d57c44caae4480efff02b90b9be86f44bf25409 /ext/spl/tests/arrayObject_exchangeArray_basic1.phpt | |
download | php2-master.tar.gz |
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/spl/tests/arrayObject_exchangeArray_basic1.phpt')
-rw-r--r-- | ext/spl/tests/arrayObject_exchangeArray_basic1.phpt | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/ext/spl/tests/arrayObject_exchangeArray_basic1.phpt b/ext/spl/tests/arrayObject_exchangeArray_basic1.phpt new file mode 100644 index 0000000..988f103 --- /dev/null +++ b/ext/spl/tests/arrayObject_exchangeArray_basic1.phpt @@ -0,0 +1,40 @@ +--TEST-- +SPL: ArrayObject::exchangeArray() and copy-on-write references +--FILE-- +<?php +$ao = new ArrayObject(); +$swapIn = array(); +$cowRef = $swapIn; // create a copy-on-write ref to $swapIn +$ao->exchangeArray($swapIn); + +$ao['a'] = 'adding element to $ao'; +$swapIn['b'] = 'adding element to $swapIn'; +$ao['c'] = 'adding another element to $ao'; + +echo "\n--> swapIn: "; +var_dump($swapIn); + +echo "\n--> cowRef: "; +var_dump($cowRef); + +echo "\n--> ao: "; +var_dump($ao); +?> +--EXPECTF-- +--> swapIn: array(1) { + ["b"]=> + string(25) "adding element to $swapIn" +} + +--> cowRef: array(0) { +} + +--> ao: object(ArrayObject)#%d (1) { + ["storage":"ArrayObject":private]=> + array(2) { + ["a"]=> + string(21) "adding element to $ao" + ["c"]=> + string(29) "adding another element to $ao" + } +} |