diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2019-03-13 21:05:33 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2019-03-13 21:05:33 -0400 |
commit | c015f853bf5958dd7562a17952df33a9d115e65f (patch) | |
tree | 4329f4fe234c0e4c30df9f9a1126e2a6312ae3d9 | |
parent | c6f153dcfebccf7a0d92290037793c656f1caef5 (diff) | |
download | postgresql-c015f853bf5958dd7562a17952df33a9d115e65f.tar.gz postgresql-c015f853bf5958dd7562a17952df33a9d115e65f.zip |
Adjust the tests for the hyperbolic functions.
Preliminary results from the buildfarm suggest that no platform gets
commit c6f153dcf's test cases wrong by more than one or two units in
the last place, so setting extra_float_digits = 0 should be plenty
to hide the cross-platform variations.
Also, add tests for Infinity/NaN inputs. I think it highly likely
that we'll end up removing these again, rather than adding code to
make ancient platforms conform. But it seems useful to find out
just how many platforms have such issues before we make a decision.
Discussion: https://postgr.es/m/E1h3nUY-0000sM-Vf@gemulon.postgresql.org
-rw-r--r-- | src/test/regress/expected/float8.out | 131 | ||||
-rw-r--r-- | src/test/regress/sql/float8.sql | 25 |
2 files changed, 138 insertions, 18 deletions
diff --git a/src/test/regress/expected/float8.out b/src/test/regress/expected/float8.out index 7aed4aa97f8..e85f92ce198 100644 --- a/src/test/regress/expected/float8.out +++ b/src/test/regress/expected/float8.out @@ -454,24 +454,25 @@ SELECT '' AS five, * FROM FLOAT8_TBL; | -1.2345678901234e-200 (5 rows) -RESET extra_float_digits; -- hyperbolic functions +-- we run these with extra_float_digits = 0 too, since different platforms +-- tend to produce results that vary in the last place. SELECT sinh(float8 '1'); - sinh --------------------- - 1.1752011936438014 + sinh +----------------- + 1.1752011936438 (1 row) SELECT cosh(float8 '1'); - cosh --------------------- - 1.5430806348152437 + cosh +------------------ + 1.54308063481524 (1 row) SELECT tanh(float8 '1'); - tanh --------------------- - 0.7615941559557649 + tanh +------------------- + 0.761594155955765 (1 row) SELECT asinh(float8 '1'); @@ -481,17 +482,115 @@ SELECT asinh(float8 '1'); (1 row) SELECT acosh(float8 '2'); - acosh --------------------- - 1.3169578969248166 + acosh +------------------ + 1.31695789692482 (1 row) SELECT atanh(float8 '0.5'); - atanh --------------------- - 0.5493061443340548 + atanh +------------------- + 0.549306144334055 +(1 row) + +-- test Inf/NaN cases for hyperbolic functions +SELECT sinh(float8 'infinity'); + sinh +---------- + Infinity +(1 row) + +SELECT sinh(float8 '-infinity'); + sinh +----------- + -Infinity +(1 row) + +SELECT sinh(float8 'nan'); + sinh +------ + NaN +(1 row) + +SELECT cosh(float8 'infinity'); + cosh +---------- + Infinity +(1 row) + +SELECT cosh(float8 '-infinity'); + cosh +---------- + Infinity +(1 row) + +SELECT cosh(float8 'nan'); + cosh +------ + NaN +(1 row) + +SELECT tanh(float8 'infinity'); + tanh +------ + 1 (1 row) +SELECT tanh(float8 '-infinity'); + tanh +------ + -1 +(1 row) + +SELECT tanh(float8 'nan'); + tanh +------ + NaN +(1 row) + +SELECT asinh(float8 'infinity'); + asinh +---------- + Infinity +(1 row) + +SELECT asinh(float8 '-infinity'); + asinh +----------- + -Infinity +(1 row) + +SELECT asinh(float8 'nan'); + asinh +------- + NaN +(1 row) + +SELECT acosh(float8 'infinity'); + acosh +---------- + Infinity +(1 row) + +SELECT acosh(float8 '-infinity'); +ERROR: input is out of range +SELECT acosh(float8 'nan'); + acosh +------- + NaN +(1 row) + +SELECT atanh(float8 'infinity'); +ERROR: input is out of range +SELECT atanh(float8 '-infinity'); +ERROR: input is out of range +SELECT atanh(float8 'nan'); + atanh +------- + NaN +(1 row) + +RESET extra_float_digits; -- test for over- and underflow INSERT INTO FLOAT8_TBL(f1) VALUES ('10e400'); ERROR: "10e400" is out of range for type double precision diff --git a/src/test/regress/sql/float8.sql b/src/test/regress/sql/float8.sql index 07fbb66c947..8385f3bb7b3 100644 --- a/src/test/regress/sql/float8.sql +++ b/src/test/regress/sql/float8.sql @@ -154,15 +154,36 @@ SELECT '' AS bad, f.f1 / '0.0' from FLOAT8_TBL f; SELECT '' AS five, * FROM FLOAT8_TBL; -RESET extra_float_digits; - -- hyperbolic functions +-- we run these with extra_float_digits = 0 too, since different platforms +-- tend to produce results that vary in the last place. SELECT sinh(float8 '1'); SELECT cosh(float8 '1'); SELECT tanh(float8 '1'); SELECT asinh(float8 '1'); SELECT acosh(float8 '2'); SELECT atanh(float8 '0.5'); +-- test Inf/NaN cases for hyperbolic functions +SELECT sinh(float8 'infinity'); +SELECT sinh(float8 '-infinity'); +SELECT sinh(float8 'nan'); +SELECT cosh(float8 'infinity'); +SELECT cosh(float8 '-infinity'); +SELECT cosh(float8 'nan'); +SELECT tanh(float8 'infinity'); +SELECT tanh(float8 '-infinity'); +SELECT tanh(float8 'nan'); +SELECT asinh(float8 'infinity'); +SELECT asinh(float8 '-infinity'); +SELECT asinh(float8 'nan'); +SELECT acosh(float8 'infinity'); +SELECT acosh(float8 '-infinity'); +SELECT acosh(float8 'nan'); +SELECT atanh(float8 'infinity'); +SELECT atanh(float8 '-infinity'); +SELECT atanh(float8 'nan'); + +RESET extra_float_digits; -- test for over- and underflow INSERT INTO FLOAT8_TBL(f1) VALUES ('10e400'); |