summaryrefslogtreecommitdiff
path: root/test/ken
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2011-01-19 23:09:00 -0500
committerRuss Cox <rsc@golang.org>2011-01-19 23:09:00 -0500
commited3592f95664c555d787d87b28ff783b846257e6 (patch)
tree9bfdc7720f6c491c1c293a4bd367abec2a1221f4 /test/ken
parent8d36be6d5ae904467a0be5e7dc3965581a3dbf73 (diff)
downloadgo-ed3592f95664c555d787d87b28ff783b846257e6.tar.gz
delete float, complex - code changes
also: cmplx -> complex float64(1.0) -> 1.0 float64(1) -> 1.0 R=gri, r, gri1, r2 CC=golang-dev http://codereview.appspot.com/3991043
Diffstat (limited to 'test/ken')
-rw-r--r--test/ken/cplx0.go2
-rw-r--r--test/ken/cplx1.go2
-rw-r--r--test/ken/cplx2.go4
-rw-r--r--test/ken/cplx3.go12
-rw-r--r--test/ken/cplx4.go8
-rw-r--r--test/ken/cplx5.go32
-rw-r--r--test/ken/robfunc.go96
-rw-r--r--test/ken/simpconv.go27
-rw-r--r--test/ken/slicearray.go8
-rw-r--r--test/ken/sliceslice.go10
10 files changed, 99 insertions, 102 deletions
diff --git a/test/ken/cplx0.go b/test/ken/cplx0.go
index 6e9bfd023..ba1fa196f 100644
--- a/test/ken/cplx0.go
+++ b/test/ken/cplx0.go
@@ -13,7 +13,7 @@ const (
C1 = R + I // ADD(5,6)
)
-func doprint(c complex) { println(c) }
+func doprint(c complex128) { println(c) }
func main() {
diff --git a/test/ken/cplx1.go b/test/ken/cplx1.go
index 26b113992..8ec7d40f5 100644
--- a/test/ken/cplx1.go
+++ b/test/ken/cplx1.go
@@ -48,7 +48,7 @@ func main() {
booltest(6+9i, false)
}
-func booltest(a complex, r bool) {
+func booltest(a complex64, r bool) {
var b bool
b = a == C1
diff --git a/test/ken/cplx2.go b/test/ken/cplx2.go
index 5a66dc9a9..b36e93ecd 100644
--- a/test/ken/cplx2.go
+++ b/test/ken/cplx2.go
@@ -28,13 +28,13 @@ const (
func main() {
- r := 5 + 0i
+ var r complex64 = 5 + 0i
if r != R {
println("opcode 1", r, R)
panic("fail")
}
- i := 6i
+ var i complex64 = 6i
if i != I {
println("opcode 2", i, I)
panic("fail")
diff --git a/test/ken/cplx3.go b/test/ken/cplx3.go
index 997894b41..83acc15ff 100644
--- a/test/ken/cplx3.go
+++ b/test/ken/cplx3.go
@@ -16,24 +16,18 @@ const (
C1 = R + I // ADD(5,6)
)
-var complexBits = reflect.Typeof(complex(0i)).Size() * 8
-
func main() {
c0 := C1
c0 = (c0 + c0 + c0) / (c0 + c0 + 3i)
println(c0)
- c := *(*complex)(unsafe.Pointer(&c0))
+ c := *(*complex128)(unsafe.Pointer(&c0))
println(c)
- println(complexBits)
-
var a interface{}
switch c := reflect.NewValue(a).(type) {
case *reflect.ComplexValue:
- if complexBits == 64 {
- v := c.Get()
- _, _ = complex64(v), true
- }
+ v := c.Get()
+ _, _ = complex128(v), true
}
}
diff --git a/test/ken/cplx4.go b/test/ken/cplx4.go
index 3c6f1f68c..8524e47ae 100644
--- a/test/ken/cplx4.go
+++ b/test/ken/cplx4.go
@@ -15,7 +15,7 @@ const (
C1 = R + I // ADD(5,6)
)
-func doprint(c complex) { fmt.Printf("c = %f\n", c) }
+func doprint(c complex128) { fmt.Printf("c = %f\n", c) }
func main() {
@@ -32,12 +32,12 @@ func main() {
c2 := complex128(C1)
fmt.Printf("c = %G\n", c2)
- // real, imag, cmplx
- c3 := cmplx(real(c2)+3, imag(c2)-5) + c2
+ // real, imag, complex
+ c3 := complex(real(c2)+3, imag(c2)-5) + c2
fmt.Printf("c = %G\n", c3)
// compiler used to crash on nested divide
- c4 := cmplx(real(c3/2), imag(c3/2))
+ c4 := complex(real(c3/2), imag(c3/2))
if c4 != c3/2 {
fmt.Printf("BUG: c3 = %G != c4 = %G\n", c3, c4)
}
diff --git a/test/ken/cplx5.go b/test/ken/cplx5.go
index af2a1c57d..d425a7c4c 100644
--- a/test/ken/cplx5.go
+++ b/test/ken/cplx5.go
@@ -6,49 +6,49 @@
package main
-var a [12]complex
-var s []complex
-var c chan complex
+var a [12]complex128
+var s []complex128
+var c chan complex128
var f struct {
- c complex
+ c complex128
}
-var m map[complex]complex
+var m map[complex128]complex128
func main() {
- // array of complex
+ // array of complex128
for i := 0; i < len(a); i++ {
- a[i] = cmplx(float(i), float(-i))
+ a[i] = complex(float64(i), float64(-i))
}
println(a[5])
- // slice of complex
- s = make([]complex, len(a))
+ // slice of complex128
+ s = make([]complex128, len(a))
for i := 0; i < len(s); i++ {
s[i] = a[i]
}
println(s[5])
// chan
- c = make(chan complex)
+ c = make(chan complex128)
go chantest(c)
println(<-c)
- // pointer of complex
+ // pointer of complex128
v := a[5]
pv := &v
println(*pv)
- // field of complex
+ // field of complex128
f.c = a[5]
println(f.c)
- // map of complex
- m = make(map[complex]complex)
+ // map of complex128
+ m = make(map[complex128]complex128)
for i := 0; i < len(s); i++ {
m[-a[i]] = a[i]
}
println(m[5i-5])
- println(m[cmplx(-5, 5)])
+ println(m[complex(-5, 5)])
}
-func chantest(c chan complex) { c <- a[5] }
+func chantest(c chan complex128) { c <- a[5] }
diff --git a/test/ken/robfunc.go b/test/ken/robfunc.go
index 12b4b6d7b..6b3d4b2e4 100644
--- a/test/ken/robfunc.go
+++ b/test/ken/robfunc.go
@@ -8,8 +8,8 @@ package main
func assertequal(is, shouldbe int, msg string) {
if is != shouldbe {
- print("assertion fail" + msg + "\n");
- panic(1);
+ print("assertion fail" + msg + "\n")
+ panic(1)
}
}
@@ -20,75 +20,75 @@ func f2(a int) {
}
func f3(a, b int) int {
- return a+b;
+ return a + b
}
-func f4(a, b int, c float) int {
- return (a+b)/2 + int(c);
+func f4(a, b int, c float64) int {
+ return (a+b)/2 + int(c)
}
func f5(a int) int {
- return 5;
+ return 5
}
func f6(a int) (r int) {
- return 6;
+ return 6
}
-func f7(a int) (x int, y float) {
- return 7, 7.0;
+func f7(a int) (x int, y float64) {
+ return 7, 7.0
}
-func f8(a int) (x int, y float) {
- return 8, 8.0;
+func f8(a int) (x int, y float64) {
+ return 8, 8.0
}
type T struct {
- x, y int;
+ x, y int
}
-func (t *T) m10(a int, b float) int {
- return (t.x+a) * (t.y+int(b));
+func (t *T) m10(a int, b float64) int {
+ return (t.x + a) * (t.y + int(b))
}
-func f9(a int) (in int, fl float) {
- i := 9;
- f := float(9);
- return i, f;
+func f9(a int) (in int, fl float64) {
+ i := 9
+ f := float64(9)
+ return i, f
}
func main() {
- f1();
- f2(1);
- r3 := f3(1, 2);
- assertequal(r3, 3, "3");
- r4 := f4(0, 2, 3.0);
- assertequal(r4, 4, "4");
- r5 := f5(1);
- assertequal(r5, 5, "5");
- r6 := f6(1);
- assertequal(r6, 6, "6");
- var r7 int;
- var s7 float;
- r7, s7 = f7(1);
- assertequal(r7, 7, "r7");
- assertequal(int(s7), 7, "s7");
- var r8 int;
- var s8 float;
- r8, s8 = f8(1);
- assertequal(r8, 8, "r8");
- assertequal(int(s8), 8, "s8");
- var r9 int;
- var s9 float;
- r9, s9 = f9(1);
- assertequal(r9, 9, "r9");
- assertequal(int(s9), 9, "s9");
- var t *T = new(T);
- t.x = 1;
- t.y = 2;
- r10 := t.m10(1, 3.0);
- assertequal(r10, 10, "10");
+ f1()
+ f2(1)
+ r3 := f3(1, 2)
+ assertequal(r3, 3, "3")
+ r4 := f4(0, 2, 3.0)
+ assertequal(r4, 4, "4")
+ r5 := f5(1)
+ assertequal(r5, 5, "5")
+ r6 := f6(1)
+ assertequal(r6, 6, "6")
+ var r7 int
+ var s7 float64
+ r7, s7 = f7(1)
+ assertequal(r7, 7, "r7")
+ assertequal(int(s7), 7, "s7")
+ var r8 int
+ var s8 float64
+ r8, s8 = f8(1)
+ assertequal(r8, 8, "r8")
+ assertequal(int(s8), 8, "s8")
+ var r9 int
+ var s9 float64
+ r9, s9 = f9(1)
+ assertequal(r9, 9, "r9")
+ assertequal(int(s9), 9, "s9")
+ var t *T = new(T)
+ t.x = 1
+ t.y = 2
+ r10 := t.m10(1, 3.0)
+ assertequal(r10, 10, "10")
}
diff --git a/test/ken/simpconv.go b/test/ken/simpconv.go
index cb443e3a1..feb85d299 100644
--- a/test/ken/simpconv.go
+++ b/test/ken/simpconv.go
@@ -6,20 +6,23 @@
package main
-type vlong int64;
-type short int16;
+type vlong int64
+type short int16
-func
-main() {
- s1 := vlong(0);
- for i:=short(0); i<10; i=i+1 {
- s1 = s1 + vlong(i);
+func main() {
+ s1 := vlong(0)
+ for i := short(0); i < 10; i = i + 1 {
+ s1 = s1 + vlong(i)
+ }
+ if s1 != 45 {
+ panic(s1)
}
- if s1 != 45 { panic(s1); }
- s2 := float(0);
- for i:=0; i<10; i=i+1 {
- s2 = s2 + float(i);
+ s2 := float64(0)
+ for i := 0; i < 10; i = i + 1 {
+ s2 = s2 + float64(i)
+ }
+ if s2 != 45 {
+ panic(s2)
}
- if s2 != 45 { panic(s2); }
}
diff --git a/test/ken/slicearray.go b/test/ken/slicearray.go
index 6e7088e19..5c31270fc 100644
--- a/test/ken/slicearray.go
+++ b/test/ken/slicearray.go
@@ -8,8 +8,8 @@ package main
var bx [10]byte
var by []byte
-var fx [10]float
-var fy []float
+var fx [10]float64
+var fy []float64
var lb, hb int
var t int
@@ -87,7 +87,7 @@ func main() {
by = bx[2:8]
tstb()
- // width 4 (float)
+ // width 4 (float64)
lb = 0
hb = 10
fy = fx[lb:hb]
@@ -204,7 +204,7 @@ func init() {
by = nil
for i := 0; i < len(fx); i++ {
- fx[i] = float(i + 20)
+ fx[i] = float64(i + 20)
}
fy = nil
}
diff --git a/test/ken/sliceslice.go b/test/ken/sliceslice.go
index 5a35acaf4..639042128 100644
--- a/test/ken/sliceslice.go
+++ b/test/ken/sliceslice.go
@@ -8,8 +8,8 @@ package main
var bx []byte
var by []byte
-var fx []float
-var fy []float
+var fx []float64
+var fy []float64
var lb, hb int
var t int
@@ -78,7 +78,7 @@ func main() {
by = bx[2:8]
tstb()
- // width 4 (float)
+ // width 4 (float64)
lb = 0
hb = 10
fy = fx[lb:hb]
@@ -195,9 +195,9 @@ func init() {
}
by = nil
- fx = make([]float, 10)
+ fx = make([]float64, 10)
for i := 0; i < len(fx); i++ {
- fx[i] = float(i + 20)
+ fx[i] = float64(i + 20)
}
fy = nil
}