mirror of
https://github.com/php/php-src.git
synced 2026-04-14 19:41:05 +02:00
add more tests (Felipe)
This commit is contained in:
12
ext/spl/tests/fastarray_005.phpt
Normal file
12
ext/spl/tests/fastarray_005.phpt
Normal file
@@ -0,0 +1,12 @@
|
||||
--TEST--
|
||||
SPL: FastArray: Trying to instantiate passing object to constructor parameter
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$b = new stdClass;
|
||||
|
||||
$a = new SplFastArray($b);
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: SplFastArray::__construct() expects parameter 1 to be long, object given in %s on line %d
|
||||
22
ext/spl/tests/fastarray_006.phpt
Normal file
22
ext/spl/tests/fastarray_006.phpt
Normal file
@@ -0,0 +1,22 @@
|
||||
--TEST--
|
||||
SPL: FastArray: Assigning objects
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$b = 10000;
|
||||
$a = new SplFastArray($b);
|
||||
|
||||
try {
|
||||
for ($i = 0; $i < 100; $i++) {
|
||||
$a[] = new stdClass;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
|
||||
print "ok\n";
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
Index invalid or out of range
|
||||
ok
|
||||
26
ext/spl/tests/fastarray_007.phpt
Normal file
26
ext/spl/tests/fastarray_007.phpt
Normal file
@@ -0,0 +1,26 @@
|
||||
--TEST--
|
||||
SPL: FastArray: Assigning the itself object
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$b = 10;
|
||||
$a = new SplFastArray($b);
|
||||
|
||||
try {
|
||||
$a[1] = $a;
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
|
||||
foreach ($a as $c) {
|
||||
if ($c) {
|
||||
echo $c->getSize(), "\n";
|
||||
}
|
||||
}
|
||||
|
||||
print "ok\n";
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
10
|
||||
ok
|
||||
30
ext/spl/tests/fastarray_008.phpt
Normal file
30
ext/spl/tests/fastarray_008.phpt
Normal file
@@ -0,0 +1,30 @@
|
||||
--TEST--
|
||||
SPL: FastArray: Assigning the itself object testing the reference
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$b = 3;
|
||||
$a = new SplFastArray($b);
|
||||
|
||||
$a[0] = 1;
|
||||
$a[1] = 2;
|
||||
$a[2] = $a;
|
||||
|
||||
$a[2][0] = 3;
|
||||
|
||||
foreach ($a as $x) {
|
||||
if (is_object($x)) {
|
||||
var_dump($x[0]);
|
||||
} else {
|
||||
var_dump($x);
|
||||
}
|
||||
}
|
||||
|
||||
var_dump($a->getSize());
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
int(3)
|
||||
int(2)
|
||||
int(3)
|
||||
int(3)
|
||||
10
ext/spl/tests/fastarray_009.phpt
Normal file
10
ext/spl/tests/fastarray_009.phpt
Normal file
@@ -0,0 +1,10 @@
|
||||
--TEST--
|
||||
SPL: FastArray: Trying to instantiate passing string to construtor parameter
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$a = new SplFastArray('FOO');
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: SplFastArray::__construct() expects parameter 1 to be long, string given in %s on line %d
|
||||
16
ext/spl/tests/fastarray_010.phpt
Normal file
16
ext/spl/tests/fastarray_010.phpt
Normal file
@@ -0,0 +1,16 @@
|
||||
--TEST--
|
||||
SPL: FastArray: Setting size to 0
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$a = new SplFastArray(1);
|
||||
|
||||
$a[0] = 1;
|
||||
|
||||
$a->setSize(0);
|
||||
|
||||
print "ok\n";
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
ok
|
||||
14
ext/spl/tests/fastarray_011.phpt
Normal file
14
ext/spl/tests/fastarray_011.phpt
Normal file
@@ -0,0 +1,14 @@
|
||||
--TEST--
|
||||
SPL: FastArray: Testing setSize() with NULL
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$a = new SplFastArray(100);
|
||||
|
||||
$a->setSize(NULL);
|
||||
|
||||
print "ok\n";
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
ok
|
||||
19
ext/spl/tests/fastarray_012.phpt
Normal file
19
ext/spl/tests/fastarray_012.phpt
Normal file
@@ -0,0 +1,19 @@
|
||||
--TEST--
|
||||
SPL: FastArray: Assigning the object to another variable using []
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$a = new SplFastArray(100);
|
||||
|
||||
try {
|
||||
$b = &$a[];
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
|
||||
print "ok\n";
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
Index invalid or out of range
|
||||
ok
|
||||
21
ext/spl/tests/fastarray_013.phpt
Normal file
21
ext/spl/tests/fastarray_013.phpt
Normal file
@@ -0,0 +1,21 @@
|
||||
--TEST--
|
||||
SPL: FastArray: Passing the object using [] as parameter
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$a = new SplFastArray(100);
|
||||
|
||||
|
||||
function test(SplFastArray &$arr) {
|
||||
print "ok\n";
|
||||
}
|
||||
|
||||
try {
|
||||
test($a[]);
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
Index invalid or out of range
|
||||
15
ext/spl/tests/fastarray_014.phpt
Normal file
15
ext/spl/tests/fastarray_014.phpt
Normal file
@@ -0,0 +1,15 @@
|
||||
--TEST--
|
||||
SPL: FastArray: Trying to access inexistent item
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
try {
|
||||
$a = new SplFastArray(NULL);
|
||||
echo $a[0]++;
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
Index invalid or out of range
|
||||
Reference in New Issue
Block a user