Fixed SplFixedArray and tests.

This commit is contained in:
Danack 2015-03-01 13:44:55 +00:00
parent a519838ece
commit c57bde7c9e
7 changed files with 48 additions and 50 deletions

View File

@ -561,6 +561,13 @@ SPL_METHOD(SplFixedArray, __construct)
spl_fixedarray_object *intern;
zend_long size = 0;
int rv;
zend_error_handling zeh;
// zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &zeh TSRMLS_CC);
// rv = zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &size);
// zend_restore_error_handling(&zeh TSRMLS_CC);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &size) == FAILURE) {
return;
}

View File

@ -5,8 +5,13 @@ PHPNW Test Fest 2009 - Jordan Hatch
--FILE--
<?php
$array = new SplFixedArray( array("string", 1) );
try {
$array = new SplFixedArray( array("string", 1) );
}
catch(InvalidArgumentException $iae) {
echo "Ok - ".$iae->getMessage().PHP_EOL;
}
?>
--EXPECTF--
Warning: SplFixedArray::__construct() expects parameter 1 to be integer, array given in %s on line %d
Ok - SplFixedArray::__construct() expects parameter 1 to be integer, array given

View File

@ -4,9 +4,14 @@ SplFixedArray::__construct() with string passed as parameter.
PHPNW Test Fest 2009 - Jordan Hatch
--FILE--
<?php
try {
$array = new SplFixedArray( "string" );
}
catch(InvalidArgumentException $iae) {
echo "Ok - ".$iae->getMessage().PHP_EOL;
}
$array = new SplFixedArray( "string" );
?>
--EXPECTF--
Warning: SplFixedArray::__construct() expects parameter 1 to be integer, %unicode_string_optional% given in %s on line %d
Ok - SplFixedArray::__construct() expects parameter 1 to be integer, %unicode_string_optional% given

View File

@ -4,10 +4,13 @@ Create an SplFixedArray using an SplFixedArray object.
Philip Norton philipnorton42@gmail.com
--FILE--
<?php
$array = new SplFixedArray(new SplFixedArray(3));
var_dump($array);
try {
$array = new SplFixedArray(new SplFixedArray(3));
}
catch(InvalidArgumentException $iae) {
echo "Ok - ".$iae->getMessage().PHP_EOL;
}
?>
--EXPECTF--
Warning: SplFixedArray::__construct() expects parameter 1 to be integer, object given in %s on line %d
object(SplFixedArray)#1 (0) {
}
Ok - SplFixedArray::__construct() expects parameter 1 to be integer, object given

View File

@ -5,8 +5,14 @@ SPL: FixedArray: Trying to instantiate passing object to constructor parameter
$b = new stdClass;
$a = new SplFixedArray($b);
try {
$a = new SplFixedArray($b);
}
catch(InvalidArgumentException $iae) {
echo "Ok - ".$iae->getMessage().PHP_EOL;
}
?>
--EXPECTF--
Warning: SplFixedArray::__construct() expects parameter 1 to be integer, object given in %s on line %d
Ok - SplFixedArray::__construct() expects parameter 1 to be integer, object given

View File

@ -3,8 +3,12 @@ SPL: FixedArray: Trying to instantiate passing string to construtor parameter
--FILE--
<?php
$a = new SplFixedArray('FOO');
try {
$a = new SplFixedArray('FOO');
}
catch(InvalidArgumentException $iae) {
echo "Ok - ".$iae->getMessage().PHP_EOL;
}
?>
--EXPECTF--
Warning: SplFixedArray::__construct() expects parameter 1 to be integer, string given in %s on line %d
Ok - SplFixedArray::__construct() expects parameter 1 to be integer, string given

View File

@ -3,47 +3,15 @@ SPL: FixedArray: accessing uninitialized array
--FILE--
<?php
$a = new SplFixedArray('');
try {
var_dump($a[1]);
} catch (Exception $e) {
echo $e->getMessage(), "\n";
$a = new SplFixedArray('');
}
try {
$a[1] = 1;
} catch (Exception $e) {
echo $e->getMessage(), "\n";
}
try {
var_dump(count($a[1]));
} catch (Exception $e) {
echo $e->getMessage(), "\n";
}
try {
var_dump($a->getSize());
} catch (Exception $e) {
echo $e->getMessage(), "\n";
}
try {
foreach ($a as $v) {
}
} catch (Exception $e) {
echo $e->getMessage(), "\n";
}
try {
var_dump($a->setSize(10));
} catch (Exception $e) {
echo $e->getMessage(), "\n";
catch(InvalidArgumentException $iae) {
echo "Ok - ".$iae->getMessage().PHP_EOL;
}
echo "Done\n";
?>
--EXPECTF--
Warning: SplFixedArray::__construct() expects parameter 1 to be integer, string given in %s on line %d
Index invalid or out of range
Index invalid or out of range
Index invalid or out of range
int(0)
bool(true)
Ok - SplFixedArray::__construct() expects parameter 1 to be integer, string given
Done