File:
[ELWIX - Embedded LightWeight unIX -] /
embedaddon /
php /
ext /
spl /
tests /
fixedarray_020.phpt
Revision
1.1.1.1 (vendor branch):
download - view:
text,
annotated -
select for diffs -
revision graph
Tue Feb 21 23:48:01 2012 UTC (12 years, 6 months ago) by
misho
Branches:
php,
MAIN
CVS tags:
v5_4_3elwix,
v5_4_29p0,
v5_4_29,
v5_4_20p0,
v5_4_20,
v5_4_17p0,
v5_4_17,
v5_3_10,
HEAD
php
--TEST--
SPL: FixedArray: fromArray/toArray + get_properties
--FILE--
<?php
$a = array(1=>'foo', 2=>'bar', 0=>'gee');
$fa = SplFixedArray::fromArray($a, false);
var_dump(count($fa), $fa->toArray() === array_values($a));
$fa = SplFixedArray::fromArray($a, true);
var_dump(count($fa), $fa->toArray() === $a, $fa->toArray() === (array)$fa);
try {
echo "From Array with string keys, no preserve\n";
SplFixedArray::fromArray(array("foo"=>"bar"), false);
echo "No exception\n";
} catch (Exception $e) {
echo "Exception: ".$e->getMessage()."\n";
}
try {
echo "From Array with string keys, preserve\n";
SplFixedArray::fromArray(array("foo"=>"bar"), true);
echo "No exception\n";
} catch (Exception $e) {
echo "Exception: ".$e->getMessage()."\n";
}
?>
--EXPECT--
int(3)
bool(true)
int(3)
bool(false)
bool(true)
From Array with string keys, no preserve
No exception
From Array with string keys, preserve
Exception: array must contain only positive integer keys
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>