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