blob: 6a67b175de1eee9f2e959d40c97bce45c4b4dba2 [file] [log] [blame]
Russ Cox21ff75b2010-06-18 15:46:00 -07001// $G $D/$F.go $D/cmplxdivide1.go && $L $D/$F.$A && ./$A.out
2
3// Copyright 2010 The Go Authors. All rights reserved.
4// Use of this source code is governed by a BSD-style
5// license that can be found in the LICENSE file.
6
7// Driver for complex division table defined in cmplxdivide1.go
8
9package main
10
11import (
12 "cmath"
13 "fmt"
14 "math"
15)
16
17type Test struct{
18 f, g complex128
19 out complex128
20}
21
22var nan = math.NaN()
23var inf = math.Inf(1)
24var negzero = math.Copysign(0, -1)
25
26func calike(a, b complex128) bool {
27 switch {
28 case cmath.IsInf(a) && cmath.IsInf(b):
29 return true
30 case cmath.IsNaN(a) && cmath.IsNaN(b):
31 return true
32 }
33 return a == b
34}
35
36func main() {
Kai Backman36057e72010-07-20 15:53:16 +030037 bad := false
Russ Cox21ff75b2010-06-18 15:46:00 -070038 for _, t := range tests {
39 x := t.f/t.g
40 if !calike(x, t.out) {
Kai Backman36057e72010-07-20 15:53:16 +030041 if !bad {
42 fmt.Printf("BUG\n")
43 bad = true
44 }
Russ Cox21ff75b2010-06-18 15:46:00 -070045 fmt.Printf("%v/%v: expected %v error; got %v\n", t.f, t.g, t.out, x)
46 }
47 }
48}