Annotation of embedaddon/php/ext/spl/tests/array_010.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: SPL: ArrayIterator implements ArrayAccess
! 3: --FILE--
! 4: <?php
! 5:
! 6: $obj = new ArrayObject(array('1st', 1, 2=>'3rd', '4th'=>4));
! 7:
! 8: var_dump($obj->getArrayCopy());
! 9:
! 10: echo "===EMPTY===\n";
! 11: var_dump(empty($obj[0]));
! 12: var_dump(empty($obj[1]));
! 13: var_dump(empty($obj[2]));
! 14: var_dump(empty($obj['4th']));
! 15: var_dump(empty($obj['5th']));
! 16: var_dump(empty($obj[6]));
! 17:
! 18: echo "===isset===\n";
! 19: var_dump(isset($obj[0]));
! 20: var_dump(isset($obj[1]));
! 21: var_dump(isset($obj[2]));
! 22: var_dump(isset($obj['4th']));
! 23: var_dump(isset($obj['5th']));
! 24: var_dump(isset($obj[6]));
! 25:
! 26: echo "===offsetGet===\n";
! 27: var_dump($obj[0]);
! 28: var_dump($obj[1]);
! 29: var_dump($obj[2]);
! 30: var_dump($obj['4th']);
! 31: var_dump($obj['5th']);
! 32: var_dump($obj[6]);
! 33:
! 34: echo "===offsetSet===\n";
! 35: echo "WRITE 1\n";
! 36: $obj[1] = 'Changed 1';
! 37: var_dump($obj[1]);
! 38: echo "WRITE 2\n";
! 39: $obj['4th'] = 'Changed 4th';
! 40: var_dump($obj['4th']);
! 41: echo "WRITE 3\n";
! 42: $obj['5th'] = 'Added 5th';
! 43: var_dump($obj['5th']);
! 44: echo "WRITE 4\n";
! 45: $obj[6] = 'Added 6';
! 46: var_dump($obj[6]);
! 47:
! 48: var_dump($obj[0]);
! 49: var_dump($obj[2]);
! 50:
! 51: $x = $obj[6] = 'changed 6';
! 52: var_dump($obj[6]);
! 53: var_dump($x);
! 54:
! 55: echo "===unset===\n";
! 56: var_dump($obj->getArrayCopy());
! 57: unset($obj[2]);
! 58: unset($obj['4th']);
! 59: unset($obj[7]);
! 60: unset($obj['8th']);
! 61: var_dump($obj->getArrayCopy());
! 62:
! 63: ?>
! 64: ===DONE===
! 65: <?php exit(0); ?>
! 66: --EXPECTF--
! 67: array(4) {
! 68: [0]=>
! 69: string(3) "1st"
! 70: [1]=>
! 71: int(1)
! 72: [2]=>
! 73: string(3) "3rd"
! 74: ["4th"]=>
! 75: int(4)
! 76: }
! 77: ===EMPTY===
! 78: bool(false)
! 79: bool(false)
! 80: bool(false)
! 81: bool(false)
! 82: bool(true)
! 83: bool(true)
! 84: ===isset===
! 85: bool(true)
! 86: bool(true)
! 87: bool(true)
! 88: bool(true)
! 89: bool(false)
! 90: bool(false)
! 91: ===offsetGet===
! 92: string(3) "1st"
! 93: int(1)
! 94: string(3) "3rd"
! 95: int(4)
! 96:
! 97: Notice: Undefined index: 5th in %sarray_010.php on line %d
! 98: NULL
! 99:
! 100: Notice: Undefined offset: 6 in %sarray_010.php on line %d
! 101: NULL
! 102: ===offsetSet===
! 103: WRITE 1
! 104: string(9) "Changed 1"
! 105: WRITE 2
! 106: string(11) "Changed 4th"
! 107: WRITE 3
! 108: string(9) "Added 5th"
! 109: WRITE 4
! 110: string(7) "Added 6"
! 111: string(3) "1st"
! 112: string(3) "3rd"
! 113: string(9) "changed 6"
! 114: string(9) "changed 6"
! 115: ===unset===
! 116: array(6) {
! 117: [0]=>
! 118: string(3) "1st"
! 119: [1]=>
! 120: string(9) "Changed 1"
! 121: [2]=>
! 122: string(3) "3rd"
! 123: ["4th"]=>
! 124: string(11) "Changed 4th"
! 125: ["5th"]=>
! 126: string(9) "Added 5th"
! 127: [6]=>
! 128: string(9) "changed 6"
! 129: }
! 130:
! 131: Notice: Undefined offset: 7 in %sarray_010.php on line %d
! 132:
! 133: Notice: Undefined index: 8th in %sarray_010.php on line %d
! 134: array(4) {
! 135: [0]=>
! 136: string(3) "1st"
! 137: [1]=>
! 138: string(9) "Changed 1"
! 139: ["5th"]=>
! 140: string(9) "Added 5th"
! 141: [6]=>
! 142: string(9) "changed 6"
! 143: }
! 144: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>