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/fixedarray_021.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/fixedarray_021.phpt')
| -rw-r--r-- | ext/spl/tests/fixedarray_021.phpt | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/ext/spl/tests/fixedarray_021.phpt b/ext/spl/tests/fixedarray_021.phpt new file mode 100644 index 0000000..97b0a70 --- /dev/null +++ b/ext/spl/tests/fixedarray_021.phpt @@ -0,0 +1,78 @@ +--TEST-- +SPL: FixedArray: misc small tests +--FILE-- +<?php + +/* empty count */ +$a = new SplFixedArray(); + +var_dump(count($a)); +var_dump($a->count()); + +/* negative init value */ +try { + $b = new SplFixedArray(-10); +} catch (Exception $e) { + var_dump($e->getMessage()); +} + +/* resize and negative value */ +$b = new SplFixedArray(); +try { + $b->setSize(-5); +} catch (Exception $e) { + var_dump($e->getMessage()); +} + +/* calling __construct() twice */ +$c = new SplFixedArray(0); +var_dump($c->__construct()); + +/* fromArray() from empty array */ +$d = new SplFixedArray(); +$d->fromArray(array()); + +var_dump(count($a)); +var_dump($a->count()); +var_dump($a); + +/* foreach by ref */ +$e = new SplFixedArray(10); +$e[0] = 1; +$e[1] = 5; +$e[2] = 10; + +try { + foreach ($e as $k=>&$v) { + var_dump($v); + } +} catch (Exception $e) { + var_dump($e->getMessage()); +} + +//non-long indexes +$a = new SplFixedArray(4); +$a["2"] = "foo"; +$a["1"] = "foo"; +$a["3"] = "0"; + +var_dump(isset($a["0"], $a[-1]), $a["1"]); +var_dump(empty($a["3"])); + +?> +==DONE== +--EXPECTF-- +int(0) +int(0) +string(35) "array size cannot be less than zero" +string(35) "array size cannot be less than zero" +NULL +int(0) +int(0) +object(SplFixedArray)#%d (0) { +} +string(52) "An iterator cannot be used with foreach by reference" +bool(false) +string(3) "foo" +bool(true) +==DONE== |
