]> Cypherpunks.ru repositories - gostls13.git/blob - test/cmplxdivide.go
more soft float support. passes several basic tests
[gostls13.git] / test / cmplxdivide.go
1 // $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
9 package main
10
11 import (
12         "cmath"
13         "fmt"
14         "math"
15 )
16
17 type Test struct{
18         f, g    complex128
19         out     complex128
20 }
21
22 var nan = math.NaN()
23 var inf = math.Inf(1)
24 var negzero = math.Copysign(0, -1)
25
26 func 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
36 func main() {
37         bad := false
38         for _, t := range tests {
39                 x := t.f/t.g
40                 if !calike(x, t.out) {
41                         if !bad {
42                                 fmt.Printf("BUG\n")
43                                 bad = true
44                         }
45                         fmt.Printf("%v/%v: expected %v error; got %v\n", t.f, t.g, t.out, x)
46                 }
47         }
48 }