OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [go.test/] [test/] [cmplxdivide.go] - Blame information for rev 700

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 700 jeremybenn
// $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
        "fmt"
13
        "math"
14
        "math/cmplx"
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 cmplx.IsInf(a) && cmplx.IsInf(b):
29
                return true
30
        case cmplx.IsNaN(a) && cmplx.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
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.