]> granicus.if.org Git - php/commitdiff
Add more tests
authorMarcus Boerger <helly@php.net>
Mon, 22 Dec 2003 22:53:48 +0000 (22:53 +0000)
committerMarcus Boerger <helly@php.net>
Mon, 22 Dec 2003 22:53:48 +0000 (22:53 +0000)
Zend/tests/bug26229.phpt [new file with mode: 0755]
ext/reflection/tests/bug26695.phpt [new file with mode: 0755]
tests/lang/bug23524.phpt [new file with mode: 0755]
tests/strings/bug22592.phpt [new file with mode: 0755]

diff --git a/Zend/tests/bug26229.phpt b/Zend/tests/bug26229.phpt
new file mode 100755 (executable)
index 0000000..1e03bb2
--- /dev/null
@@ -0,0 +1,21 @@
+--TEST--
+Bug #26229 (getIterator() segfaults when it returns arrays or scalars)
+--FILE--
+<?php
+
+class array_iterator implements IteratorAggregate {
+        public function getIterator() {
+                return array('foo', 'bar');     
+        }
+}
+
+$obj = new array_iterator;
+
+foreach ($obj as $property => $value) {
+        var_dump($value);
+}
+?>
+===DONE===
+--EXPECTF--
+Warning: Objects returned by array_iterator::getIterator() must be traversable or implement interface Iterator in %sbug26229.php on line %d
+===DONE===
\ No newline at end of file
diff --git a/ext/reflection/tests/bug26695.phpt b/ext/reflection/tests/bug26695.phpt
new file mode 100755 (executable)
index 0000000..e2eab7e
--- /dev/null
@@ -0,0 +1,25 @@
+--TEST--
+Bug #26695 (Reflection API does not recognize mixed-case class hints)
+--FILE--
+<?php
+
+class Foo {
+}
+
+class Bar {
+  function demo(foo $f) {
+  }
+}
+
+$class = new Reflection_Class('bar');
+$methods = $class->getMethods();
+$params = $methods[0]->getParameters();
+
+$class = $params[0]->getClass();
+
+var_dump($class->getName());
+?>
+===DONE===
+--EXPECT--
+string(3) "Foo"
+===DONE===
\ No newline at end of file
diff --git a/tests/lang/bug23524.phpt b/tests/lang/bug23524.phpt
new file mode 100755 (executable)
index 0000000..18ffc33
--- /dev/null
@@ -0,0 +1,29 @@
+--TEST--
+Bug #23524 Improper handling of constants in array indeces
+--FILE--
+<?php
+  echo "Begin\n";
+  define("THE_CONST",123);
+  function f($a=array(THE_CONST=>THE_CONST)) {
+    print_r($a);
+  }
+  f();
+  f();
+  f();
+  echo "Done";
+?>
+--EXPECT--
+Begin
+Array
+(
+    [123] => 123
+)
+Array
+(
+    [123] => 123
+)
+Array
+(
+    [123] => 123
+)
+Done
diff --git a/tests/strings/bug22592.phpt b/tests/strings/bug22592.phpt
new file mode 100755 (executable)
index 0000000..0c13e50
--- /dev/null
@@ -0,0 +1,27 @@
+--TEST--
+Bug #22592 (Cascading assignments to strings with curly braces broken)
+--FILE--
+<?php
+$wrong = $correct = 'abcdef';
+
+$t = $x[] = 'x';
+
+var_dump($correct);
+var_dump($wrong);
+
+$correct{1} = '*';
+$correct{3} = '*';
+$correct{5} = '*';
+
+// This produces the 
+$wrong{1} = $wrong{3} = $wrong{5} = '*';
+
+var_dump($correct);
+var_dump($wrong);
+
+?>
+--EXPECT--
+string(6) "abcdef"
+string(6) "abcdef"
+string(6) "a*c*e*"
+string(6) "a*c*e*"