Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4db0d2d

Browse files
committed
Improve regression tests for degree-based trigonometric functions.
Print the actual value of each function result that's expected to be exact,rather than merely emitting a NULL if it's not right. Although we printthese with extra_float_digits = 3, we should not trust that the platformwill produce a result visibly different from the expected value if it's offonly in the last place; hence, also include comparisons against the exactvalues as before. This is a bit bulkier and uglier than the previousprintout, but it will provide more information and be easier to interpretif there's a test failure.Discussion: <18241.1461073100@sss.pgh.pa.us>
1 parenta0382e2 commit4db0d2d

File tree

5 files changed

+399
-269
lines changed

5 files changed

+399
-269
lines changed

‎src/test/regress/expected/float8-exp-three-digits-win32.out

Lines changed: 91 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -445,79 +445,106 @@ SELECT '' AS five, * FROM FLOAT8_TBL;
445445
(5 rows)
446446

447447
-- test exact cases for trigonometric functions in degrees
448+
SET extra_float_digits = 3;
448449
SELECT x,
449-
CASE WHEN sind(x) IN (-1,-0.5,0,0.5,1) THEN sind(x) END AS sind,
450-
CASE WHEN cosd(x) IN (-1,-0.5,0,0.5,1) THEN cosd(x) END AS cosd,
451-
CASE WHEN tand(x) IN ('-Infinity'::float8,-1,0,
452-
1,'Infinity'::float8) THEN tand(x) END AS tand,
453-
CASE WHEN cotd(x) IN ('-Infinity'::float8,-1,0,
454-
1,'Infinity'::float8) THEN cotd(x) END AS cotd
455-
FROM generate_series(0, 360, 15) AS t(x);
456-
x | sind | cosd | tand | cotd
457-
-----+------+------+-----------+-----------
458-
0 | 0 | 1 | 0 | Infinity
459-
15 | | | |
460-
30 | 0.5 | | |
461-
45 | | | 1 | 1
462-
60 | | 0.5 | |
463-
75 | | | |
464-
90 | 1 | 0 | Infinity | 0
465-
105 | | | |
466-
120 | | -0.5 | |
467-
135 | | | -1 | -1
468-
150 | 0.5 | | |
469-
165 | | | |
470-
180 | 0 | -1 | 0 | -Infinity
471-
195 | | | |
472-
210 | -0.5 | | |
473-
225 | | | 1 | 1
474-
240 | | -0.5 | |
475-
255 | | | |
476-
270 | -1 | 0 | -Infinity | 0
477-
285 | | | |
478-
300 | | 0.5 | |
479-
315 | | | -1 | -1
480-
330 | -0.5 | | |
481-
345 | | | |
482-
360 | 0 | 1 | 0 | Infinity
483-
(25 rows)
450+
sind(x),
451+
sind(x) IN (-1,-0.5,0,0.5,1) AS sind_exact
452+
FROM (VALUES (0), (30), (90), (150), (180),
453+
(210), (270), (330), (360)) AS t(x);
454+
x | sind | sind_exact
455+
-----+------+------------
456+
0 | 0 | t
457+
30 | 0.5 | t
458+
90 | 1 | t
459+
150 | 0.5 | t
460+
180 | 0 | t
461+
210 | -0.5 | t
462+
270 | -1 | t
463+
330 | -0.5 | t
464+
360 | 0 | t
465+
(9 rows)
484466

