com php-src: Fixed SplFixedArray and tests.: ext/spl/spl_fixe darray.c ext/spl/tests/SplFixedArray__construct_param _array.phpt
ext/spl/tests/SplFixedArray__construct_ param_string.phpt ext/spl/tests/SplFixedArray_construct _param_SplFixedArray.phpt ext/spl/tests/fixedarray_
005.phpt ext/spl/tests/fixedarray_009.phpt ext/spl/tests/fixedarray_015.phpt
| From: | Dmitry Stogov | Date: | Sun, 01 Mar 2015 13:44:55 +0000 |
| Subject: | com php-src: Fixed SplFixedArray and tests.: ext/spl/spl_fixe darray.c ext/spl/tests/SplFixedArray__construct_param _array.phpt ext/spl/tests/SplFixedArray__construct_ param_string.phpt ext/spl/tests/SplFixedArray_construct _param_SplFixedArray.phpt ext/spl/tests/fixedarray_ 005.phpt ext/spl/tests/fixedarray_009.phpt ext/spl/tests/fixedarray_015.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-86006@lists.php.net to get a copy of this message | ||
Commit: c57bde7c9e2f4ac3e93f096eaa93d4ab0133915d
Author: Danack <Danack@basereality.com> Sun, 1 Mar 2015 13:44:55 +0000
Parents: a519838ece18dd1babce5b6683b04e99e7816184
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=c57bde7c9e2f4ac3e93f096eaa93d4ab0133915d
Log:
Fixed SplFixedArray and tests.
Changed paths:
M ext/spl/spl_fixedarray.c
M ext/spl/tests/SplFixedArray__construct_param_array.phpt
M ext/spl/tests/SplFixedArray__construct_param_string.phpt
M ext/spl/tests/SplFixedArray_construct_param_SplFixedArray.phpt
M ext/spl/tests/fixedarray_005.phpt
M ext/spl/tests/fixedarray_009.phpt
M ext/spl/tests/fixedarray_015.phpt
Diff:
diff --git a/ext/spl/spl_fixedarray.c b/ext/spl/spl_fixedarray.c
index cd83a17..dcac83d 100644
--- a/ext/spl/spl_fixedarray.c
+++ b/ext/spl/spl_fixedarray.c
@@ -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;
}
diff --git a/ext/spl/tests/SplFixedArray__construct_param_array.phpt
b/ext/spl/tests/SplFixedArray__construct_param_array.phpt
index 1d78695..aa5933e 100644
--- a/ext/spl/tests/SplFixedArray__construct_param_array.phpt
+++ b/ext/spl/tests/SplFixedArray__construct_param_array.phpt
@@ -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
\ No newline at end of file
+Ok - SplFixedArray::__construct() expects parameter 1 to be integer, array given
\ No newline at end of file
diff --git a/ext/spl/tests/SplFixedArray__construct_param_string.phpt
b/ext/spl/tests/SplFixedArray__construct_param_string.phpt
index 99742e3..411d740 100644
--- a/ext/spl/tests/SplFixedArray__construct_param_string.phpt
+++ b/ext/spl/tests/SplFixedArray__construct_param_string.phpt
@@ -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
diff --git a/ext/spl/tests/SplFixedArray_construct_param_SplFixedArray.phpt
b/ext/spl/tests/SplFixedArray_construct_param_SplFixedArray.phpt
index e91f110..10d4c64 100644
--- a/ext/spl/tests/SplFixedArray_construct_param_SplFixedArray.phpt
+++ b/ext/spl/tests/SplFixedArray_construct_param_SplFixedArray.phpt
@@ -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) {
-}
\ No newline at end of file
+Ok - SplFixedArray::__construct() expects parameter 1 to be integer, object given
diff --git a/ext/spl/tests/fixedarray_005.phpt b/ext/spl/tests/fixedarray_005.phpt
index fdd78f0..72970a9 100644
--- a/ext/spl/tests/fixedarray_005.phpt
+++ b/ext/spl/tests/fixedarray_005.phpt
@@ -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
diff --git a/ext/spl/tests/fixedarray_009.phpt b/ext/spl/tests/fixedarray_009.phpt
index c386fc6..d67c7cc 100644
--- a/ext/spl/tests/fixedarray_009.phpt
+++ b/ext/spl/tests/fixedarray_009.phpt
@@ -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
diff --git a/ext/spl/tests/fixedarray_015.phpt b/ext/spl/tests/fixedarray_015.phpt
index 6e31a42..f12d83b 100644
--- a/ext/spl/tests/fixedarray_015.phpt
+++ b/ext/spl/tests/fixedarray_015.phpt
@@ -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";
-}
-try {
- $a[1] = 1;
-} catch (Exception $e) {
- echo $e->getMessage(), "\n";
-}
try {
- var_dump(count($a[1]));
-} catch (Exception $e) {
- echo $e->getMessage(), "\n";
+ $a = new SplFixedArray('');
}
-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