1--TEST-- 2SPL: FixedArray: misc small tests 3--FILE-- 4<?php 5 6/* empty count */ 7$a = new SplFixedArray(); 8 9var_dump(count($a)); 10var_dump($a->count()); 11 12/* negative init value */ 13try { 14 $b = new SplFixedArray(-10); 15} catch (Exception $e) { 16 var_dump($e->getMessage()); 17} 18 19/* resize and negative value */ 20$b = new SplFixedArray(); 21try { 22 $b->setSize(-5); 23} catch (Exception $e) { 24 var_dump($e->getMessage()); 25} 26 27/* calling __construct() twice */ 28$c = new SplFixedArray(0); 29var_dump($c->__construct()); 30 31/* fromArray() from empty array */ 32$d = new SplFixedArray(); 33$d->fromArray(array()); 34 35var_dump(count($a)); 36var_dump($a->count()); 37var_dump($a); 38 39/* foreach by ref */ 40$e = new SplFixedArray(10); 41$e[0] = 1; 42$e[1] = 5; 43$e[2] = 10; 44 45try { 46 foreach ($e as $k=>&$v) { 47 var_dump($v); 48 } 49} catch (Exception $e) { 50 var_dump($e->getMessage()); 51} 52 53//non-long indexes 54$a = new SplFixedArray(4); 55$a["2"] = "foo"; 56$a["1"] = "foo"; 57$a["3"] = "0"; 58 59var_dump(isset($a["0"], $a[-1]), $a["1"]); 60var_dump(empty($a["3"])); 61 62?> 63==DONE== 64--EXPECTF-- 65int(0) 66int(0) 67string(35) "array size cannot be less than zero" 68string(35) "array size cannot be less than zero" 69NULL 70int(0) 71int(0) 72object(SplFixedArray)#%d (0) { 73} 74string(52) "An iterator cannot be used with foreach by reference" 75bool(false) 76string(3) "foo" 77bool(true) 78==DONE== 79