diff --git a/test/ken/array.go b/test/ken/array.go index 809d243a42c..9600e8a1a6a 100644 --- a/test/ken/array.go +++ b/test/ken/array.go @@ -7,8 +7,7 @@ package main func -setpd(a []int) -{ +setpd(a []int) { // print("setpd a=", a, " len=", len(a), " cap=", cap(a), "\n"); for i:=0; i= 1000000 { randx -= 1000000; @@ -21,9 +20,7 @@ nrand(n int) int return randx%n; } -type Chan -struct -{ +type Chan struct { sc,rc chan int; // send and recv chan sv,rv int; // send and recv seq } @@ -38,14 +35,12 @@ var ) func -init() -{ +init() { nc = new(Chan); } func -mkchan(c,n int) []*Chan -{ +mkchan(c,n int) []*Chan { ca := make([]*Chan, n); for i:=0; i=0; r-- { @@ -100,9 +91,7 @@ send(c *Chan) nproc--; } -func (c *Chan) -recv(v int) bool -{ +func (c *Chan) recv(v int) bool { // print("recv ", v, "\n"); totr++; c.rv = expect(c.rv, v); @@ -114,8 +103,7 @@ recv(v int) bool } func -recv(c *Chan) -{ +recv(c *Chan) { var v int; nproc++; // total goroutines running @@ -132,8 +120,7 @@ recv(c *Chan) } func -sel(r0,r1,r2,r3, s0,s1,s2,s3 *Chan) -{ +sel(r0,r1,r2,r3, s0,s1,s2,s3 *Chan) { var v int; nproc++; // total goroutines running @@ -196,16 +183,14 @@ sel(r0,r1,r2,r3, s0,s1,s2,s3 *Chan) // direct send to direct recv func -test1(c *Chan) -{ +test1(c *Chan) { go send(c); go recv(c); } // direct send to select recv func -test2(c int) -{ +test2(c int) { ca := mkchan(c,4); go send(ca[0]); @@ -218,8 +203,7 @@ test2(c int) // select send to direct recv func -test3(c int) -{ +test3(c int) { ca := mkchan(c,4); go recv(ca[0]); @@ -232,8 +216,7 @@ test3(c int) // select send to select recv func -test4(c int) -{ +test4(c int) { ca := mkchan(c,4); go sel(nc,nc,nc,nc, ca[0],ca[1],ca[2],ca[3]); @@ -241,8 +224,7 @@ test4(c int) } func -test5(c int) -{ +test5(c int) { ca := mkchan(c,8); go sel(ca[4],ca[5],ca[6],ca[7], ca[0],ca[1],ca[2],ca[3]); @@ -250,8 +232,7 @@ test5(c int) } func -test6(c int) -{ +test6(c int) { ca := mkchan(c,12); go send(ca[4]); @@ -270,8 +251,7 @@ test6(c int) // wait for outstanding tests to finish func -wait() -{ +wait() { runtime.Gosched(); for nproc != 0 { runtime.Gosched(); @@ -280,8 +260,7 @@ wait() // run all tests with specified buffer size func -tests(c int) -{ +tests(c int) { ca := mkchan(c,4); test1(ca[0]); test1(ca[1]); @@ -307,19 +286,18 @@ tests(c int) // run all test with 4 buffser sizes func -main() -{ +main() { tests(0); tests(1); tests(10); tests(100); - t := 4 // buffer sizes - * ( 4*4 // tests 1,2,3,4 channels - + 8 // test 5 channels - + 12 // test 6 channels - ) * 76; // sends/recvs on a channel + t := 4 * // buffer sizes + ( 4*4 + // tests 1,2,3,4 channels + 8 + // test 5 channels + 12 ) * // test 6 channels + 76; // sends/recvs on a channel if tots != t || totr != t { print("tots=", tots, " totr=", totr, " sb=", t, "\n"); diff --git a/test/ken/chan1.go b/test/ken/chan1.go index 2905e08c548..0008e314b69 100644 --- a/test/ken/chan1.go +++ b/test/ken/chan1.go @@ -14,8 +14,7 @@ const W = 2; // channel buffering var h [N]int; // marking of send/recv func -r(c chan int, m int) -{ +r(c chan int, m int) { for { select { case r := <- c: @@ -23,7 +22,7 @@ r(c chan int, m int) panicln("r", "m=", m, "r=", r, - "h=", h[r] + "h=", h[r], ); } h[r] = 2; @@ -32,8 +31,7 @@ r(c chan int, m int) } func -s(c chan int) -{ +s(c chan int) { for n:=0; n= len(answers) { println(xs, x); @@ -119,8 +117,7 @@ var ms = map[int]S{0:S{5101,5102,5103},1:S{5104,5105,5106},2:S{5107,5108,5109}} var mc = map[int][]int{0:[]int{5201,5202,5203}, 1:[]int{5204,5205,5206}, 2:[]int{5207,5208,5209}} var mm = map[int]M{0:M{0:5301,1:5302,2:5303}, 1:M{0:5304,1:5305,2:5306}, 2:M{0:5307,1:5308,2:5309}} -var answers = [...]int -{ +var answers = [...]int { // s 1101, 1102, 1103, diff --git a/test/ken/divconst.go b/test/ken/divconst.go index 0b2e059748f..4143dc58178 100644 --- a/test/ken/divconst.go +++ b/test/ken/divconst.go @@ -11,8 +11,7 @@ import "rand" const Count = 1e5 func -i64rand() int64 -{ +i64rand() int64 { for { a := int64(rand.Uint32()); a = (a<<32) | int64(rand.Uint32()); @@ -25,8 +24,7 @@ i64rand() int64 } func -i64test(a,b,c int64) -{ +i64test(a,b,c int64) { d := a/c; if d != b { panicln("i64", a, b, c, d); @@ -34,8 +32,7 @@ i64test(a,b,c int64) } func -i64run() -{ +i64run() { var a, b int64; for i:=0; i>= uint(rand.Intn(64)); @@ -89,8 +85,7 @@ u64rand() uint64 } func -u64test(a,b,c uint64) -{ +u64test(a,b,c uint64) { d := a/c; if d != b { panicln("u64", a, b, c, d); @@ -98,8 +93,7 @@ u64test(a,b,c uint64) } func -u64run() -{ +u64run() { var a, b uint64; for i:=0; i>= uint(rand.Intn(32)); @@ -139,8 +132,7 @@ i32rand() int32 } func -i32test(a,b,c int32) -{ +i32test(a,b,c int32) { d := a/c; if d != b { panicln("i32", a, b, c, d); @@ -148,8 +140,7 @@ i32test(a,b,c int32) } func -i32run() -{ +i32run() { var a, b int32; for i:=0; i>= uint(rand.Intn(32)); return a; } func -u32test(a,b,c uint32) -{ +u32test(a,b,c uint32) { d := a/c; if d != b { panicln("u32", a, b, c, d); @@ -210,8 +199,7 @@ u32test(a,b,c uint32) } func -u32run() -{ +u32run() { var a, b uint32; for i:=0; i>= uint(rand.Intn(16)); @@ -251,8 +238,7 @@ i16rand() int16 } func -i16test(a,b,c int16) -{ +i16test(a,b,c int16) { d := a/c; if d != b { panicln("i16", a, b, c, d); @@ -260,8 +246,7 @@ i16test(a,b,c int16) } func -i16run() -{ +i16run() { var a, b int16; for i:=0; i>= uint(rand.Intn(16)); return a; } func -u16test(a,b,c uint16) -{ +u16test(a,b,c uint16) { d := a/c; if d != b { panicln("u16", a, b, c, d); @@ -323,8 +306,7 @@ u16test(a,b,c uint16) } func -u16run() -{ +u16run() { var a, b uint16; for i:=0; i>= uint(rand.Intn(8)); @@ -364,8 +345,7 @@ i8rand() int8 } func -i8test(a,b,c int8) -{ +i8test(a,b,c int8) { d := a/c; if d != b { panicln("i8", a, b, c, d); @@ -373,8 +353,7 @@ i8test(a,b,c int8) } func -i8run() -{ +i8run() { var a, b int8; for i:=0; i>= uint(rand.Intn(8)); return a; } func -u8test(a,b,c uint8) -{ +u8test(a,b,c uint8) { d := a/c; if d != b { panicln("u8", a, b, c, d); @@ -432,8 +409,7 @@ u8test(a,b,c uint8) } func -u8run() -{ +u8run() { var a, b uint8; for i:=0; i>= uint(rand.Intn(64)); @@ -89,8 +85,7 @@ u64rand() uint64 } func -u64test(a,b,c uint64) -{ +u64test(a,b,c uint64) { d := a%c; if d != b { panicln("u64", a, b, c, d); @@ -98,8 +93,7 @@ u64test(a,b,c uint64) } func -u64run() -{ +u64run() { var a, b uint64; for i:=0; i>= uint(rand.Intn(32)); @@ -139,8 +132,7 @@ i32rand() int32 } func -i32test(a,b,c int32) -{ +i32test(a,b,c int32) { d := a%c; if d != b { panicln("i32", a, b, c, d); @@ -148,8 +140,7 @@ i32test(a,b,c int32) } func -i32run() -{ +i32run() { var a, b int32; for i:=0; i>= uint(rand.Intn(32)); return a; } func -u32test(a,b,c uint32) -{ +u32test(a,b,c uint32) { d := a%c; if d != b { panicln("u32", a, b, c, d); @@ -210,8 +199,7 @@ u32test(a,b,c uint32) } func -u32run() -{ +u32run() { var a, b uint32; for i:=0; i>= uint(rand.Intn(16)); @@ -251,8 +238,7 @@ i16rand() int16 } func -i16test(a,b,c int16) -{ +i16test(a,b,c int16) { d := a%c; if d != b { panicln("i16", a, b, c, d); @@ -260,8 +246,7 @@ i16test(a,b,c int16) } func -i16run() -{ +i16run() { var a, b int16; for i:=0; i>= uint(rand.Intn(16)); return a; } func -u16test(a,b,c uint16) -{ +u16test(a,b,c uint16) { d := a%c; if d != b { panicln("u16", a, b, c, d); @@ -323,8 +306,7 @@ u16test(a,b,c uint16) } func -u16run() -{ +u16run() { var a, b uint16; for i:=0; i>= uint(rand.Intn(8)); @@ -364,8 +345,7 @@ i8rand() int8 } func -i8test(a,b,c int8) -{ +i8test(a,b,c int8) { d := a%c; if d != b { panicln("i8", a, b, c, d); @@ -373,8 +353,7 @@ i8test(a,b,c int8) } func -i8run() -{ +i8run() { var a, b int8; for i:=0; i>= uint(rand.Intn(8)); return a; } func -u8test(a,b,c uint8) -{ +u8test(a,b,c uint8) { d := a%c; if d != b { panicln("u8", a, b, c, d); @@ -433,8 +410,7 @@ u8test(a,b,c uint8) } func -u8run() -{ +u8run() { var a, b uint8; for i:=0; i= 0 { @@ -141,13 +137,11 @@ func Get() int return c; } -func WhiteSpace(c int) bool -{ +func WhiteSpace(c int) bool { return c == ' ' || c == '\t' || c == '\r' || c == '\n'; } -func NextToken() -{ +func NextToken() { var i, c int; tokenbuf[0] = nilchar; // clear previous token @@ -187,8 +181,7 @@ func NextToken() } } -func Expect(c int) -{ +func Expect(c int) { if token != c { print("parse error: expected ", c, "\n"); panic("parse"); @@ -197,8 +190,7 @@ func Expect(c int) } // Parse a non-parenthesized list up to a closing paren or EOF -func ParseList() *Slist -{ +func ParseList() *Slist { var slist, retval *Slist; slist = new(Slist); @@ -219,8 +211,7 @@ func ParseList() *Slist return retval; } -func atom(i int) *Slist // BUG: uses tokenbuf; should take argument -{ +func atom(i int) *Slist { // BUG: uses tokenbuf; should take argument) var slist *Slist; slist = new(Slist); @@ -235,8 +226,7 @@ func atom(i int) *Slist // BUG: uses tokenbuf; should take argument return slist; } -func atoi() int // BUG: uses tokenbuf; should take argument -{ +func atoi() int { // BUG: uses tokenbuf; should take argument) var v int = 0; for i := 0; i < tokenlen && '0' <= tokenbuf[i] && tokenbuf[i] <= '9'; i = i + 1 { v = 10 * v + int(tokenbuf[i] - '0'); @@ -244,8 +234,7 @@ func atoi() int // BUG: uses tokenbuf; should take argument return v; } -func Parse() *Slist -{ +func Parse() *Slist { var slist *Slist; if token == EOF || token == ')' { @@ -275,8 +264,7 @@ func Parse() *Slist return nil; } -func OpenFile() -{ +func OpenFile() { input = "(defn foo (add 12 34))\n\x00"; inputindex = 0; peekc = -1; // BUG diff --git a/test/ken/shift.go b/test/ken/shift.go index 379f53fa422..157a07aec54 100644 --- a/test/ken/shift.go +++ b/test/ken/shift.go @@ -11,8 +11,7 @@ var uans [18]uint; var pass string; func -testi(i int, t1,t2,t3 int) -{ +testi(i int, t1,t2,t3 int) { n := ((t1*3) + t2)*2 + t3; if i != ians[n] { print("itest ", t1,t2,t3,pass, @@ -21,14 +20,12 @@ testi(i int, t1,t2,t3 int) } func -index(t1,t2,t3 int) int -{ +index(t1,t2,t3 int) int { return ((t1*3) + t2)*2 + t3; } func -testu(u uint, t1,t2,t3 int) -{ +testu(u uint, t1,t2,t3 int) { n := index(t1,t2,t3); if u != uans[n] { print("utest ", t1,t2,t3,pass, @@ -37,8 +34,7 @@ testu(u uint, t1,t2,t3 int) } func -main() -{ +main() { var i int; var u,c uint; @@ -95,8 +91,7 @@ main() } func -init() -{ +init() { /* * set the 'correct' answer */ diff --git a/test/ken/simparray.go b/test/ken/simparray.go index 90331e5e3d5..1b6f245eea2 100644 --- a/test/ken/simparray.go +++ b/test/ken/simparray.go @@ -9,8 +9,7 @@ package main var b[10] float32; func -main() -{ +main() { var a[10] float32; for i:=int16(5); i<10; i=i+1 { diff --git a/test/ken/simpbool.go b/test/ken/simpbool.go index aad111dd556..dbd9c8d8bcf 100644 --- a/test/ken/simpbool.go +++ b/test/ken/simpbool.go @@ -6,15 +6,13 @@ package main -type s struct -{ +type s struct { a bool; b bool; } func -main() -{ +main() { var a,b bool; a = true; diff --git a/test/ken/simpconv.go b/test/ken/simpconv.go index 9785138aeb2..cb443e3a19b 100644 --- a/test/ken/simpconv.go +++ b/test/ken/simpconv.go @@ -10,8 +10,7 @@ type vlong int64; type short int16; func -main() -{ +main() { s1 := vlong(0); for i:=short(0); i<10; i=i+1 { s1 = s1 + vlong(i); diff --git a/test/ken/simpfun.go b/test/ken/simpfun.go index ee2c1a9a091..ba9ce6f7bce 100644 --- a/test/ken/simpfun.go +++ b/test/ken/simpfun.go @@ -8,8 +8,7 @@ package main func -main() -{ +main() { var x int; x = fun(10,20,30); @@ -17,8 +16,7 @@ main() } func -fun(ia,ib,ic int)int -{ +fun(ia,ib,ic int)int { var o int; o = ia+ib+ic; diff --git a/test/ken/simpprint.go b/test/ken/simpprint.go index 98393a45705..6077f7eb025 100644 --- a/test/ken/simpprint.go +++ b/test/ken/simpprint.go @@ -8,7 +8,6 @@ package main func -main() -{ +main() { print("hello world\n"); } diff --git a/test/ken/simpswitch.go b/test/ken/simpswitch.go index e5f39e35438..ab5dd356b3e 100644 --- a/test/ken/simpswitch.go +++ b/test/ken/simpswitch.go @@ -7,8 +7,7 @@ package main func -main() -{ +main() { a := 3; for i:=0; i<10; i=i+1 { switch(i) { diff --git a/test/ken/simpvar.go b/test/ken/simpvar.go index 70946bf70ef..fd060b0e2e9 100644 --- a/test/ken/simpvar.go +++ b/test/ken/simpvar.go @@ -10,8 +10,7 @@ package main var x,y int; func -main() -{ +main() { x = 15; y = 20; diff --git a/test/ken/slicearray.go b/test/ken/slicearray.go index a8f5ad928dc..f24c7fc9c23 100644 --- a/test/ken/slicearray.go +++ b/test/ken/slicearray.go @@ -14,8 +14,7 @@ var lb,hb int var t int func -main() -{ +main() { lb = 0; hb = 10; by = &bx; tstb(); @@ -82,8 +81,7 @@ main() } func -tstb() -{ +tstb() { t++; if len(by) != hb-lb { panicln("t=", t, "lb=", lb, "hb=", hb, @@ -104,8 +102,7 @@ tstb() } func -tstf() -{ +tstf() { t++; if len(fy) != hb-lb { panicln("t=", t, "lb=", lb, "hb=", hb, @@ -126,8 +123,7 @@ tstf() } func -init() -{ +init() { for i:=0; i