Annotation of embedaddon/php/ext/spl/tests/bug31185.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Bug #31185 (Crash when exceptions thrown from ArrayAccess::offsetUnset())
                      3: --FILE--
                      4: <?php
                      5: 
                      6: class FooBar implements ArrayAccess {
                      7:        private $array = array();
                      8: 
                      9:        public function offsetExists($index) {
                     10:                return isset($this->array[$index]);
                     11:        }
                     12: 
                     13:        public function offsetGet($index) {
                     14:                return $this->array[$index];
                     15:        }
                     16: 
                     17:        public function offsetSet($index, $value) {
                     18:                echo __METHOD__ . "($index, $value)\n";
                     19:                $this->array[$index] = $value;
                     20:        }
                     21: 
                     22:        public function offsetUnset($index) {
                     23:                throw new Exception('FAIL');
                     24:                unset($this->array[$index]);
                     25:        }
                     26: 
                     27: }
                     28: 
                     29: $i = 0; $j = 0;
                     30: $foo = new FooBar();
                     31: $foo[$j++] = $i++;
                     32: $foo[$j++] = $i++;
                     33: $foo[$j++] = $i++;
                     34: try
                     35: {
                     36:        unset($foo[1]);
                     37: }
                     38: catch (Exception $e)
                     39: {
                     40:        echo "CAUGHT: " . $e->getMessage() . "\n";
                     41: }
                     42: 
                     43: print_R($foo);
                     44: ?>
                     45: ===DONE===
                     46: --EXPECT--
                     47: FooBar::offsetSet(0, 0)
                     48: FooBar::offsetSet(1, 1)
                     49: FooBar::offsetSet(2, 2)
                     50: CAUGHT: FAIL
                     51: FooBar Object
                     52: (
                     53:     [array:FooBar:private] => Array
                     54:         (
                     55:             [0] => 0
                     56:             [1] => 1
                     57:             [2] => 2
                     58:         )
                     59: 
                     60: )
                     61: ===DONE===

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>