Annotation of embedaddon/php/ext/standard/tests/array/reset_variation1.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test reset() function : usage variations - Pass different data types as $array_arg arg.
! 3: --FILE--
! 4: <?php
! 5: /* Prototype : mixed reset(array $array_arg)
! 6: * Description: Set array argument's internal pointer to the first element and return it
! 7: * Source code: ext/standard/array.c
! 8: */
! 9:
! 10: /*
! 11: * Pass different data types as $array_arg argument to reset() to test behaviour
! 12: */
! 13:
! 14: echo "*** Testing reset() : usage variations ***\n";
! 15:
! 16: //get an unset variable
! 17: $unset_var = 10;
! 18: unset ($unset_var);
! 19:
! 20: // get a class
! 21: class classA
! 22: {
! 23: public function __toString() {
! 24: return "Class A object";
! 25: }
! 26: }
! 27:
! 28: // heredoc string
! 29: $heredoc = <<<EOT
! 30: hello world
! 31: EOT;
! 32:
! 33: // get a resource variable
! 34: $fp = fopen(__FILE__, "r");
! 35:
! 36: // unexpected values to be passed to $array_arg argument
! 37: $inputs = array(
! 38:
! 39: // int data
! 40: /*1*/ 0,
! 41: 1,
! 42: 12345,
! 43: -2345,
! 44:
! 45: // float data
! 46: /*5*/ 10.5,
! 47: -10.5,
! 48: 12.3456789000e10,
! 49: 12.3456789000E-10,
! 50: .5,
! 51:
! 52: // null data
! 53: /*10*/ NULL,
! 54: null,
! 55:
! 56: // boolean data
! 57: /*12*/ true,
! 58: false,
! 59: TRUE,
! 60: FALSE,
! 61:
! 62: // empty data
! 63: /*16*/ "",
! 64: '',
! 65: array(),
! 66:
! 67: // string data
! 68: /*19*/ "string",
! 69: 'string',
! 70: $heredoc,
! 71:
! 72: // object data
! 73: /*22*/ new classA(),
! 74:
! 75: // undefined data
! 76: /*23*/ @$undefined_var,
! 77:
! 78: // unset data
! 79: /*24*/ @$unset_var,
! 80:
! 81: // resource variable
! 82: /*25*/ $fp
! 83: );
! 84:
! 85: // loop through each element of $inputs to check the behavior of reset()
! 86: $iterator = 1;
! 87: foreach($inputs as $input) {
! 88: echo "\n-- Iteration $iterator --\n";
! 89: var_dump( reset($input) );
! 90: $iterator++;
! 91: };
! 92:
! 93: fclose($fp);
! 94: ?>
! 95: ===DONE===
! 96: --EXPECTF--
! 97: *** Testing reset() : usage variations ***
! 98:
! 99: -- Iteration 1 --
! 100:
! 101: Warning: reset() expects parameter 1 to be array, integer given in %s on line %d
! 102: NULL
! 103:
! 104: -- Iteration 2 --
! 105:
! 106: Warning: reset() expects parameter 1 to be array, integer given in %s on line %d
! 107: NULL
! 108:
! 109: -- Iteration 3 --
! 110:
! 111: Warning: reset() expects parameter 1 to be array, integer given in %s on line %d
! 112: NULL
! 113:
! 114: -- Iteration 4 --
! 115:
! 116: Warning: reset() expects parameter 1 to be array, integer given in %s on line %d
! 117: NULL
! 118:
! 119: -- Iteration 5 --
! 120:
! 121: Warning: reset() expects parameter 1 to be array, double given in %s on line %d
! 122: NULL
! 123:
! 124: -- Iteration 6 --
! 125:
! 126: Warning: reset() expects parameter 1 to be array, double given in %s on line %d
! 127: NULL
! 128:
! 129: -- Iteration 7 --
! 130:
! 131: Warning: reset() expects parameter 1 to be array, double given in %s on line %d
! 132: NULL
! 133:
! 134: -- Iteration 8 --
! 135:
! 136: Warning: reset() expects parameter 1 to be array, double given in %s on line %d
! 137: NULL
! 138:
! 139: -- Iteration 9 --
! 140:
! 141: Warning: reset() expects parameter 1 to be array, double given in %s on line %d
! 142: NULL
! 143:
! 144: -- Iteration 10 --
! 145:
! 146: Warning: reset() expects parameter 1 to be array, null given in %s on line %d
! 147: NULL
! 148:
! 149: -- Iteration 11 --
! 150:
! 151: Warning: reset() expects parameter 1 to be array, null given in %s on line %d
! 152: NULL
! 153:
! 154: -- Iteration 12 --
! 155:
! 156: Warning: reset() expects parameter 1 to be array, boolean given in %s on line %d
! 157: NULL
! 158:
! 159: -- Iteration 13 --
! 160:
! 161: Warning: reset() expects parameter 1 to be array, boolean given in %s on line %d
! 162: NULL
! 163:
! 164: -- Iteration 14 --
! 165:
! 166: Warning: reset() expects parameter 1 to be array, boolean given in %s on line %d
! 167: NULL
! 168:
! 169: -- Iteration 15 --
! 170:
! 171: Warning: reset() expects parameter 1 to be array, boolean given in %s on line %d
! 172: NULL
! 173:
! 174: -- Iteration 16 --
! 175:
! 176: Warning: reset() expects parameter 1 to be array, string given in %s on line %d
! 177: NULL
! 178:
! 179: -- Iteration 17 --
! 180:
! 181: Warning: reset() expects parameter 1 to be array, string given in %s on line %d
! 182: NULL
! 183:
! 184: -- Iteration 18 --
! 185: bool(false)
! 186:
! 187: -- Iteration 19 --
! 188:
! 189: Warning: reset() expects parameter 1 to be array, string given in %s on line %d
! 190: NULL
! 191:
! 192: -- Iteration 20 --
! 193:
! 194: Warning: reset() expects parameter 1 to be array, string given in %s on line %d
! 195: NULL
! 196:
! 197: -- Iteration 21 --
! 198:
! 199: Warning: reset() expects parameter 1 to be array, string given in %s on line %d
! 200: NULL
! 201:
! 202: -- Iteration 22 --
! 203: bool(false)
! 204:
! 205: -- Iteration 23 --
! 206:
! 207: Warning: reset() expects parameter 1 to be array, null given in %s on line %d
! 208: NULL
! 209:
! 210: -- Iteration 24 --
! 211:
! 212: Warning: reset() expects parameter 1 to be array, null given in %s on line %d
! 213: NULL
! 214:
! 215: -- Iteration 25 --
! 216:
! 217: Warning: reset() expects parameter 1 to be array, resource given in %s on line %d
! 218: NULL
! 219: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>