Annotation of embedaddon/php/ext/mbstring/tests/mb_ereg_variation1.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test mb_ereg() function : usage variations - pass different data types to $pattern argument
! 3: --SKIPIF--
! 4: <?php
! 5: extension_loaded('mbstring') or die('skip');
! 6: function_exists('mb_ereg') or die("skip mb_ereg() is not available in this build");
! 7: ?>
! 8: --FILE--
! 9: <?php
! 10: /* Prototype : int mb_ereg(string $pattern, string $string [, array $registers])
! 11: * Description: Regular expression match for multibyte string
! 12: * Source code: ext/mbstring/php_mbregex.c
! 13: */
! 14:
! 15: /*
! 16: * Pass different data types to $pattern argument
! 17: */
! 18:
! 19: echo "*** Testing mb_ereg() : usage variations ***\n";
! 20:
! 21: // Initialise function arguments not being substituted (if any)
! 22: $string = 'string value';
! 23:
! 24: //get an unset variable
! 25: $unset_var = 10;
! 26: unset ($unset_var);
! 27:
! 28: // get a class
! 29: class classA
! 30: {
! 31: public function __toString() {
! 32: return "Class A object";
! 33: }
! 34: }
! 35:
! 36: // heredoc string
! 37: $heredoc = <<<EOT
! 38: hello world
! 39: EOT;
! 40:
! 41: // get a resource variable
! 42: $fp = fopen(__FILE__, "r");
! 43:
! 44: // unexpected values to be passed to $pattern argument
! 45: $inputs = array(
! 46:
! 47: // int data
! 48: /*1*/ 0,
! 49: 1,
! 50: 12345,
! 51: -2345,
! 52:
! 53: // float data
! 54: /*5*/ 10.5,
! 55: -10.5,
! 56: 12.3456789000e10,
! 57: 12.3456789000E-10,
! 58: .5,
! 59:
! 60: // boolean data
! 61: /*10*/ true,
! 62: TRUE,
! 63:
! 64: // string data
! 65: /*12*/ "string",
! 66: 'string',
! 67: $heredoc,
! 68:
! 69: // object data
! 70: /*15*/ new classA(),
! 71:
! 72: // resource variable
! 73: /*16*/ $fp
! 74: );
! 75:
! 76: // loop through each element of $inputs to check the behavior of mb_ereg()
! 77: $iterator = 1;
! 78: foreach($inputs as $input) {
! 79: if (@is_array($regs)){
! 80: $regs = null;
! 81: }
! 82: echo "\n-- Iteration $iterator --\n";
! 83: var_dump( mb_ereg($input, $string, $regs) );
! 84: var_dump($regs);
! 85: $iterator++;
! 86: };
! 87:
! 88: fclose($fp);
! 89:
! 90: echo "Done";
! 91: ?>
! 92:
! 93: --EXPECTF--
! 94: *** Testing mb_ereg() : usage variations ***
! 95:
! 96: -- Iteration 1 --
! 97: bool(false)
! 98: NULL
! 99:
! 100: -- Iteration 2 --
! 101: bool(false)
! 102: NULL
! 103:
! 104: -- Iteration 3 --
! 105: bool(false)
! 106: NULL
! 107:
! 108: -- Iteration 4 --
! 109: bool(false)
! 110: NULL
! 111:
! 112: -- Iteration 5 --
! 113: bool(false)
! 114: NULL
! 115:
! 116: -- Iteration 6 --
! 117: bool(false)
! 118: NULL
! 119:
! 120: -- Iteration 7 --
! 121: bool(false)
! 122: NULL
! 123:
! 124: -- Iteration 8 --
! 125: bool(false)
! 126: NULL
! 127:
! 128: -- Iteration 9 --
! 129: bool(false)
! 130: NULL
! 131:
! 132: -- Iteration 10 --
! 133: bool(false)
! 134: NULL
! 135:
! 136: -- Iteration 11 --
! 137: bool(false)
! 138: NULL
! 139:
! 140: -- Iteration 12 --
! 141: int(6)
! 142: array(1) {
! 143: [0]=>
! 144: string(6) "string"
! 145: }
! 146:
! 147: -- Iteration 13 --
! 148: int(6)
! 149: array(1) {
! 150: [0]=>
! 151: string(6) "string"
! 152: }
! 153:
! 154: -- Iteration 14 --
! 155: bool(false)
! 156: NULL
! 157:
! 158: -- Iteration 15 --
! 159: bool(false)
! 160: NULL
! 161:
! 162: -- Iteration 16 --
! 163: bool(false)
! 164: NULL
! 165: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>