diff options
Diffstat (limited to 'ext/standard/tests')
| -rw-r--r-- | ext/standard/tests/array/bug35014.phpt | 6 | ||||
| -rw-r--r-- | ext/standard/tests/array/bug35014_64bit.phpt | 36 | ||||
| -rw-r--r-- | ext/standard/tests/array/bug35821.phpt | 33 | ||||
| -rw-r--r-- | ext/standard/tests/file/bug35740.phpt | 14 | ||||
| -rw-r--r-- | ext/standard/tests/file/bug35781.phpt | 24 | ||||
| -rw-r--r-- | ext/standard/tests/file/proc_open01.phpt | 4 | ||||
| -rw-r--r-- | ext/standard/tests/filters/bug35916.phpt | 42 | ||||
| -rw-r--r-- | ext/standard/tests/general_functions/bug27678.phpt | 14 | ||||
| -rw-r--r-- | ext/standard/tests/general_functions/bug32647.phpt | 20 | ||||
| -rw-r--r-- | ext/standard/tests/general_functions/sunfuncts.phpt | 48 | ||||
| -rw-r--r-- | ext/standard/tests/strings/bug35817.phpt | 29 | ||||
| -rw-r--r-- | ext/standard/tests/strings/http_build_query.phpt | 15 | ||||
| -rw-r--r-- | ext/standard/tests/strings/str_word_count.phpt | 30 | ||||
| -rw-r--r-- | ext/standard/tests/strings/url_t.phpt | 13 |
14 files changed, 290 insertions, 38 deletions
diff --git a/ext/standard/tests/array/bug35014.phpt b/ext/standard/tests/array/bug35014.phpt index 213bacae3..99ef0f7eb 100644 --- a/ext/standard/tests/array/bug35014.phpt +++ b/ext/standard/tests/array/bug35014.phpt @@ -1,5 +1,7 @@ --TEST-- -Bug #35014 (array_product() always returns 0) +Bug #35014 (array_product() always returns 0) (32bit) +--SKIPIF-- +<?php if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); ?> --INI-- precision=14 --FILE-- @@ -22,7 +24,7 @@ foreach ($tests as $v) { ?> --EXPECTF-- -Warning: array_product(): The argument should be an array in %s/bug35014.php on line 15 +Warning: array_product(): The argument should be an array in %s on line %d NULL int(0) int(0) diff --git a/ext/standard/tests/array/bug35014_64bit.phpt b/ext/standard/tests/array/bug35014_64bit.phpt new file mode 100644 index 000000000..a5b8da8a3 --- /dev/null +++ b/ext/standard/tests/array/bug35014_64bit.phpt @@ -0,0 +1,36 @@ +--TEST-- +Bug #35014 (array_product() always returns 0) (64bit) +--SKIPIF-- +<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); ?> +--INI-- +precision=14 +--FILE-- +<?php +$tests = array( + 'foo', + array(), + array(0), + array(3), + array(3, 3), + array(0.5, 2), + array(99999999, 99999999), + array(8.993, 7443241,988, sprintf("%u", -1)+0.44), + array(2,sprintf("%u", -1)), +); + +foreach ($tests as $v) { + var_dump(array_product($v)); +} +?> +--EXPECTF-- + +Warning: array_product(): The argument should be an array in %s on line %d +NULL +int(0) +int(0) +int(3) +int(9) +float(1) +int(9999999800000001) +float(2.8404260053903E+20) +int(8589934590) diff --git a/ext/standard/tests/array/bug35821.phpt b/ext/standard/tests/array/bug35821.phpt new file mode 100644 index 000000000..095323ebc --- /dev/null +++ b/ext/standard/tests/array/bug35821.phpt @@ -0,0 +1,33 @@ +--TEST-- +Bug #35821 (array_map() segfaults when exception is throwed from the callback) +--FILE-- +<?php + +class Element +{ + public function ThrowException () + { + throw new Exception(); + } + + public static function CallBack(Element $elem) + { + $elem->ThrowException(); + } +} + +$arr = array(new Element(), new Element(), new Element()); +array_map(array('Element', 'CallBack'), $arr); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: array_map(): An error occurred while invoking the map callback in %s on line %d + +Fatal error: Uncaught exception 'Exception' in %s:%d +Stack trace: +#0 %s(%d): Element->ThrowException() +#1 [internal function]: Element::CallBack(Object(Element)) +#2 %s(%d): array_map(Array, Array) +#3 {main} + thrown in %s on line %d diff --git a/ext/standard/tests/file/bug35740.phpt b/ext/standard/tests/file/bug35740.phpt new file mode 100644 index 000000000..78df1843c --- /dev/null +++ b/ext/standard/tests/file/bug35740.phpt @@ -0,0 +1,14 @@ +--TEST-- +bug #35740 (memory leak when including a directory) +--FILE-- +<?php + +include (dirname(__FILE__)); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: include(%s): failed to open stream: %s in %s on line %d + +Warning: include(): Failed opening '%s' for inclusion (include_path='%s') in %s on line %d +Done diff --git a/ext/standard/tests/file/bug35781.phpt b/ext/standard/tests/file/bug35781.phpt new file mode 100644 index 000000000..5dc684a65 --- /dev/null +++ b/ext/standard/tests/file/bug35781.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #35781 (stream_filter_append() causes segfault) +--FILE-- +<?php + +$filename = dirname(__FILE__)."/bug35781.txt"; + +$fp = fopen($filename, "w"); +stream_filter_append($fp, "string.rot13", -49); +fwrite($fp, "This is a test\n"); +rewind($fp); +fpassthru($fp); +fclose($fp); + +var_dump(file_get_contents($filename)); + +@unlink($filename); + +echo "Done\n"; +?> +--EXPECTF-- +string(15) "Guvf vf n grfg +" +Done diff --git a/ext/standard/tests/file/proc_open01.phpt b/ext/standard/tests/file/proc_open01.phpt index 39fc4e4cf..c5b0ed971 100644 --- a/ext/standard/tests/file/proc_open01.phpt +++ b/ext/standard/tests/file/proc_open01.phpt @@ -30,7 +30,9 @@ for ($left = strlen($test_string); $left > 0;) { break; } $read_fds = array($pipes[1]); - $retval = stream_select($read_fds, $write_fds = NULL, $exp_fds = NULL, 1); + $write_fds = NULL; + $exp_fds = NULL; + $retval = stream_select($read_fds, $write_fds, $exp_fds, 1); if ($retval === false) { print "select() failed\n"; break; diff --git a/ext/standard/tests/filters/bug35916.phpt b/ext/standard/tests/filters/bug35916.phpt new file mode 100644 index 000000000..4d2027d24 --- /dev/null +++ b/ext/standard/tests/filters/bug35916.phpt @@ -0,0 +1,42 @@ +--TEST-- +Bug #35916 (Duplicate calls to stream_bucket_append() lead to a crash) +--FILE-- +<?php +$file = dirname(__FILE__) . "/bug35916.txt"; +@unlink($file); + +class strtoupper_filter extends php_user_filter +{ + function filter($in, $out, &$consumed, $closing) + { + while($bucket=stream_bucket_make_writeable($in)) { + $bucket->data = strtoupper($bucket->data); + $consumed += $bucket->datalen; + stream_bucket_append($out, $bucket); + stream_bucket_append($out, $bucket); + } + return PSFS_PASS_ON; + } + function onCreate() + { + echo "fffffffffff\n"; + } + function onClose() + { + echo "hello\n"; + } +} + +stream_filter_register("strtoupper", "strtoupper_filter"); +$fp=fopen($file, "w"); +stream_filter_append($fp, "strtoupper"); +fread($fp, 1024); +fwrite($fp, "Thank you\n"); +fclose($fp); +readfile($file); +unlink($file); +?> +--EXPECT-- +fffffffffff +hello +THANK YOU diff --git a/ext/standard/tests/general_functions/bug27678.phpt b/ext/standard/tests/general_functions/bug27678.phpt new file mode 100644 index 000000000..ec9cf93cf --- /dev/null +++ b/ext/standard/tests/general_functions/bug27678.phpt @@ -0,0 +1,14 @@ +--TEST-- +bug #27678 (number_format() crashes with large numbers) +--FILE-- +<?php + +number_format(1e80, 0, '', ' '); +number_format(1e300, 0, '', ' '); +number_format(1e320, 0, '', ' '); +number_format(1e1000, 0, '', ' '); + +echo "Done\n"; +?> +--EXPECT-- +Done diff --git a/ext/standard/tests/general_functions/bug32647.phpt b/ext/standard/tests/general_functions/bug32647.phpt index ca98f429a..2e8201207 100644 --- a/ext/standard/tests/general_functions/bug32647.phpt +++ b/ext/standard/tests/general_functions/bug32647.phpt @@ -1,14 +1,14 @@ --TEST-- Bug #32647 (Using register_shutdown_function() with invalid callback can crash PHP) --INI-- -error_reporting=2047 +error_reporting=4095 display_errors=1 --FILE-- <?php function foo() { - echo "joo!\n"; + echo "foo!\n"; } class bar @@ -23,9 +23,9 @@ register_shutdown_function(array($obj,"some string")); // Invalid register_shutdown_function(array(0,"")); // Invalid register_shutdown_function(array('bar','foo')); // Invalid register_shutdown_function(array(0,"some string")); // Invalid -register_shutdown_function('bar'); // Valid +register_shutdown_function('bar'); // Invalid register_shutdown_function('foo'); // Valid -register_shutdown_function(array('bar','barfoo')); // Valid +register_shutdown_function(array('bar','barfoo')); // Invalid $obj = new bar; register_shutdown_function(array($obj,'foobar')); // Invalid @@ -45,11 +45,13 @@ Warning: register_shutdown_function(): Invalid shutdown callback 'Array' passed Warning: register_shutdown_function(): Invalid shutdown callback 'Array' passed in %s on line %d -Warning: (Registered shutdown functions) Unable to call bar::foo() - function does not exist in Unknown on line 0 +Strict Standards: Non-static method bar::barfoo() cannot be called statically in %sbug32647.php on line %d -Warning: (Registered shutdown functions) Unable to call bar() - function does not exist in Unknown on line 0 -joo! -bar! +Warning: register_shutdown_function(): Invalid shutdown callback 'bar::foobar' passed in %sbug32647.php on line %d +foo! + +Strict Standards: Non-static method bar::barfoo() cannot be called statically in Unknown on line 0 -Warning: (Registered shutdown functions) Unable to call bar::foobar() - function does not exist in Unknown on line 0 +Strict Standards: Non-static method bar::barfoo() cannot be called statically in Unknown on line 0 +bar! bar! diff --git a/ext/standard/tests/general_functions/sunfuncts.phpt b/ext/standard/tests/general_functions/sunfuncts.phpt index a9711ffc3..8d32e7171 100644 --- a/ext/standard/tests/general_functions/sunfuncts.phpt +++ b/ext/standard/tests/general_functions/sunfuncts.phpt @@ -18,27 +18,27 @@ for($a=1;$a<=12;$a++){ } ?> --EXPECT-- -1041316748 06:39 6.652455761896 -1041353169 16:46 16.76937486746 -1043994763 06:32 6.54537029266 -1044033183 17:13 17.21752470874 -1046412416 06:06 6.115652675685 -1046453799 17:36 17.6108549623 -1049088501 05:28 5.472742029069 -1049133501 17:58 17.97255258437 -1051678444 04:54 4.901229982859 -1051726729 18:18 18.31368876948 -1054355667 04:34 4.57442928945 -1054406363 18:39 18.65640094324 -1056947818 04:36 4.616120450519 -1056998911 18:48 18.80887165777 -1059627264 04:54 4.906882509836 -1059676557 18:35 18.59928600203 -1062306852 05:14 5.236889557074 -1062353017 18:03 18.06054178788 -1064899952 05:32 5.542366581139 -1064942681 17:24 17.41150561492 -1067579698 05:54 5.916208842058 -1067619001 16:50 16.83369857063 -1070173246 06:20 6.34622155207 -1070210100 16:35 16.58358905554 +1041395864 06:37 6.629013145891 +1041432452 16:47 16.79245111439 +1044073855 06:30 6.515408927982 +1044112463 17:14 17.23987028904 +1046491495 06:04 6.082214503336 +1046533075 17:37 17.63201103534 +1049167581 05:26 5.439443811173 +1049212774 17:59 17.99303572948 +1051757532 04:52 4.870193412616 +1051806007 18:20 18.33539050867 +1054434776 04:32 4.548982718277 +1054485647 18:40 18.67981294906 +1057026949 04:35 4.597195637274 +1057078197 18:49 18.83256339675 +1059706409 04:53 4.891657508917 +1059755837 18:37 18.62144070428 +1062385999 05:13 5.222095112101 +1062432291 18:04 18.08095716848 +1064979098 05:31 5.527319921542 +1065021952 17:25 17.43133913592 +1067658845 05:54 5.901629287095 +1067698274 16:51 16.85390245352 +1070252387 06:19 6.329924268936 +1070289382 16:36 16.60631260094 diff --git a/ext/standard/tests/strings/bug35817.phpt b/ext/standard/tests/strings/bug35817.phpt new file mode 100644 index 000000000..e2a752c4a --- /dev/null +++ b/ext/standard/tests/strings/bug35817.phpt @@ -0,0 +1,29 @@ +--TEST-- +Bug #35817 (unpack() does not decode odd number of hexadecimal values) +--FILE-- +<?php +$a = pack("H3","181"); +$b = unpack("H3", $a); +var_dump($b); + +$a = pack("H2","18"); +$b = unpack("H2", $a); +var_dump($b); + +$a = pack("H","1"); +$b = unpack("H", $a); +var_dump($b); +?> +--EXPECT-- +array(1) { + [1]=> + string(3) "181" +} +array(1) { + [1]=> + string(2) "18" +} +array(1) { + [1]=> + string(1) "1" +} diff --git a/ext/standard/tests/strings/http_build_query.phpt b/ext/standard/tests/strings/http_build_query.phpt new file mode 100644 index 000000000..4ed7fda43 --- /dev/null +++ b/ext/standard/tests/strings/http_build_query.phpt @@ -0,0 +1,15 @@ +--TEST-- +http_build_query() function +--FILE-- +<?php + +$array = array("foo"=>"bar","baz"=>1,"test"=>"a ' \" ", "abc"); +var_dump(http_build_query($array)); +var_dump(http_build_query($array, 'foo')); +var_dump(http_build_query($array, 'foo', ';')); + +?> +--EXPECT-- +string(35) "foo=bar&baz=1&test=a+%27+%22+&0=abc" +string(38) "foo=bar&baz=1&test=a+%27+%22+&foo0=abc" +string(38) "foo=bar;baz=1;test=a+%27+%22+;foo0=abc" diff --git a/ext/standard/tests/strings/str_word_count.phpt b/ext/standard/tests/strings/str_word_count.phpt index 0c6c5ae56..9d41fc147 100644 --- a/ext/standard/tests/strings/str_word_count.phpt +++ b/ext/standard/tests/strings/str_word_count.phpt @@ -36,7 +36,11 @@ var_dump(str_word_count($str2, 2, "014")); var_dump(str_word_count($str2, 2, array())); var_dump(str_word_count($str2, 2, new stdClass)); var_dump(str_word_count($str2, 2, "")); - +var_dump(str_word_count("foo'0 bar-0var", 2, "0")); +var_dump(str_word_count("'foo'", 2)); +var_dump(str_word_count("'foo'", 2, "'")); +var_dump(str_word_count("-foo-", 2)); +var_dump(str_word_count("-foo-", 2, "-")); ?> --EXPECTF-- array(6) { @@ -225,4 +229,26 @@ array(7) { string(3) "bar" [15]=> string(3) "foo" -}
\ No newline at end of file +} +array(2) { + [0]=> + string(5) "foo'0" + [6]=> + string(8) "bar-0var" +} +array(1) { + [1]=> + string(4) "foo'" +} +array(1) { + [0]=> + string(5) "'foo'" +} +array(1) { + [1]=> + string(3) "foo" +} +array(1) { + [0]=> + string(5) "-foo-" +} diff --git a/ext/standard/tests/strings/url_t.phpt b/ext/standard/tests/strings/url_t.phpt index f6fec50de..be95e0294 100644 --- a/ext/standard/tests/strings/url_t.phpt +++ b/ext/standard/tests/strings/url_t.phpt @@ -75,6 +75,11 @@ $sample_urls = array ( foreach ($sample_urls as $url) { var_dump(@parse_url($url)); } + + $url = 'http://secret:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123'; + foreach (array(PHP_URL_SCHEME,PHP_URL_HOST,PHP_URL_PORT,PHP_URL_USER,PHP_URL_PASS,PHP_URL_PATH,PHP_URL_QUERY,PHP_URL_FRAGMENT) as $v) { + var_dump(parse_url($url, $v)); + } ?> --EXPECT-- array(1) { @@ -673,3 +678,11 @@ array(4) { ["path"]=> string(4) "/bla" } +string(4) "http" +string(11) "www.php.net" +int(80) +string(6) "secret" +string(7) "hideout" +string(10) "/index.php" +string(31) "test=1&test2=char&test3=mixesCI" +string(16) "some_page_ref123" |
