diff options
| author | Ant Phillips <ant@php.net> | 2008-11-27 14:30:58 +0000 |
|---|---|---|
| committer | Ant Phillips <ant@php.net> | 2008-11-27 14:30:58 +0000 |
| commit | 74464841814dc32b83b7ba027332d3180addaa6b (patch) | |
| tree | ea2c8e37d8fca41034dfc436c322efc5b08a2682 | |
| parent | bc804655492128a6691d78f6774e54c6990c58d8 (diff) | |
| download | php-git-74464841814dc32b83b7ba027332d3180addaa6b.tar.gz | |
Latest and greatest versions of these session tests - checked on 5.2.X snap on Windows, Linux and Linux 64 bit.
| -rw-r--r-- | ext/standard/tests/reg/commit.eregi_variation_001.phpt | 178 | ||||
| -rw-r--r-- | ext/standard/tests/reg/commit.eregi_variation_002.phpt | 169 | ||||
| -rw-r--r-- | ext/standard/tests/reg/commit.eregi_variation_003.phpt | 283 | ||||
| -rw-r--r-- | ext/standard/tests/reg/commit.eregi_variation_004.phpt | 18 |
4 files changed, 648 insertions, 0 deletions
diff --git a/ext/standard/tests/reg/commit.eregi_variation_001.phpt b/ext/standard/tests/reg/commit.eregi_variation_001.phpt new file mode 100644 index 0000000000..ea8b8440dc --- /dev/null +++ b/ext/standard/tests/reg/commit.eregi_variation_001.phpt @@ -0,0 +1,178 @@ +--TEST-- +Test eregi() function : usage variations - unexpected type arg 1 +--FILE-- +<?php +/* Prototype : proto int eregi(string pattern, string string [, array registers]) + * Description: Regular expression match + * Source code: ext/standard/reg.c + * Alias to functions: + */ + +function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) { + echo "Error: $err_no - $err_msg, $filename($linenum)\n"; +} +set_error_handler('test_error_handler'); + + +echo "*** Testing eregi() : usage variations ***\n"; + +// Initialise function arguments not being substituted (if any) +$string = '1'; +$registers = array(1, 2); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +//array of values to iterate over +$values = array( + + // int data + 0, + 1, + 12345, + -2345, + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // object data + new stdclass(), + + // undefined data + $undefined_var, + + // unset data + $unset_var, +); + +// loop through each element of the array for pattern + +foreach($values as $value) { + echo "\nArg value $value \n"; + var_dump( eregi($value, $string, $registers) ); +}; + +echo "Done"; +?> +--EXPECTF-- +*** Testing eregi() : usage variations *** +Error: 8 - Undefined variable: undefined_var, %s(65) +Error: 8 - Undefined variable: unset_var, %s(68) + +Arg value 0 +bool(false) + +Arg value 1 +int(1) + +Arg value 12345 +bool(false) + +Arg value -2345 +bool(false) + +Arg value 10.5 +bool(false) + +Arg value -10.5 +bool(false) + +Arg value 101234567000 +bool(false) + +Arg value 1.07654321E-9 +bool(false) + +Arg value 0.5 +bool(false) + +Arg value Array +Error: 8 - Array to string conversion, %s(75) +bool(false) + +Arg value Array +Error: 8 - Array to string conversion, %s(75) +bool(false) + +Arg value Array +Error: 8 - Array to string conversion, %s(75) +bool(false) + +Arg value Array +Error: 8 - Array to string conversion, %s(75) +bool(false) + +Arg value Array +Error: 8 - Array to string conversion, %s(75) +bool(false) + +Arg value +Error: 2 - eregi(): REG_EMPTY, %s(75) +bool(false) + +Arg value +Error: 2 - eregi(): REG_EMPTY, %s(75) +bool(false) + +Arg value 1 +int(1) + +Arg value +Error: 2 - eregi(): REG_EMPTY, %s(75) +bool(false) + +Arg value 1 +int(1) + +Arg value +Error: 2 - eregi(): REG_EMPTY, %s(75) +bool(false) + +Arg value +Error: 2 - eregi(): REG_EMPTY, %s(75) +bool(false) + +Arg value +Error: 2 - eregi(): REG_EMPTY, %s(75) +bool(false) +Error: 4096 - Object of class stdClass could not be converted to string, %s(74) + +Arg value +Error: 4096 - Object of class stdClass could not be converted to string, %s(75) +Error: 8 - Object of class stdClass to string conversion, %s(75) +bool(false) + +Arg value +Error: 2 - eregi(): REG_EMPTY, %s(75) +bool(false) + +Arg value +Error: 2 - eregi(): REG_EMPTY, %s(75) +bool(false) +Done
\ No newline at end of file diff --git a/ext/standard/tests/reg/commit.eregi_variation_002.phpt b/ext/standard/tests/reg/commit.eregi_variation_002.phpt new file mode 100644 index 0000000000..766a48abd3 --- /dev/null +++ b/ext/standard/tests/reg/commit.eregi_variation_002.phpt @@ -0,0 +1,169 @@ +--TEST-- +Test eregi() function : usage variations - unexpected type arg 2 +--FILE-- +<?php +/* Prototype : proto int eregi(string pattern, string string [, array registers]) + * Description: Regular expression match + * Source code: ext/standard/reg.c + * Alias to functions: + */ + +function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) { + echo "Error: $err_no - $err_msg, $filename($linenum)\n"; +} +set_error_handler('test_error_handler'); + +echo "*** Testing eregi() : usage variations ***\n"; + +// Initialise function arguments not being substituted (if any) +$pattern = '1'; +$registers = array(); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +//array of values to iterate over +$values = array( + + // int data + 0, + 1, + 12345, + -2345, + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // object data + new stdclass(), + + // undefined data + $undefined_var, + + // unset data + $unset_var, +); + +// loop through each element of the array for string + +foreach($values as $value) { + echo "\nArg value $value \n"; + var_dump( eregi($pattern, $value, $registers) ); +}; + +echo "Done"; +?> +--EXPECTF-- +*** Testing eregi() : usage variations *** +Error: 8 - Undefined variable: undefined_var, %s(64) +Error: 8 - Undefined variable: unset_var, %s(67) + +Arg value 0 +bool(false) + +Arg value 1 +int(1) + +Arg value 12345 +int(1) + +Arg value -2345 +bool(false) + +Arg value 10.5 +int(1) + +Arg value -10.5 +int(1) + +Arg value 101234567000 +int(1) + +Arg value 1.07654321E-9 +int(1) + +Arg value 0.5 +bool(false) + +Arg value Array +Error: 8 - Array to string conversion, %s(74) +bool(false) + +Arg value Array +Error: 8 - Array to string conversion, %s(74) +bool(false) + +Arg value Array +Error: 8 - Array to string conversion, %s(74) +bool(false) + +Arg value Array +Error: 8 - Array to string conversion, %s(74) +bool(false) + +Arg value Array +Error: 8 - Array to string conversion, %s(74) +bool(false) + +Arg value +bool(false) + +Arg value +bool(false) + +Arg value 1 +int(1) + +Arg value +bool(false) + +Arg value 1 +int(1) + +Arg value +bool(false) + +Arg value +bool(false) + +Arg value +bool(false) +Error: 4096 - Object of class stdClass could not be converted to string, %s(73) + +Arg value +Error: 4096 - Object of class stdClass could not be converted to string, %s(74) +Error: 8 - Object of class stdClass to string conversion, %s(74) +bool(false) + +Arg value +bool(false) + +Arg value +bool(false) +Done
\ No newline at end of file diff --git a/ext/standard/tests/reg/commit.eregi_variation_003.phpt b/ext/standard/tests/reg/commit.eregi_variation_003.phpt new file mode 100644 index 0000000000..43785871a9 --- /dev/null +++ b/ext/standard/tests/reg/commit.eregi_variation_003.phpt @@ -0,0 +1,283 @@ +--TEST-- +Test eregi() function : usage variations - unexpected type for arg 3 +--FILE-- +<?php +/* Prototype : proto int eregi(string pattern, string string [, array registers]) + * Description: Regular expression match + * Source code: ext/standard/reg.c + * Alias to functions: + */ + +function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) { + echo "Error: $err_no - $err_msg, $filename($linenum)\n"; +} +set_error_handler('test_error_handler'); + +echo "*** Testing eregi() : usage variations ***\n"; + +// Initialise function arguments not being substituted (if any) +$pattern = 'h(.*)lo!'; +$string = 'hello!'; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +//array of values to iterate over +$values = array( + + // int data + 0, + 1, + 12345, + -2345, + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // string data + "string", + 'string', + + // object data + new stdclass(), + + // undefined data + $undefined_var, + + // unset data + $unset_var, +); + +// loop through each element of the array for registers + +foreach($values as $value) { + echo "\nArg value $value \n"; + var_dump( eregi($pattern, $string, $value) ); + var_dump($value); +}; + +echo "Done"; +?> +--EXPECTF-- +*** Testing eregi() : usage variations *** +Error: 8 - Undefined variable: undefined_var, %s(61) +Error: 8 - Undefined variable: unset_var, %s(64) + +Arg value 0 +int(6) +array(2) { + [0]=> + string(6) "hello!" + [1]=> + string(2) "el" +} + +Arg value 1 +int(6) +array(2) { + [0]=> + string(6) "hello!" + [1]=> + string(2) "el" +} + +Arg value 12345 +int(6) +array(2) { + [0]=> + string(6) "hello!" + [1]=> + string(2) "el" +} + +Arg value -2345 +int(6) +array(2) { + [0]=> + string(6) "hello!" + [1]=> + string(2) "el" +} + +Arg value 10.5 +int(6) +array(2) { + [0]=> + string(6) "hello!" + [1]=> + string(2) "el" +} + +Arg value -10.5 +int(6) +array(2) { + [0]=> + string(6) "hello!" + [1]=> + string(2) "el" +} + +Arg value 101234567000 +int(6) +array(2) { + [0]=> + string(6) "hello!" + [1]=> + string(2) "el" +} + +Arg value 1.07654321E-9 +int(6) +array(2) { + [0]=> + string(6) "hello!" + [1]=> + string(2) "el" +} + +Arg value 0.5 +int(6) +array(2) { + [0]=> + string(6) "hello!" + [1]=> + string(2) "el" +} + +Arg value +int(6) +array(2) { + [0]=> + string(6) "hello!" + [1]=> + string(2) "el" +} + +Arg value +int(6) +array(2) { + [0]=> + string(6) "hello!" + [1]=> + string(2) "el" +} + +Arg value 1 +int(6) +array(2) { + [0]=> + string(6) "hello!" + [1]=> + string(2) "el" +} + +Arg value +int(6) +array(2) { + [0]=> + string(6) "hello!" + [1]=> + string(2) "el" +} + +Arg value 1 +int(6) +array(2) { + [0]=> + string(6) "hello!" + [1]=> + string(2) "el" +} + +Arg value +int(6) +array(2) { + [0]=> + string(6) "hello!" + [1]=> + string(2) "el" +} + +Arg value +int(6) +array(2) { + [0]=> + string(6) "hello!" + [1]=> + string(2) "el" +} + +Arg value +int(6) +array(2) { + [0]=> + string(6) "hello!" + [1]=> + string(2) "el" +} + +Arg value string +int(6) +array(2) { + [0]=> + string(6) "hello!" + [1]=> + string(2) "el" +} + +Arg value string +int(6) +array(2) { + [0]=> + string(6) "hello!" + [1]=> + string(2) "el" +} +Error: 4096 - Object of class stdClass could not be converted to string, %s(70) + +Arg value +int(6) +array(2) { + [0]=> + string(6) "hello!" + [1]=> + string(2) "el" +} + +Arg value +int(6) +array(2) { + [0]=> + string(6) "hello!" + [1]=> + string(2) "el" +} + +Arg value +int(6) +array(2) { + [0]=> + string(6) "hello!" + [1]=> + string(2) "el" +} +Done
\ No newline at end of file diff --git a/ext/standard/tests/reg/commit.eregi_variation_004.phpt b/ext/standard/tests/reg/commit.eregi_variation_004.phpt new file mode 100644 index 0000000000..bf4f036950 --- /dev/null +++ b/ext/standard/tests/reg/commit.eregi_variation_004.phpt @@ -0,0 +1,18 @@ +--TEST-- +Test eregi() function : usage variations - pass non-variable as arg 3, which is pass-by-ref. +--FILE-- +<?php +/* Prototype : proto int eregi(string pattern, string string [, array registers]) + * Description: Regular expression match + * Source code: ext/standard/reg.c + * Alias to functions: + */ + +var_dump(eregi('l{2}', 'hello', str_repeat('x',1))); +echo "Done"; +?> +--EXPECTF-- + +Strict Standards: Only variables should be passed by reference in %s on line 8 +int(2) +Done
\ No newline at end of file |
