PhpSpreadsheet/tests/data/Calculation
oleibman cabcfaa522
ROUND Accepts null, false, and true as First Parameter (#1837)
* ROUND Accepts null, false, and true as First Parameter

Issue #1789 was addressed by PR #1799. In a follow-up discussion,
it came to light that ROUND was not handling the unexpected case where the
first parameter is an empty cell in the same manner that Excel does.
Subsequent investigation showed that a boolean first parameter is permitted.
I broadened my investigation to include the following related functions.
- ROUNDUP
- ROUNDDOWN
- MROUND
- TRUNC
- INT
- FLOOR
- FLOOR.MATH
- FLOOR.PRECISE
- CEILING
- CEILING.MATH
- CEILING.PRECISE

All of these allow a NULL first parameter, and all except MROUND allow boolean.
For completeness, I will note that all treat null string as invalid.
I suspect there are other functions which permit
similarly unexpected parameters, but I consider them out of scope for this PR.

CEILING.MATH and CEILING.PRECISE were unimplemented, and are now supported
as part of this PR.

The tests for each of these functions have been re-coded, though all the original
test data is still included in the test cases, plus several new cases for each.
The new tests now take place as a user would invoke the functions,
through a spreadsheet cell rather than a
direct call to the appropriate function within Calculation/MathTrig.
Aside from being more realistic, the new tests are also more complete.
For example, FLOOR.MATH can take from 1-3 arguments, and the existing tests
confirmed that the function in Calculation could handle a single argument.
However, the function list in Calculation.php erroneously set the number of
arguments for FLOOR.MATH to exactly 3, so, if a user tried to get the calculated
result of a cell containing FLOOR.MATH(1.2), the result would be an Exception.

Aside from the parameter support, there are a few minor code changes.
Ods, as well as Gnumeric, allows the omission of the second parameter for
FLOAT and CEILING; Excel does not. A potential divide-by-zero error is
avoided in CEILING, FLOOR, and FLOORMATH.

I will note that it would probably be beneficial in terms of maintainability
to break MathTrig up into many individual modules. The same would hold for the
other Calculation modules. I would be willing to look into this if you agree
that it would be worthwhile.
2021-02-13 21:00:08 +01:00
..
DateTime Fix date tests withut specified year for current year 2021 (#1774) 2021-01-07 11:41:46 +01:00
DefinedNames Named formula implementation, and improved handling of Defined Names generally (#1535) 2020-07-26 12:00:06 +02:00
Engineering Extract DELTA() and GESTEP() functions from the Engineering class into a dedicated Comparison classes (#1853) 2021-02-13 20:52:20 +01:00
Financial Update PPMT & IPMT implementation to better reflect excel behaviour. Update CUMPRINC & CUMIPMT implementation to prevent a crash while trying to add a string to a number. Update AMORLINC & AMORDEGRC to prevent crash when trying to multiply a string by a number. Update related unit tests. Update changelog to describe what we fixed. (#1840) 2021-02-12 18:04:52 +01:00
Functions Fixed Functions->ifCondition for allowing <> and empty condition 2019-11-17 21:03:11 +01:00
Logical Add support for IFS() logical function (#1442) 2020-06-20 18:21:19 +02:00
LookupRef Fix HLOOKUP on single row (#1512) 2020-06-19 21:06:41 +02:00
MathTrig ROUND Accepts null, false, and true as First Parameter (#1837) 2021-02-13 21:00:08 +01:00
Statistical Extract Permutation functions from the Statistical class into a dedicated Permutations class (#1851) 2021-02-13 15:35:07 +01:00
TextData Problems Using Builtin PHP Functions Directly As Excel Functions (#1799) 2021-01-26 22:55:06 +01:00
Web WEBSERVICE is HTTP client agnostic 2020-07-19 11:33:01 +09:00
Calculation.php Update PHP-CS-Fixer rules 2020-05-18 13:49:57 +09:00
FunctionsAsString.php MATCH with a static array should return the position of the found value based on the values submitted. 2020-04-26 22:09:31 +09:00