2012-03-06 23:54:39 -07:00
|
|
|
// run cmplxdivide1.go
|
2010-06-18 16:46:00 -06:00
|
|
|
|
2016-04-10 15:32:26 -06:00
|
|
|
// Copyright 2010 The Go Authors. All rights reserved.
|
2010-06-18 16:46:00 -06:00
|
|
|
// 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
|
2017-02-25 15:50:56 -07:00
|
|
|
// For details, see the comment at the top of cmplxdivide.c.
|
2010-06-18 16:46:00 -06:00
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"math"
|
|
|
|
)
|
|
|
|
|
|
|
|
func calike(a, b complex128) bool {
|
2017-02-25 15:50:56 -07:00
|
|
|
if imag(a) != imag(b) && !(math.IsNaN(imag(a)) && math.IsNaN(imag(b))) {
|
|
|
|
return false
|
2010-06-18 16:46:00 -06:00
|
|
|
}
|
2017-02-25 15:50:56 -07:00
|
|
|
|
|
|
|
if real(a) != real(b) && !(math.IsNaN(real(a)) && math.IsNaN(real(b))) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
return true
|
2010-06-18 16:46:00 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
2010-07-20 06:53:16 -06:00
|
|
|
bad := false
|
2010-06-18 16:46:00 -06:00
|
|
|
for _, t := range tests {
|
2011-11-08 16:43:02 -07:00
|
|
|
x := t.f / t.g
|
2010-06-18 16:46:00 -06:00
|
|
|
if !calike(x, t.out) {
|
2010-07-20 06:53:16 -06:00
|
|
|
if !bad {
|
|
|
|
fmt.Printf("BUG\n")
|
|
|
|
bad = true
|
|
|
|
}
|
2010-06-18 16:46:00 -06:00
|
|
|
fmt.Printf("%v/%v: expected %v error; got %v\n", t.f, t.g, t.out, x)
|
|
|
|
}
|
|
|
|
}
|
2013-02-12 11:17:49 -07:00
|
|
|
if bad {
|
|
|
|
panic("cmplxdivide failed.")
|
|
|
|
}
|
2010-06-18 16:46:00 -06:00
|
|
|
}
|