diff options
author | Ian Lance Taylor <iant@golang.org> | 2012-01-18 14:31:31 -0800 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2012-01-18 14:31:31 -0800 |
commit | f2030938522fae7c6b65569a20a7b9ed1431b8f8 (patch) | |
tree | f3715df98cecac151807d23e7ec9403765252d5b /test/ken/cplx4.go | |
parent | 39bb4bd454b915aed58d1732c6d7c6e3b233d706 (diff) | |
download | go-git-f2030938522fae7c6b65569a20a7b9ed1431b8f8.tar.gz |
test: change several tests to not print
This will make these tests more meaningful for gccgo, which
runs tests in parallel and has no equivalent to golden.out.
Remove ken/simpprint.go since it duplicates helloworld.go.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5536058
Diffstat (limited to 'test/ken/cplx4.go')
-rw-r--r-- | test/ken/cplx4.go | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/test/ken/cplx4.go b/test/ken/cplx4.go index 8524e47aec..738afcd2ca 100644 --- a/test/ken/cplx4.go +++ b/test/ken/cplx4.go @@ -15,30 +15,44 @@ const ( C1 = R + I // ADD(5,6) ) -func doprint(c complex128) { fmt.Printf("c = %f\n", c) } +func want(s, w string) { + if s != w { + panic(s + " != " + w) + } +} + +func doprint(c complex128, w string) { + s := fmt.Sprintf("%f", c) + want(s, w) +} func main() { // constants - fmt.Printf("c = %f\n", -C1) - doprint(C1) + s := fmt.Sprintf("%f", -C1) + want(s, "(-5.000000-6.000000i)") + doprint(C1, "(5.000000+6.000000i)") // variables c1 := C1 - fmt.Printf("c = %f\n", c1) - doprint(c1) + s = fmt.Sprintf("%f", c1) + want(s, "(5.000000+6.000000i)") + doprint(c1, "(5.000000+6.000000i)") // 128 c2 := complex128(C1) - fmt.Printf("c = %G\n", c2) + s = fmt.Sprintf("%G", c2) + want(s, "(5+6i)") // real, imag, complex c3 := complex(real(c2)+3, imag(c2)-5) + c2 - fmt.Printf("c = %G\n", c3) + s = fmt.Sprintf("%G", c3) + want(s, "(13+7i)") // compiler used to crash on nested divide c4 := complex(real(c3/2), imag(c3/2)) if c4 != c3/2 { fmt.Printf("BUG: c3 = %G != c4 = %G\n", c3, c4) + panic(0) } } |