485467
SELECT x,
486-
CASE WHEN asind(x) IN (-90,-30,0,30,90) THEN asind(x) END AS asind,
487-
CASE WHEN acosd(x) IN (0,60,90,120,180) THEN acosd(x) END AS acosd,
488-
CASE WHEN atand(x) IN (-45,0,45) THEN atand(x) END AS atand
468+
cosd(x),
469+
cosd(x) IN (-1,-0.5,0,0.5,1) AS cosd_exact
470+
FROM (VALUES (0), (60), (90), (120), (180),
471+
(240), (270), (300), (360)) AS t(x);
472+
x | cosd | cosd_exact
473+
-----+------+------------
474+
0 | 1 | t
475+
60 | 0.5 | t
476+
90 | 0 | t
477+
120 | -0.5 | t
478+
180 | -1 | t
479+
240 | -0.5 | t
480+
270 | 0 | t
481+
300 | 0.5 | t
482+
360 | 1 | t
483+
(9 rows)
484+
485+
SELECT x,
486+
tand(x),
487+
tand(x) IN ('-Infinity'::float8,-1,0,
488+
1,'Infinity'::float8) AS tand_exact,
489+
cotd(x),
490+
cotd(x) IN ('-Infinity'::float8,-1,0,
491+
1,'Infinity'::float8) AS cotd_exact
492+
FROM (VALUES (0), (45), (90), (135), (180),
493+
(225), (270), (315), (360)) AS t(x);
494+
x | tand | tand_exact | cotd | cotd_exact
495+
-----+-----------+------------+-----------+------------
496+
0 | 0 | t | Infinity | t
497+
45 | 1 | t | 1 | t
498+
90 | Infinity | t | 0 | t
499+
135 | -1 | t | -1 | t
500+
180 | 0 | t | -Infinity | t
501+
225 | 1 | t | 1 | t
502+
270 | -Infinity | t | 0 | t
503+
315 | -1 | t | -1 | t
504+
360 | 0 | t | Infinity | t
505+
(9 rows)
506+
507+
SELECT x,
508+
asind(x),
509+
asind(x) IN (-90,-30,0,30,90) AS asind_exact,
510+
acosd(x),
511+
acosd(x) IN (0,60,90,120,180) AS acosd_exact
489512
FROM (VALUES (-1), (-0.5), (0), (0.5), (1)) AS t(x);
490-
x | asind | acosd |atand
491-
------+-------+-------+-------
492-
-1 | -90 | 180|-45
493-
-0.5 | -30 | 120 |
494-
0 | 0 |90| 0
495-
0.5 | 30 |60|
496-
1 | 90 |0|45
513+
x | asind |asind_exact |acosd |acosd_exact
514+
------+-------+-------------+-------+-------------
515+
-1 | -90 |t|180 | t
516+
-0.5 | -30 |t | 120 | t
517+
0 | 0 |t|90 | t
518+
0.5 | 30 |t|60 | t
519+
1 | 90 |t| 0 | t
497520
(5 rows)
498521

499-
SELECT atand('-Infinity'::float8) = -90;
500-
?column?
501-
----------
502-
t
503-
(1 row)
504-
505-
SELECT atand('Infinity'::float8) = 90;
506-
?column?
507-
----------
508-
t
509-
(1 row)
522+
SELECT x,
523+
atand(x),
524+
atand(x) IN (-90,-45,0,45,90) AS atand_exact
525+
FROM (VALUES ('-Infinity'::float8), (-1), (0), (1),
526+
('Infinity'::float8)) AS t(x);
527+
x | atand | atand_exact
528+
-----------+-------+-------------
529+
-Infinity | -90 | t
530+
-1 | -45 | t
531+
0 | 0 | t
532+
1 | 45 | t
533+
Infinity | 90 | t
534+
(5 rows)
510535

511536
SELECT x, y,
512-
CASE WHEN atan2d(y, x) IN (-90,0,90,180) THEN atan2d(y, x) END AS atan2d
537+
atan2d(y, x),
538+
atan2d(y, x) IN (-90,0,90,180) AS atan2d_exact
513539
FROM (SELECT 10*cosd(a), 10*sind(a)
514540
FROM generate_series(0, 360, 90) AS t(a)) AS t(x,y);
515-
x | y | atan2d
516-
-----+-----+--------
517-
10 | 0 | 0
518-
0 | 10 | 90
519-
-10 | 0 | 180
520-
0 | -10 | -90
521-
10 | 0 | 0
541+
x | y | atan2d| atan2d_exact
542+
-----+-----+--------+--------------
543+
10 | 0 | 0 | t
544+
0 | 10 | 90 | t
545+
-10 | 0 | 180 | t
546+
0 | -10 | -90 | t
547+
10 | 0 | 0 | t
522548
(5 rows)
523549

