Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1251)

Side by Side Diff: src/pkg/math/all_test.go

Issue 6344078: code review 6344078: math, runtime: use a NaN that matches gcc's (Closed)
Patch Set: diff -r 4bd268b3c88a https://code.google.com/p/go/ Created 11 years, 7 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/pkg/math/bits.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package math_test 5 package math_test
6 6
7 import ( 7 import (
8 "fmt" 8 "fmt"
9 . "math" 9 . "math"
10 "testing" 10 "testing"
(...skipping 1675 matching lines...) Expand 10 before | Expand all | Expand 10 after
1686 func alike(a, b float64) bool { 1686 func alike(a, b float64) bool {
1687 switch { 1687 switch {
1688 case IsNaN(a) && IsNaN(b): 1688 case IsNaN(a) && IsNaN(b):
1689 return true 1689 return true
1690 case a == b: 1690 case a == b:
1691 return Signbit(a) == Signbit(b) 1691 return Signbit(a) == Signbit(b)
1692 } 1692 }
1693 return false 1693 return false
1694 } 1694 }
1695 1695
1696 func TestNaN(t *testing.T) {
1697 f64 := NaN()
1698 if f64 == f64 {
1699 t.Fatalf("NaN() returns %g, expected NaN", f64)
1700 }
1701 f32 := float32(f64)
1702 if f32 == f32 {
1703 t.Fatalf("float32(NaN()) is %g, expected NaN", f32)
1704 }
1705 }
1706
1696 func TestAcos(t *testing.T) { 1707 func TestAcos(t *testing.T) {
1697 for i := 0; i < len(vf); i++ { 1708 for i := 0; i < len(vf); i++ {
1698 a := vf[i] / 10 1709 a := vf[i] / 10
1699 if f := Acos(a); !close(acos[i], f) { 1710 if f := Acos(a); !close(acos[i], f) {
1700 t.Errorf("Acos(%g) = %g, want %g", a, f, acos[i]) 1711 t.Errorf("Acos(%g) = %g, want %g", a, f, acos[i])
1701 } 1712 }
1702 } 1713 }
1703 for i := 0; i < len(vfacosSC); i++ { 1714 for i := 0; i < len(vfacosSC); i++ {
1704 if f := Acos(vfacosSC[i]); !alike(acosSC[i], f) { 1715 if f := Acos(vfacosSC[i]); !alike(acosSC[i], f) {
1705 t.Errorf("Acos(%g) = %g, want %g", vfacosSC[i], f, acosS C[i]) 1716 t.Errorf("Acos(%g) = %g, want %g", vfacosSC[i], f, acosS C[i])
(...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after
2908 for i := 0; i < b.N; i++ { 2919 for i := 0; i < b.N; i++ {
2909 Y1(2.5) 2920 Y1(2.5)
2910 } 2921 }
2911 } 2922 }
2912 2923
2913 func BenchmarkYn(b *testing.B) { 2924 func BenchmarkYn(b *testing.B) {
2914 for i := 0; i < b.N; i++ { 2925 for i := 0; i < b.N; i++ {
2915 Yn(2, 2.5) 2926 Yn(2, 2.5)
2916 } 2927 }
2917 } 2928 }
OLDNEW
« no previous file with comments | « no previous file | src/pkg/math/bits.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b