mirror of
https://github.com/golang/go
synced 2024-11-05 15:56:12 -07:00
052c942e20
Previously merely printing an error would cause the golden file comparison (in 'bash run') to fail, but that is no longer the case with the new run.go driver. R=iant CC=golang-dev https://golang.org/cl/7310087
52 lines
894 B
Go
52 lines
894 B
Go
// run cmplxdivide1.go
|
|
|
|
// Copyright 2010 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// Driver for complex division table defined in cmplxdivide1.go
|
|
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"math"
|
|
"math/cmplx"
|
|
)
|
|
|
|
type Test struct {
|
|
f, g complex128
|
|
out complex128
|
|
}
|
|
|
|
var nan = math.NaN()
|
|
var inf = math.Inf(1)
|
|
var negzero = math.Copysign(0, -1)
|
|
|
|
func calike(a, b complex128) bool {
|
|
switch {
|
|
case cmplx.IsInf(a) && cmplx.IsInf(b):
|
|
return true
|
|
case cmplx.IsNaN(a) && cmplx.IsNaN(b):
|
|
return true
|
|
}
|
|
return a == b
|
|
}
|
|
|
|
func main() {
|
|
bad := false
|
|
for _, t := range tests {
|
|
x := t.f / t.g
|
|
if !calike(x, t.out) {
|
|
if !bad {
|
|
fmt.Printf("BUG\n")
|
|
bad = true
|
|
}
|
|
fmt.Printf("%v/%v: expected %v error; got %v\n", t.f, t.g, t.out, x)
|
|
}
|
|
}
|
|
if bad {
|
|
panic("cmplxdivide failed.")
|
|
}
|
|
}
|