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