runtime: abort stack scan in cases that we cannot unwind the stack
[gcc.git] / libgo / go / math / huge_test.go
1 // Copyright 2018 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 // Disabled for s390x because it uses assembly routines that are not
6 // accurate for huge arguments.
7
8 // +build !s390x
9
10 package math_test
11
12 import (
13 . "math"
14 "testing"
15 )
16
17 // Inputs to test trig_reduce
18 var trigHuge = []float64{
19 1 << 120,
20 1 << 240,
21 1 << 480,
22 1234567891234567 << 180,
23 1234567891234567 << 300,
24 MaxFloat64,
25 }
26
27 // Results for trigHuge[i] calculated with https://github.com/robpike/ivy
28 // using 4096 bits of working precision. Values requiring less than
29 // 102 decimal digits (1 << 120, 1 << 240, 1 << 480, 1234567891234567 << 180)
30 // were confirmed via https://keisan.casio.com/
31 var cosHuge = []float64{
32 -0.92587902285483787,
33 0.93601042593353793,
34 -0.28282777640193788,
35 -0.14616431394103619,
36 -0.79456058210671406,
37 -0.99998768942655994,
38 }
39
40 var sinHuge = []float64{
41 0.37782010936075202,
42 -0.35197227524865778,
43 0.95917070894368716,
44 0.98926032637023618,
45 -0.60718488235646949,
46 0.00496195478918406,
47 }
48
49 var tanHuge = []float64{
50 -0.40806638884180424,
51 -0.37603456702698076,
52 -3.39135965054779932,
53 -6.76813854009065030,
54 0.76417695016604922,
55 -0.00496201587444489,
56 }
57
58 // Check that trig values of huge angles return accurate results.
59 // This confirms that argument reduction works for very large values
60 // up to MaxFloat64.
61 func TestHugeCos(t *testing.T) {
62 for i := 0; i < len(trigHuge); i++ {
63 f1 := cosHuge[i]
64 f2 := Cos(trigHuge[i])
65 if !close(f1, f2) {
66 t.Errorf("Cos(%g) = %g, want %g", trigHuge[i], f2, f1)
67 }
68 }
69 }
70
71 func TestHugeSin(t *testing.T) {
72 for i := 0; i < len(trigHuge); i++ {
73 f1 := sinHuge[i]
74 f2 := Sin(trigHuge[i])
75 if !close(f1, f2) {
76 t.Errorf("Sin(%g) = %g, want %g", trigHuge[i], f2, f1)
77 }
78 }
79 }
80
81 func TestHugeSinCos(t *testing.T) {
82 for i := 0; i < len(trigHuge); i++ {
83 f1, g1 := sinHuge[i], cosHuge[i]
84 f2, g2 := Sincos(trigHuge[i])
85 if !close(f1, f2) || !close(g1, g2) {
86 t.Errorf("Sincos(%g) = %g, %g, want %g, %g", trigHuge[i], f2, g2, f1, g1)
87 }
88 }
89 }
90
91 func TestHugeTan(t *testing.T) {
92 for i := 0; i < len(trigHuge); i++ {
93 f1 := tanHuge[i]
94 f2 := Tan(trigHuge[i])
95 if !close(f1, f2) {
96 t.Errorf("Tan(%g) = %g, want %g", trigHuge[i], f2, f1)
97 }
98 }
99 }