]> granicus.if.org Git - php/commitdiff
add more tests (Felipe)
authorAntony Dovgal <tony2001@php.net>
Sat, 7 Jun 2008 14:10:42 +0000 (14:10 +0000)
committerAntony Dovgal <tony2001@php.net>
Sat, 7 Jun 2008 14:10:42 +0000 (14:10 +0000)
ext/spl/tests/fastarray_005.phpt [new file with mode: 0644]
ext/spl/tests/fastarray_006.phpt [new file with mode: 0644]
ext/spl/tests/fastarray_007.phpt [new file with mode: 0644]
ext/spl/tests/fastarray_008.phpt [new file with mode: 0644]
ext/spl/tests/fastarray_009.phpt [new file with mode: 0644]
ext/spl/tests/fastarray_010.phpt [new file with mode: 0644]
ext/spl/tests/fastarray_011.phpt [new file with mode: 0644]
ext/spl/tests/fastarray_012.phpt [new file with mode: 0644]
ext/spl/tests/fastarray_013.phpt [new file with mode: 0644]
ext/spl/tests/fastarray_014.phpt [new file with mode: 0644]

diff --git a/ext/spl/tests/fastarray_005.phpt b/ext/spl/tests/fastarray_005.phpt
new file mode 100644 (file)
index 0000000..0e6132a
--- /dev/null
@@ -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
diff --git a/ext/spl/tests/fastarray_006.phpt b/ext/spl/tests/fastarray_006.phpt
new file mode 100644 (file)
index 0000000..f9a4e59
--- /dev/null
@@ -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
diff --git a/ext/spl/tests/fastarray_007.phpt b/ext/spl/tests/fastarray_007.phpt
new file mode 100644 (file)
index 0000000..4cc46fe
--- /dev/null
@@ -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
diff --git a/ext/spl/tests/fastarray_008.phpt b/ext/spl/tests/fastarray_008.phpt
new file mode 100644 (file)
index 0000000..05986a2
--- /dev/null
@@ -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)
diff --git a/ext/spl/tests/fastarray_009.phpt b/ext/spl/tests/fastarray_009.phpt
new file mode 100644 (file)
index 0000000..daead11
--- /dev/null
@@ -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
diff --git a/ext/spl/tests/fastarray_010.phpt b/ext/spl/tests/fastarray_010.phpt
new file mode 100644 (file)
index 0000000..dcb2e81
--- /dev/null
@@ -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
diff --git a/ext/spl/tests/fastarray_011.phpt b/ext/spl/tests/fastarray_011.phpt
new file mode 100644 (file)
index 0000000..746e05f
--- /dev/null
@@ -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
diff --git a/ext/spl/tests/fastarray_012.phpt b/ext/spl/tests/fastarray_012.phpt
new file mode 100644 (file)
index 0000000..d5592f1
--- /dev/null
@@ -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
diff --git a/ext/spl/tests/fastarray_013.phpt b/ext/spl/tests/fastarray_013.phpt
new file mode 100644 (file)
index 0000000..edc53d9
--- /dev/null
@@ -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
diff --git a/ext/spl/tests/fastarray_014.phpt b/ext/spl/tests/fastarray_014.phpt
new file mode 100644 (file)
index 0000000..dfb45b3
--- /dev/null
@@ -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