550+
RESET extra_float_digits;

‎src/test/regress/expected/float8-small-is-zero.out

Lines changed: 91 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -443,79 +443,106 @@ SELECT '' AS five, * FROM FLOAT8_TBL;
443443
(5 rows)
444444

445445
-- test exact cases for trigonometric functions in degrees
446+
SET extra_float_digits = 3;
446447
SELECT x,
447-
CASE WHEN sind(x) IN (-1,-0.5,0,0.5,1) THEN sind(x) END AS sind,
448-
CASE WHEN cosd(x) IN (-1,-0.5,0,0.5,1) THEN cosd(x) END AS cosd,
449-
CASE WHEN tand(x) IN ('-Infinity'::float8,-1,0,
450-
1,'Infinity'::float8) THEN tand(x) END AS tand,
451-
CASE WHEN cotd(x) IN ('-Infinity'::float8,-1,0,
452-
1,'Infinity'::float8) THEN cotd(x) END AS cotd
453-
FROM generate_series(0, 360, 15) AS t(x);
454-
x | sind | cosd | tand | cotd
455-
-----+------+------+-----------+-----------
456-
0 | 0 | 1 | 0 | Infinity
457-
15 | | | |
458-
30 | 0.5 | | |
459-
45 | | | 1 | 1
460-
60 | | 0.5 | |
461-
75 | | | |
462-
90 | 1 | 0 | Infinity | 0
463-
105 | | | |
464-
120 | | -0.5 | |
465-
135 | | | -1 | -1
466-
150 | 0.5 | | |
467-
165 | | | |
468-
180 | 0 | -1 | 0 | -Infinity
469-
195 | | | |
470-
210 | -0.5 | | |
471-
225 | | | 1 | 1
472-
240 | | -0.5 | |
473-
255 | | | |
474-
270 | -1 | 0 | -Infinity | 0
475-
285 | | | |
476-
300 | | 0.5 | |
477-
315 | | | -1 | -1
478-
330 | -0.5 | | |
479-
345 | | | |
480-
360 | 0 | 1 | 0 | Infinity
481-
(25 rows)
448+
sind(x),
449+
sind(x) IN (-1,-0.5,0,0.5,1) AS sind_exact
450+
FROM (VALUES (0), (30), (90), (150), (180),
451+
(210), (270), (330), (360)) AS t(x);
452+
x | sind | sind_exact
453+
-----+------+------------
454+
0 | 0 | t
455+
30 | 0.5 | t
456+
90 | 1 | t
457+
150 | 0.5 | t
458+
180 | 0 | t
459+
210 | -0.5 | t
460+
270 | -1 | t
461+
330 | -0.5 | t
462+
360 | 0 | t
463+
(9 rows)
482464

