mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
Fixed SplFixedArray and tests.
This commit is contained in:
parent
a519838ece
commit
c57bde7c9e
@ -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;
|
||||
}
|
||||
|
@ -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
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user