]> granicus.if.org Git - postgresql/commitdiff
Rethink how to test the hyperbolic functions.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 13 Mar 2019 22:13:38 +0000 (18:13 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 13 Mar 2019 22:13:45 +0000 (18:13 -0400)
The initial commit tried to test them on trivial cases such as 0,
reasoning that we shouldn't hit any portability issues that way.
The buildfarm immediately proved that hope ill-founded, and anyway
it's not a great testing scheme because it doesn't prove that we're
even calling the right library function for each SQL function.

Instead, let's test them at inputs such as 1 (or something within
the valid range, as needed), so that each function should produce
a different output.

As committed, this is just about certain to show portability
failures, because it's very unlikely that every platform computes
these functions the same as mine down to the last bit.  However,
I want to put it through a buildfarm cycle this way, so that
we can see how big the variations are.  The plan is to add
"set extra_float_digits = -1", or whatever we need in order to
hide the variations; but first we need data.

Discussion: https://postgr.es/m/E1h3nUY-0000sM-Vf@gemulon.postgresql.org

src/test/regress/expected/float8.out
src/test/regress/sql/float8.sql

index 36b2acda739bbd42f6ec4a9dcfdc866bc6f85924..7aed4aa97f80f0fc3ecbd1da12781abca2f95c3d 100644 (file)
@@ -454,44 +454,44 @@ SELECT '' AS five, * FROM FLOAT8_TBL;
       | -1.2345678901234e-200
 (5 rows)
 
+RESET extra_float_digits;
 -- hyperbolic functions
-SELECT sinh(float8 '0');
- sinh 
-------
-    0
+SELECT sinh(float8 '1');
+        sinh        
+--------------------
+ 1.1752011936438014
 (1 row)
 
-SELECT cosh(float8 '0');
- cosh 
-------
-    1
+SELECT cosh(float8 '1');
+        cosh        
+--------------------
+ 1.5430806348152437
 (1 row)
 
-SELECT tanh(float8 '0');
- tanh 
-------
-    0
+SELECT tanh(float8 '1');
+        tanh        
+--------------------
+ 0.7615941559557649
 (1 row)
 
-SELECT asinh(float8 '0');
- asinh 
--------
-     0
+SELECT asinh(float8 '1');
+       asinh       
+-------------------
+ 0.881373587019543
 (1 row)
 
-SELECT acosh(float8 '1');
- acosh 
--------
-     0
+SELECT acosh(float8 '2');
+       acosh        
+--------------------
+ 1.3169578969248166
 (1 row)
 
-SELECT atanh(float8 '0');
- atanh 
--------
-     0
+SELECT atanh(float8 '0.5');
+       atanh        
+--------------------
+ 0.5493061443340548
 (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
index 4660cd265ebbfb785ef1a090cec58b71b551c397..07fbb66c94700d4d67de17bff6fe397b4cd2ebe5 100644 (file)
@@ -154,16 +154,16 @@ SELECT '' AS bad, f.f1 / '0.0' from FLOAT8_TBL f;
 
 SELECT '' AS five, * FROM FLOAT8_TBL;
 
--- hyperbolic functions
-SELECT sinh(float8 '0');
-SELECT cosh(float8 '0');
-SELECT tanh(float8 '0');
-SELECT asinh(float8 '0');
-SELECT acosh(float8 '1');
-SELECT atanh(float8 '0');
-
 RESET extra_float_digits;
 
+-- hyperbolic functions
+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 for over- and underflow
 INSERT INTO FLOAT8_TBL(f1) VALUES ('10e400');