483465
SELECT x,
484-
CASE WHEN asind(x) IN (-90,-30,0,30,90) THEN asind(x) END AS asind,
485-
CASE WHEN acosd(x) IN (0,60,90,120,180) THEN acosd(x) END AS acosd,
486-
CASE WHEN atand(x) IN (-45,0,45) THEN atand(x) END AS atand
466+
cosd(x),
467+
cosd(x) IN (-1,-0.5,0,0.5,1) AS cosd_exact
468+
FROM (VALUES (0), (60), (90), (120), (180),
469+
(240), (270), (300), (360)) AS t(x);
470+
x | cosd | cosd_exact
471+
-----+------+------------
472+
0 | 1 | t
473+
60 | 0.5 | t
474+
90 | 0 | t
475+
120 | -0.5 | t
476+
180 | -1 | t
477+
240 | -0.5 | t
478+
270 | 0 | t
479+
300 | 0.5 | t
480+
360 | 1 | t
481+
(9 rows)
482+
483+
SELECT x,
484+
tand(x),
485+
tand(x) IN ('-Infinity'::float8,-1,0,
486+
1,'Infinity'::float8) AS tand_exact,
487+
cotd(x),
488+
cotd(x) IN ('-Infinity'::float8,-1,0,
489+
1,'Infinity'::float8) AS cotd_exact
490+
FROM (VALUES (0), (45), (90), (135), (180),
491+
(225), (270), (315), (360)) AS t(x);
492+
x | tand | tand_exact | cotd | cotd_exact
493+
-----+-----------+------------+-----------+------------
494+
0 | 0 | t | Infinity | t
495+
45 | 1 | t | 1 | t
496+
90 | Infinity | t | 0 | t
497+
135 | -1 | t | -1 | t
498+
180 | 0 | t | -Infinity | t
499+
225 | 1 | t | 1 | t
500+
270 | -Infinity | t | 0 | t
501+
315 | -1 | t | -1 | t
502+
360 | 0 | t | Infinity | t
503+
(9 rows)
504+
505+
SELECT x,
506+
asind(x),
507+
asind(x) IN (-90,-30,0,30,90) AS asind_exact,
508+
acosd(x),
509+
acosd(x) IN (0,60,90,120,180) AS acosd_exact
487510
FROM (VALUES (-1), (-0.5), (0), (0.5), (1)) AS t(x);
488-
x | asind | acosd |atand
489-
------+-------+-------+-------
490-
-1 | -90 | 180|-45
491-
-0.5 | -30 | 120 |
492-
0 | 0 |90| 0
493-
0.5 | 30 |60|
494-
1 | 90 |0|45
511+
x | asind |asind_exact |acosd |acosd_exact
512+
------+-------+-------------+-------+-------------
513+
-1 | -90 |t|180 | t
514+
-0.5 | -30 |t | 120 | t
515+
0 | 0 |t|90 | t
516+
0.5 | 30 |t|60 | t
517+
1 | 90 |t| 0 | t
495518
(5 rows)
496519

497-
SELECT atand('-Infinity'::float8) = -90;
498-
?column?
499-
----------
500-
t
501-
(1 row)
502-
503-
SELECT atand('Infinity'::float8) = 90;
504-
?column?
505-
----------
506-
t
507-
(1 row)
520+
SELECT x,
521+
atand(x),
522+
atand(x) IN (-90,-45,0,45,90) AS atand_exact
523+
FROM (VALUES ('-Infinity'::float8), (-1), (0), (1),
524+
('Infinity'::float8)) AS t(x);
525+
x | atand | atand_exact
526+
-----------+-------+-------------
527+
-Infinity | -90 | t
528+
-1 | -45 | t
529+
0 | 0 | t
530+
1 | 45 | t
531+
Infinity | 90 | t
532+
(5 rows)
508533

509534
SELECT x, y,
510-
CASE WHEN atan2d(y, x) IN (-90,0,90,180) THEN atan2d(y, x) END AS atan2d
535+
atan2d(y, x),
536+
atan2d(y, x) IN (-90,0,90,180) AS atan2d_exact
511537
FROM (SELECT 10*cosd(a), 10*sind(a)
512538
FROM generate_series(0, 360, 90) AS t(a)) AS t(x,y);
513-
x | y | atan2d
514-
-----+-----+--------
515-
10 | 0 | 0
516-
0 | 10 | 90
517-
-10 | 0 | 180
518-
0 | -10 | -90
519-
10 | 0 | 0
539+
x | y | atan2d| atan2d_exact
540+
-----+-----+--------+--------------
541+
10 | 0 | 0 | t
542+
0 | 10 | 90 | t
543+
-10 | 0 | 180 | t
544+
0 | -10 | -90 | t
545+
10 | 0 | 0 | t
520546
(5 rows)
521547

548+
RESET extra_float_digits;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp