Source file
test/cmplxdivide.go
1
2
3
4
5
6
7
8
9
10 package main
11
12 import (
13 "fmt"
14 "math"
15 )
16
17 func calike(a, b complex128) bool {
18 if imag(a) != imag(b) && !(math.IsNaN(imag(a)) && math.IsNaN(imag(b))) {
19 return false
20 }
21
22 if real(a) != real(b) && !(math.IsNaN(real(a)) && math.IsNaN(real(b))) {
23 return false
24 }
25
26 return true
27 }
28
29 func main() {
30 bad := false
31 for _, t := range tests {
32 x := t.f / t.g
33 if !calike(x, t.out) {
34 if !bad {
35 fmt.Printf("BUG\n")
36 bad = true
37 }
38 fmt.Printf("%v/%v: expected %v error; got %v\n", t.f, t.g, t.out, x)
39 }
40 }
41 if bad {
42 panic("cmplxdivide failed.")
43 }
44 }
45
View as plain text