Annotation of embedaddon/php/ext/standard/tests/math/decoct_variation1.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test decoct() function : usage variations - different data types as $number arg
! 3: --INI--
! 4: precision=14
! 5: --SKIPIF--
! 6: <?php
! 7: if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
! 8: ?>
! 9: --FILE--
! 10: <?php
! 11: /* Prototype : string decoct ( int $number )
! 12: * Description: Returns a string containing an octal representation of the given number argument.
! 13: * Source code: ext/standard/math.c
! 14: */
! 15:
! 16: echo "*** Testing decoct() : usage variations ***\n";
! 17: //get an unset variable
! 18: $unset_var = 10;
! 19: unset ($unset_var);
! 20:
! 21:
! 22: // heredoc string
! 23: $heredoc = <<<EOT
! 24: abc
! 25: xyz
! 26: EOT;
! 27:
! 28: // get a class
! 29: class classA
! 30: {
! 31: }
! 32:
! 33: // get a resource variable
! 34: $fp = fopen(__FILE__, "r");
! 35:
! 36: $inputs = array(
! 37: // int data
! 38: /*1*/ 0,
! 39: 1,
! 40: 12345,
! 41: -2345,
! 42: 4294967295, // largest decimal
! 43: 4294967296,
! 44:
! 45: // float data
! 46: /*7*/ 10.5,
! 47: -10.5,
! 48: 12.3456789000e10,
! 49: 12.3456789000E-10,
! 50: .5,
! 51:
! 52: // null data
! 53: /*12*/ NULL,
! 54: null,
! 55:
! 56: // boolean data
! 57: /*14*/ true,
! 58: false,
! 59: TRUE,
! 60: FALSE,
! 61:
! 62: // empty data
! 63: /*18*/ "",
! 64: '',
! 65: array(),
! 66:
! 67: // string data
! 68: /*21*/ "abcxyz",
! 69: 'abcxyz',
! 70: $heredoc,
! 71:
! 72: // object data
! 73: /*24*/ new classA(),
! 74:
! 75: // undefined data
! 76: /*25*/ @$undefined_var,
! 77:
! 78: // unset data
! 79: /*26*/ @$unset_var,
! 80:
! 81: // resource variable
! 82: /*27*/ $fp
! 83: );
! 84:
! 85: // loop through each element of $inputs to check the behaviour of decoct()
! 86: $iterator = 1;
! 87: foreach($inputs as $input) {
! 88: echo "\n-- Iteration $iterator --\n";
! 89: var_dump(decoct($input));
! 90: $iterator++;
! 91: };
! 92: fclose($fp);
! 93: ?>
! 94: ===Done===
! 95: --EXPECTF--
! 96: *** Testing decoct() : usage variations ***
! 97:
! 98: -- Iteration 1 --
! 99: string(1) "0"
! 100:
! 101: -- Iteration 2 --
! 102: string(1) "1"
! 103:
! 104: -- Iteration 3 --
! 105: string(5) "30071"
! 106:
! 107: -- Iteration 4 --
! 108: string(11) "37777773327"
! 109:
! 110: -- Iteration 5 --
! 111: string(11) "37777777777"
! 112:
! 113: -- Iteration 6 --
! 114: string(1) "0"
! 115:
! 116: -- Iteration 7 --
! 117: string(2) "12"
! 118:
! 119: -- Iteration 8 --
! 120: string(11) "37777777766"
! 121:
! 122: -- Iteration 9 --
! 123: string(11) "27646215010"
! 124:
! 125: -- Iteration 10 --
! 126: string(1) "0"
! 127:
! 128: -- Iteration 11 --
! 129: string(1) "0"
! 130:
! 131: -- Iteration 12 --
! 132: string(1) "0"
! 133:
! 134: -- Iteration 13 --
! 135: string(1) "0"
! 136:
! 137: -- Iteration 14 --
! 138: string(1) "1"
! 139:
! 140: -- Iteration 15 --
! 141: string(1) "0"
! 142:
! 143: -- Iteration 16 --
! 144: string(1) "1"
! 145:
! 146: -- Iteration 17 --
! 147: string(1) "0"
! 148:
! 149: -- Iteration 18 --
! 150: string(1) "0"
! 151:
! 152: -- Iteration 19 --
! 153: string(1) "0"
! 154:
! 155: -- Iteration 20 --
! 156: string(1) "0"
! 157:
! 158: -- Iteration 21 --
! 159: string(1) "0"
! 160:
! 161: -- Iteration 22 --
! 162: string(1) "0"
! 163:
! 164: -- Iteration 23 --
! 165: string(1) "0"
! 166:
! 167: -- Iteration 24 --
! 168:
! 169: Notice: Object of class classA could not be converted to int in %s on line %d
! 170: string(1) "1"
! 171:
! 172: -- Iteration 25 --
! 173: string(1) "0"
! 174:
! 175: -- Iteration 26 --
! 176: string(1) "0"
! 177:
! 178: -- Iteration 27 --
! 179: string(%d) "%d"
! 180: ===Done===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>