Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
bd80b5a8
Commit
bd80b5a8
authored
Nov 24, 2009
by
Ken Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test case for large angles in trig functions
R=rsc
https://golang.org/cl/157160
parent
b2bc1db9
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
0 deletions
+37
-0
all_test.go
src/pkg/math/all_test.go
+37
-0
No files found.
src/pkg/math/all_test.go
View file @
bd80b5a8
...
@@ -169,6 +169,7 @@ func tolerance(a, b, e float64) bool {
...
@@ -169,6 +169,7 @@ func tolerance(a, b, e float64) bool {
}
}
return
d
<
e
;
return
d
<
e
;
}
}
func
kindaclose
(
a
,
b
float64
)
bool
{
return
tolerance
(
a
,
b
,
1e-8
)
}
func
close
(
a
,
b
float64
)
bool
{
return
tolerance
(
a
,
b
,
1e-14
)
}
func
close
(
a
,
b
float64
)
bool
{
return
tolerance
(
a
,
b
,
1e-14
)
}
func
veryclose
(
a
,
b
float64
)
bool
{
return
tolerance
(
a
,
b
,
4e-16
)
}
func
veryclose
(
a
,
b
float64
)
bool
{
return
tolerance
(
a
,
b
,
4e-16
)
}
...
@@ -274,6 +275,42 @@ func TestHypot(t *testing.T) {
...
@@ -274,6 +275,42 @@ func TestHypot(t *testing.T) {
}
}
}
}
// Check that math functions of high angle values
// return similar results to low angle values
func
TestLargeSin
(
t
*
testing
.
T
)
{
large
:=
float64
(
100000
*
Pi
);
for
i
:=
0
;
i
<
len
(
vf
);
i
++
{
f1
:=
Sin
(
vf
[
i
]);
f2
:=
Sin
(
vf
[
i
]
+
large
);
if
!
kindaclose
(
f1
,
f2
)
{
t
.
Errorf
(
"Sin(%g) = %g, want %g
\n
"
,
vf
[
i
]
+
large
,
f1
,
f2
)
}
}
}
func
TestLargeCos
(
t
*
testing
.
T
)
{
large
:=
float64
(
100000
*
Pi
);
for
i
:=
0
;
i
<
len
(
vf
);
i
++
{
f1
:=
Cos
(
vf
[
i
]);
f2
:=
Cos
(
vf
[
i
]
+
large
);
if
!
kindaclose
(
f1
,
f2
)
{
t
.
Errorf
(
"Cos(%g) = %g, want %g
\n
"
,
vf
[
i
]
+
large
,
f1
,
f2
)
}
}
}
func
TestLargeTan
(
t
*
testing
.
T
)
{
large
:=
float64
(
100000
*
Pi
);
for
i
:=
0
;
i
<
len
(
vf
);
i
++
{
f1
:=
Tan
(
vf
[
i
]);
f2
:=
Tan
(
vf
[
i
]
+
large
);
if
!
kindaclose
(
f1
,
f2
)
{
t
.
Errorf
(
"Tan(%g) = %g, want %g
\n
"
,
vf
[
i
]
+
large
,
f1
,
f2
)
}
}
}
// Check that math constants are accepted by compiler
// Check that math constants are accepted by compiler
// and have right value (assumes strconv.Atof works).
// and have right value (assumes strconv.Atof works).
// http://code.google.com/p/go/issues/detail?id=201
// http://code.google.com/p/go/issues/detail?id=201
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment