]> granicus.if.org Git - php/commitdiff
Added test for bug #32993 (implemented Iterator function current() don't throw
authorDmitry Stogov <dmitry@php.net>
Mon, 6 Jun 2005 08:25:22 +0000 (08:25 +0000)
committerDmitry Stogov <dmitry@php.net>
Mon, 6 Jun 2005 08:25:22 +0000 (08:25 +0000)
  exception)

Zend/tests/bug32993.phpt [new file with mode: 0755]

diff --git a/Zend/tests/bug32993.phpt b/Zend/tests/bug32993.phpt
new file mode 100755 (executable)
index 0000000..88fb023
--- /dev/null
@@ -0,0 +1,29 @@
+--TEST--
+Bug #32993 (implemented Iterator function current() don't throw exception)
+--FILE--
+<?php
+class Test implements Iterator {
+
+    public $arr = array();
+
+    public function rewind()    { return reset($this->arr); }
+    public function current()   { throw new Exception(); }
+    public function key()       { return key($this->arr); }
+    public function next()      { return next($this->arr); }
+    public function valid()     { return (current($this->arr) !== false); }
+}
+
+$t = new Test();
+$t->arr =  array(1, 2, 3);
+
+try {
+    foreach ($t as $v) {
+        echo "$v\n";
+    }
+} catch (Exception $e) {
+    ; // handle exception
+}
+echo "ok\n";
+?>
+--EXPECT--
+ok