[PHP-BUG] Bug #80018 [NEW]: Tests expect var_dump(FLOAT) to print an integer
From: jamieliu at google dot com Operating system: All PHP version: master-Git-2020-08-25 (Git) Package: Testing related Bug Type: Bug Bug description:Tests expect var_dump(FLOAT) to print an integer Description: Many tests parse the result of var_dump() on a float and expect the result to be an integer: $ find . -name '*.phpt' | xargs grep 'float(%d)' ./Zend/tests/cast_to_double.phpt:float(%d) ./Zend/tests/settype_double.phpt:float(%d) ./ext/standard/tests/file/disk_total_space_basic.phpt:float(%d) ./ext/standard/tests/file/disk_total_space_basic.phpt:float(%d) ./ext/standard/tests/file/disk_total_space_basic.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk.phpt:float(%d) ./ext/standard/tests/file/disk.phpt:float(%d) ./ext/standard/tests/file/disk_total_space_error.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_error.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_error.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_basic.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_basic.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_basic.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_basic.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_basic.phpt:float(%d) ./ext/standard/tests/file/disk_total_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_total_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_total_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_total_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_total_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_total_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_total_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_total_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_total_space_variation.phpt:float(%d) ./ext/standard/tests/general_functions/type.phpt:float(%d) ./ext/standard/tests/general_functions/type.phpt:float(%d) ./ext/standard/tests/general_functions/type.phpt:float(%d) ./ext/standard/tests/general_functions/gettype_settype_basic.phpt:float(%d) ./ext/standard/tests/general_functions/gettype_settype_basic.phpt:float(%d) ./ext/standard/tests/general_functions/gettype_settype_basic.phpt:float(%d) ./ext/standard/tests/general_functions/gettype_settype_basic.phpt:float(%d) This is problematic because var_dump() will print sufficiently large numbers in exponential notation. An example in Linux: $ mkdir tmp $ sudo mount -t tmpfs -o size=$((1 << 62)) tmpfs tmp $ ~/src/php-src/sapi/cli/php --version PHP 8.0.0-dev (cli) (built: Aug 25 2020 12:55:38) ( NTS ) Copyright (c) The PHP Group Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies $ ~/src/php-src/sapi/cli/php -r 'var_dump(disk_total_space("tmp"));' float(4.611686018427388E+18) I think every instance of "float(%d)" in such tests could simply be converted to use "float(%E)" instead. Test script: --- See description. -- Edit bug report at https://bugs.php.net/bug.php?id=80018&edit=1 -- Fix committed:https://bugs.php.net/fix.php?id=80018&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=80018&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=80018&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=80018&r=needscript Try newer version: https://bugs.php.net/fix.php?id=80018&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=80018&r=support Expected behavior: https://bugs.php.net/fix.php?id=80018&r=notwrong Not enough info:
Bug #80018 [Com]: Tests expect var_dump(FLOAT) to print an integer
Edit report at https://bugs.php.net/bug.php?id=80018&edit=1 ID: 80018 Comment by: jamieliu at google dot com Reported by:jamieliu at google dot com Summary:Tests expect var_dump(FLOAT) to print an integer Status: Open Type: Bug Package:Testing related Operating System: All PHP Version:master-Git-2020-08-25 (Git) Block user comment: N Private report: N New Comment: My mistake, I though test format strings were interpreted by sscanf(). Using %f instead seems to work (tested by modifying ext/standard/tests/file/disk.phpt to call disk_free_space() and disk_total_space() on a tmpfs mount as described in the original report). Previous Comments: [2020-08-25 20:32:48] c...@php.net I agree that this should be fixed, but to my knowledge run-tests.php does not support %E, but only %f. Are you using another test runner? [2020-08-25 20:09:25] jamieliu at google dot com Description: Many tests parse the result of var_dump() on a float and expect the result to be an integer: $ find . -name '*.phpt' | xargs grep 'float(%d)' ./Zend/tests/cast_to_double.phpt:float(%d) ./Zend/tests/settype_double.phpt:float(%d) ./ext/standard/tests/file/disk_total_space_basic.phpt:float(%d) ./ext/standard/tests/file/disk_total_space_basic.phpt:float(%d) ./ext/standard/tests/file/disk_total_space_basic.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk.phpt:float(%d) ./ext/standard/tests/file/disk.phpt:float(%d) ./ext/standard/tests/file/disk_total_space_error.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_error.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_error.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_basic.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_basic.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_basic.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_basic.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_basic.phpt:float(%d) ./ext/standard/tests/file/disk_total_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_total_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_total_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_total_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_total_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_total_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_total_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_total_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_total_space_variation.phpt:float(%d) ./ext/standard/tests/general_functions/type.phpt:float(%d) ./ext/standard/tests/general_functions/type.phpt:float(%d) ./ext/standard/tests/general_functions/type.phpt:float(%d) ./ext/standard/tests/general_functions/gettype_settype_basic.phpt:float(%d) ./ext/standard/tests/general_functions/gettype_settype_basic.phpt:float(%d) ./ext/standard/tests/general_functions/gettype_settype_basic.phpt:float(%d) ./ext/standard/tests/general_functions/gettype_settype_basic.phpt:float(%d) This is problematic because var_dump() will print sufficiently large numbers in exponential notation. An example in Linux: $ mkdir tmp $ sudo mount -t tmpfs -o size=$((1 << 62)) tmpfs tmp $ ~/src/php-src/sapi/cli/php --version PHP 8.0.0-dev (cli) (built: Aug 25 2020 12:55:38) ( NTS ) Copyright (c) The PHP Group Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies $ ~/src/php-src/sapi/cli/php -r 'var_dump(disk_total_space("tmp"));' float(4.611686018427388E+