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