]> Cypherpunks repositories - gostls13.git/commitdiff
make test/ken safe for optional semis
authorRobert Griesemer <gri@golang.org>
Thu, 10 Dec 2009 20:53:23 +0000 (12:53 -0800)
committerRobert Griesemer <gri@golang.org>
Thu, 10 Dec 2009 20:53:23 +0000 (12:53 -0800)
R=rsc, ken2, ken3
https://golang.org/cl/174042

32 files changed:
test/ken/array.go
test/ken/chan.go
test/ken/chan1.go
test/ken/complit.go
test/ken/divconst.go
test/ken/divmod.go
test/ken/embed.go
test/ken/for.go
test/ken/interbasic.go
test/ken/interfun.go
test/ken/intervar.go
test/ken/label.go
test/ken/litfun.go
test/ken/mfunc.go
test/ken/modconst.go
test/ken/ptrfun.go
test/ken/ptrvar.go
test/ken/range.go
test/ken/rob1.go
test/ken/rob2.go
test/ken/shift.go
test/ken/simparray.go
test/ken/simpbool.go
test/ken/simpconv.go
test/ken/simpfun.go
test/ken/simpprint.go
test/ken/simpswitch.go
test/ken/simpvar.go
test/ken/slicearray.go
test/ken/sliceslice.go
test/ken/string.go
test/ken/strvar.go

index 809d243a42c6186e500f73deb840aeb56ebe6721..9600e8a1a6acb5c80adb3555255abb08eacc7c2c 100644 (file)
@@ -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<len(a); i++ {
                a[i] = i;
@@ -16,8 +15,7 @@ setpd(a []int)
 }
 
 func
-sumpd(a []int) int
-{
+sumpd(a []int) int {
 //     print("sumpd a=", a, " len=", len(a), " cap=", cap(a), "\n");
        t := 0;
        for i:=0; i<len(a); i++ {
@@ -28,8 +26,7 @@ sumpd(a []int) int
 }
 
 func
-setpf(a *[20]int)
-{
+setpf(a *[20]int) {
 //     print("setpf a=", a, " len=", len(a), " cap=", cap(a), "\n");
        for i:=0; i<len(a); i++ {
                a[i] = i;
@@ -37,8 +34,7 @@ setpf(a *[20]int)
 }
 
 func
-sumpf(a *[20]int) int
-{
+sumpf(a *[20]int) int {
 //     print("sumpf a=", a, " len=", len(a), " cap=", cap(a), "\n");
        t := 0;
        for i:=0; i<len(a); i++ {
@@ -49,8 +45,7 @@ sumpf(a *[20]int) int
 }
 
 func
-res(t int, lb, hb int)
-{
+res(t int, lb, hb int) {
        sb := (hb-lb)*(hb+lb-1)/2;
        if t != sb {
                print(  "lb=", lb,
@@ -64,8 +59,7 @@ res(t int, lb, hb int)
 
 // call ptr dynamic with ptr dynamic
 func
-testpdpd()
-{
+testpdpd() {
        a := make([]int, 10, 100);
        if len(a) != 10 && cap(a) != 100 {
                panic("len and cap from new: ", len(a), " ", cap(a), "\n");
@@ -83,8 +77,7 @@ testpdpd()
 
 // call ptr fixed with ptr fixed
 func
-testpfpf()
-{
+testpfpf() {
        var a [20]int;
 
        setpf(&a);
@@ -93,8 +86,7 @@ testpfpf()
 
 // call ptr dynamic with ptr fixed from new
 func
-testpdpf1()
-{
+testpdpf1() {
        a := new([40]int);
        setpd(a);
        res(sumpd(a), 0, 40);
@@ -105,8 +97,7 @@ testpdpf1()
 
 // call ptr dynamic with ptr fixed from var
 func
-testpdpf2()
-{
+testpdpf2() {
        var a [80]int;
 
        setpd(&a);
@@ -115,8 +106,7 @@ testpdpf2()
 
 // generate bounds error with ptr dynamic
 func
-testpdfault()
-{
+testpdfault() {
        a := make([]int, 100);
 
        print("good\n");
@@ -130,8 +120,7 @@ testpdfault()
 
 // generate bounds error with ptr fixed
 func
-testfdfault()
-{
+testfdfault() {
        var a [80]int;
 
        print("good\n");
@@ -145,8 +134,7 @@ testfdfault()
 }
 
 func
-main()
-{
+main() {
        testpdpd();
        testpfpf();
        testpdpf1();
index d56d77ade2fa0997888935444b3bcc7397c032f0..98bcbb09f6ef2211f43c624972498b9c3d6f5909 100644 (file)
@@ -12,8 +12,7 @@ import "runtime"
 var    randx   int;
 
 func
-nrand(n int) int
-{
+nrand(n int) int {
        randx += 10007;
        if randx >= 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<n; i++ {
                cval = cval+100;
@@ -60,8 +55,7 @@ mkchan(c,n int) []*Chan
 }
 
 func
-expect(v, v0 int) (newv int)
-{
+expect(v, v0 int) (newv int) {
        if v == v0 {
                if v%100 == 75 {
                        return end;
@@ -71,9 +65,7 @@ expect(v, v0 int) (newv int)
        panic("got ", v, " expected ", v0+1, "\n");
 }
 
-func (c *Chan)
-send() bool
-{
+func (c *Chan) send() bool {
 //     print("send ", c.sv, "\n");
        tots++;
        c.sv = expect(c.sv, c.sv);
@@ -85,8 +77,7 @@ send() bool
 }
 
 func
-send(c *Chan)
-{
+send(c *Chan) {
        nproc++;        // total goroutines running
        for {
                for r:=nrand(10); r>=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");
index 2905e08c548af8ae1b805ef1f802694ebc336ad5..0008e314b6905f1541ccbeae59294ec83acf37ac 100644 (file)
@@ -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<N; n++ {
                r := n;
                if h[r] != 0 {
@@ -45,8 +43,7 @@ s(c chan int)
 }
 
 func
-main()
-{
+main() {
        c := make(chan int, W);
        for m:=0; m<M; m++ {
                go r(c, m);
index 3132cf993619782ea3ae59e322718ffd7c19f6ba..da0a84a043a9fc500878de919e130bc1b95707d2 100644 (file)
@@ -14,8 +14,7 @@ type  SC      struct{ a,b,c []int };
 type   SM      struct{ a,b,c M };
 
 func
-main()
-{
+main() {
        test("s.a", s.a);
        test("s.b", s.b);
        test("s.c", s.c);
@@ -79,8 +78,7 @@ main()
 var    ref     = 0;
 
 func
-test(xs string, x int)
-{
+test(xs string, x int) {
 
        if ref >= 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,
 
index 0b2e059748fad23478554d732d024ff2d82dc3bc..4143dc58178880ffc094a5ec924b9efd48d57900 100644 (file)
@@ -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<Count; i++ {
@@ -80,8 +77,7 @@ i64run()
 }
 
 func
-u64rand() uint64
-{
+u64rand() uint64 {
        a := uint64(rand.Uint32());
        a = (a<<32) | uint64(rand.Uint32());
        a >>= 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<Count; i++ {
@@ -126,8 +120,7 @@ u64run()
 }
 
 func
-i32rand() int32
-{
+i32rand() int32 {
        for {
                a := int32(rand.Uint32());
                a >>= 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<Count; i++ {
@@ -193,16 +184,14 @@ i32run()
 }
 
 func
-u32rand() uint32
-{
+u32rand() uint32 {
        a := uint32(rand.Uint32());
        a >>= 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<Count; i++ {
@@ -238,8 +226,7 @@ u32run()
 }
 
 func
-i16rand() int16
-{
+i16rand() int16 {
        for {
                a := int16(rand.Uint32());
                a >>= 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<Count; i++ {
@@ -306,16 +291,14 @@ i16run()
 }
 
 func
-u16rand() uint16
-{
+u16rand() uint16 {
        a := uint16(rand.Uint32());
        a >>= 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<Count; i++ {
@@ -351,8 +333,7 @@ u16run()
 }
 
 func
-i8rand() int8
-{
+i8rand() int8 {
        for {
                a := int8(rand.Uint32());
                a >>= 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<Count; i++ {
@@ -415,16 +394,14 @@ i8run()
 }
 
 func
-u8rand() uint8
-{
+u8rand() uint8 {
        a := uint8(rand.Uint32());
        a >>= 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<Count; i++ {
@@ -459,8 +435,7 @@ u8run()
 }
 
 func
-main()
-{
+main() {
        xtest();
        i64run();
        u64run();
@@ -473,6 +448,5 @@ main()
 }
 
 func
-xtest()
-{
+xtest() {
 }
index d0096288c0247e1e685f7bde86838b3ef30bdd89..73c26927b57a6803f43895d4f3590188782ddb80 100644 (file)
@@ -26,8 +26,7 @@ const
 )
 
 func
-main()
-{
+main() {
        /* ideals */
        if n1/d1 != q1 || n1%d1 != r1 {
                panicln("ideal-1", n1, d1, n1/d1, n1%d1);
index 5978f7747fdd02a74de065e7d9cbe2a56704db67..893485bfa282fcb67e62e2c81513101155735e3e 100644 (file)
@@ -8,8 +8,7 @@ package main
 
 
 type
-I      interface
-{
+I      interface {
        test1() int;
        test2() int;
        test3() int;
@@ -24,20 +23,15 @@ I   interface
  ******/
 
 type
-SubpSubp       struct
-{
+SubpSubp       struct {
        a7      int;
        a       int;
 }
-func (p *SubpSubp)
-test7() int
-{
+func (p *SubpSubp) test7() int {
        if p.a != p.a7 { panicln("SubpSubp", p, p.a7) }
        return p.a
 }
-func (p *SubpSubp)
-testx()
-{
+func (p *SubpSubp) testx() {
        println("SubpSubp", p, p.a7);
 }
 
@@ -46,21 +40,16 @@ testx()
  ******/
 
 type
-SubpSub        struct
-{
+SubpSub        struct {
        a6      int;
                SubpSubp;
        a       int;
 }
-func (p *SubpSub)
-test6() int
-{
+func (p *SubpSub) test6() int {
        if p.a != p.a6 { panicln("SubpSub", p, p.a6) }
        return p.a
 }
-func (p *SubpSub)
-testx()
-{
+func (p *SubpSub) testx() {
        println("SubpSub", p, p.a6);
 }
 
@@ -69,14 +58,11 @@ testx()
  ******/
 
 type
-SubSubp        struct
-{
+SubSubp        struct {
        a5      int;
        a       int;
 }
-func (p *SubSubp)
-test5() int
-{
+func (p *SubSubp) test5() int {
        if p.a != p.a5 { panicln("SubpSub", p, p.a5) }
        return p.a
 }
@@ -86,14 +72,11 @@ test5() int
  ******/
 
 type
-SubSub struct
-{
+SubSub struct {
        a4      int;
        a       int;
 }
-func (p *SubSub)
-test4() int
-{
+func (p *SubSub) test4() int {
        if p.a != p.a4 { panicln("SubpSub", p, p.a4) }
        return p.a
 }
@@ -103,16 +86,13 @@ test4() int
  ******/
 
 type
-Subp   struct
-{
+Subp   struct {
        a3      int;
                *SubpSubp;
                SubpSub;
        a       int;
 }
-func (p *Subp)
-test3() int
-{
+func (p *Subp) test3() int {
        if p.a != p.a3 { panicln("SubpSub", p, p.a3) }
        return p.a
 }
@@ -129,9 +109,7 @@ Sub struct
                SubSub;
        a       int;
 }
-func (p *Sub)
-test2() int
-{
+func (p *Sub) test2() int {
        if p.a != p.a2 { panicln("SubpSub", p, p.a2) }
        return p.a
 }
@@ -141,16 +119,13 @@ test2() int
  ******/
 
 type
-S      struct
-{
+S      struct {
        a1      int;
                Sub;
                *Subp;
        a       int;
 }
-func (p *S)
-test1() int
-{
+func (p *S) test1() int {
        if p.a != p.a1 { panicln("SubpSub", p, p.a1) }
        return p.a
 }
@@ -160,8 +135,7 @@ test1() int
  ******/
 
 func
-main()
-{
+main() {
        var i I;
        var s *S;
 
index 74434b26784f3d38df1c3e4358f3a8fa4809fc89..176ecd74930911736aa7c27361748125c41090c6 100644 (file)
@@ -8,8 +8,7 @@
 package main
 
 func
-main()
-{
+main() {
        var t,i int;
 
        for i=0; i<100; i=i+1 {
index c6b982fe14d56dd9c0f6766703c426fc8eb17367..5199c4174a7d1d585cf0b59eda7cbbb10d452467 100644 (file)
@@ -11,8 +11,7 @@ type  mystring        string;
 type   I0              interface {};
 
 func
-f()
-{
+f() {
        var ia, ib I0;
        var i myint;
        var s mystring;
@@ -52,8 +51,7 @@ f()
 }
 
 func
-main()
-{
+main() {
        var ia [20]I0;
        var b bool;
        var s string;
index c508c73c302a1f8682a76b99e7b7f1488cc20077..94bc7eaada67d1dbc579e9304674348b6aa5e4cf 100644 (file)
@@ -6,37 +6,29 @@
 
 package main
 
-type S struct
-{
+type S struct {
        a,b     int;
 }
 
-type I1 interface
-{
+type I1 interface {
        f       ()int;
 }
 
-type I2 interface
-{
+type I2 interface {
        g() int;
        f() int;
 }
 
-func
-(this *S) f()int
-{
+func (this *S) f()int {
        return this.a;
 }
 
-func
-(this *S) g()int
-{
+func (this *S) g()int {
        return this.b;
 }
 
 func
-main()
-{
+main() {
        var i1 I1;
        var i2 I2;
        var g *S;
index 1c3d65000668f0ed5ad571065d5b819bd9da7fd2..c2aaaa870517601a7e24d9f785a18daed56a4918 100644 (file)
@@ -6,58 +6,47 @@
 
 package main
 
-type   Iputs   interface
-{
+type   Iputs   interface {
        puts    (s string);
 }
 
 // ---------
 
-type   Print   struct
-{
+type   Print   struct {
        whoami  int;
        put     Iputs;
 }
 
-func (p *Print)
-dop()
-{
+func (p *Print) dop() {
        print(" print ", p.whoami);
        p.put.puts("abc");
 }
 
 // ---------
 
-type   Bio     struct
-{
+type   Bio     struct {
        whoami  int;
        put     Iputs;
 }
 
-func (b *Bio)
-puts(s string)
-{
+func (b *Bio) puts(s string) {
        print(" bio ", b.whoami);
        b.put.puts(s);
 }
 
 // ---------
 
-type   File    struct
-{
+type   File    struct {
        whoami  int;
        put     Iputs;
 }
 
-func (f *File)
-puts(s string)
-{
+func (f *File) puts(s string) {
        print(" file ", f.whoami, " -- ", s);
 }
 
 func
-main()
-{
+main() {
        p := new(Print);
        b := new(Bio);
        f := new(File);
index 17294ef865c11584e14238c7a4e7aee44d1ce699..770f33e39f735f6678ebaac6d636cef9adbbaf29 100644 (file)
@@ -8,8 +8,7 @@
 package main
 
 func
-main()
-{
+main() {
        i := 0;
        if false {
                goto gogoloop;
index 85b4b0a6a3d334771e965048dc8eab823f0a515b..bac2bc17cce2fce3eb0e76f658912c1d722de22d 100644 (file)
@@ -8,8 +8,7 @@
 package main
 
 func
-main()
-{
+main() {
        x := func(a int)int {
                x := func(a int)int {
                        x := func(a int)int {
index 78c9617a8fe541a4cd3cf23ac4398cceca84c008..ae0bc0c58ab6d6567040216c516f4d762d0802f8 100644 (file)
@@ -7,8 +7,7 @@
 package main
 
 func
-main()
-{
+main() {
        var x,y int;
 
        x,y = simple(10,20,30);
@@ -16,7 +15,6 @@ main()
 }
 
 func
-simple(ia,ib,ic int) (oa,ob int)
-{
+simple(ia,ib,ic int) (oa,ob int) {
        return ia+5, ib+ic;
 }
index 2419a4cf5e39f15675229001ea2792bd05e73f9e..fa53d0b2569ae05d6bbb499a912862eecbe05b5a 100644 (file)
@@ -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<Count; i++ {
@@ -80,8 +77,7 @@ i64run()
 }
 
 func
-u64rand() uint64
-{
+u64rand() uint64 {
        a := uint64(rand.Uint32());
        a = (a<<32) | uint64(rand.Uint32());
        a >>= 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<Count; i++ {
@@ -126,8 +120,7 @@ u64run()
 }
 
 func
-i32rand() int32
-{
+i32rand() int32 {
        for {
                a := int32(rand.Uint32());
                a >>= 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<Count; i++ {
@@ -193,16 +184,14 @@ i32run()
 }
 
 func
-u32rand() uint32
-{
+u32rand() uint32 {
        a := uint32(rand.Uint32());
        a >>= 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<Count; i++ {
@@ -238,8 +226,7 @@ u32run()
 }
 
 func
-i16rand() int16
-{
+i16rand() int16 {
        for {
                a := int16(rand.Uint32());
                a >>= 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<Count; i++ {
@@ -306,16 +291,14 @@ i16run()
 }
 
 func
-u16rand() uint16
-{
+u16rand() uint16 {
        a := uint16(rand.Uint32());
        a >>= 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<Count; i++ {
@@ -351,8 +333,7 @@ u16run()
 }
 
 func
-i8rand() int8
-{
+i8rand() int8 {
        for {
                a := int8(rand.Uint32());
                a >>= 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<Count; i++ {
@@ -416,16 +395,14 @@ i8run()
 }
 
 func
-u8rand() uint8
-{
+u8rand() uint8 {
        a := uint8(rand.Uint32());
        a >>= 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<Count; i++ {
@@ -459,8 +435,7 @@ u8run()
 }
 
 func
-main()
-{
+main() {
        xtest();
        i64run();
        u64run();
@@ -473,6 +448,5 @@ main()
 }
 
 func
-xtest()
-{
+xtest() {
 }
index 111ac61bb9f230824dd87ba52afebf956226b579..6739ba33ae65097da35b688271371892ae428869 100644 (file)
@@ -7,21 +7,17 @@
 
 package main
 
-type C struct
-{
+type C struct {
        a       int;
        x       func(p *C)int;
 }
 
-func
-(this *C) f()int
-{
+func (this *C) f()int {
        return this.a;
 }
 
 func
-main()
-{
+main() {
        var v int;
        var c *C;
 
@@ -39,9 +35,7 @@ main()
        if v != 6 { panic(v); }
 }
 
-func
-g(p *C)int
-{
+func g(p *C)int {
        var v int;
 
        v = p.a;
index 0e3452f0aa03d86bf5205548920fb63e7e099667..e2ddde629285f14e23a9e100723e7a145f7cb058 100644 (file)
@@ -12,8 +12,7 @@ var   g1      x2;
 var    g2      struct { a,b,c int; d x2; };
 
 func
-main()
-{
+main() {
        var x int;
        var s1 *x2;
        var s2 *struct { a,b,c int; d x2; };
index 55e168920ba01a60cf168762e3c384c9f03575b4..8da830247c7b6d525d3ec32091e9b2f326144ecd 100644 (file)
@@ -13,14 +13,12 @@ var p       []byte;
 var    m       map[int]byte;
 
 func
-f(k int) byte
-{
+f(k int) byte {
        return byte(k*10007 % size);
 }
 
 func
-init()
-{
+init() {
        p = make([]byte, size);
        m = make(map[int]byte);
        for k:=0; k<size; k++ {
@@ -32,8 +30,7 @@ init()
 }
 
 func
-main()
-{
+main() {
        var i int;
 
        /*
index a75878b1f5e3e777b51a79316a8270b224b9ecc4..03350662a2e4120b15519bf4c76c8ec4f62eb9a0 100644 (file)
@@ -6,40 +6,31 @@
 
 package main
 
-type Item interface
-{
+type Item interface {
        Print();
 }
 
-type ListItem struct
-{
+type ListItem struct {
        item    Item;
        next    *ListItem;
 }
 
-type List struct
-{
+type List struct {
        head    *ListItem;
 }
 
-func (list *List)
-Init()
-{
+func (list *List) Init() {
        list.head = nil;
 }
 
-func (list *List)
-Insert(i Item)
-{
+func (list *List) Insert(i Item) {
        item := new(ListItem);
        item.item = i;
        item.next = list.head;
        list.head = item;
 }
 
-func (list *List)
-Print()
-{
+func (list *List) Print() {
        i := list.head;
        for i != nil {
                i.item.Print();
@@ -48,27 +39,21 @@ Print()
 }
 
 // Something to put in a list
-type Integer struct
-{
+type Integer struct {
        val             int;
 }
 
-func (this *Integer)
-Init(i int) *Integer
-{
+func (this *Integer) Init(i int) *Integer {
        this.val = i;
        return this;
 }
 
-func (this *Integer)
-Print()
-{
+func (this *Integer) Print() {
        print(this.val);
 }
 
 func
-main()
-{
+main() {
        list := new(List);
        list.Init();
        for i := 0; i < 10; i = i + 1 {
index 518ba29807dbcf415d1e92821e7f83f4564a470b..af63e4d9f6d3438fe894ea25fb0ffc9a50ffd1b3 100644 (file)
@@ -72,8 +72,7 @@ var tokenlen int = 0;
 
 const EOF int = -1;
 
-func main()
-{
+func main() {
        var list *Slist;
 
        OpenFile();
@@ -88,8 +87,7 @@ func main()
        }
 }
 
-func (slist *Slist) PrintOne(doparen bool)
-{
+func (slist *Slist) PrintOne(doparen bool) {
        if slist == nil {
                return;
        }
@@ -114,14 +112,12 @@ func (slist *Slist) PrintOne(doparen bool)
        }
 }
 
-func (slist *Slist) Print()
-{
+func (slist *Slist) Print() {
        slist.PrintOne(true);
        print("\n");
 }
 
-func Get() int
-{
+func Get() int {
        var c int;
 
        if peekc >= 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
index 379f53fa42256621b89af27ca255ddcdd0d52e8c..157a07aec54bf5f4e179e8002dc1382c934b1822 100644 (file)
@@ -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
         */
index 90331e5e3d54463e366e5ac541881cc7c00d7c2c..1b6f245eea20a8551aaf3268937fae011ae87e07 100644 (file)
@@ -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 {
index aad111dd55607aa18fa1c66df9350e295c82f463..dbd9c8d8bcfe6e1e1914da51c4af93854d25b940 100644 (file)
@@ -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;
index 9785138aeb2c01842ba0e9bd88958f717bdf60e2..cb443e3a19ba7785ba090debf3d5da37737346e0 100644 (file)
@@ -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);
index ee2c1a9a0914c2a72a4fcd5ef86bc4ef76022a0c..ba9ce6f7bce012a540b5421bea887be8bf5e8f06 100644 (file)
@@ -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;
index 98393a457050b6926ad523ad906a2df6f40df611..6077f7eb025aa32b83f140b35128604dd04c7ff9 100644 (file)
@@ -8,7 +8,6 @@
 package main
 
 func
-main()
-{
+main() {
        print("hello world\n");
 }
index e5f39e35438f5cb3c804c747ea8f45fc2300a864..ab5dd356b3efbbd11417f970a230440be985d77d 100644 (file)
@@ -7,8 +7,7 @@
 package main
 
 func
-main()
-{
+main() {
        a := 3;
        for i:=0; i<10; i=i+1 {
                switch(i) {
index 70946bf70ef1dec82ed461ef4f2cf7b31332d8bd..fd060b0e2e909fe474e66d7938f570842f44ebc5 100644 (file)
@@ -10,8 +10,7 @@ package main
 var    x,y     int;
 
 func
-main()
-{
+main() {
 
        x = 15;
        y = 20;
index a8f5ad928dc44e7ed92a9cdb3355eef61b453ae2..f24c7fc9c23ad0e3c87bf0ec6bbacf3966be3959 100644 (file)
@@ -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<len(bx); i++ {
                bx[i] = byte(i+20);
        }
index 9c37dedbe41550395d767e224b9b003d362280e4..7b38082bb6faff71d36e47794176d839afb42e56 100644 (file)
@@ -14,8 +14,7 @@ var   lb,hb   int
 var    t       int
 
 func
-main()
-{
+main() {
 
        // width 1 (byte)
        lb = 0; hb = 10;
@@ -77,8 +76,7 @@ main()
 }
 
 func
-tstb()
-{
+tstb() {
        t++;
        if len(by) != hb-lb {
                panicln("t=", t, "lb=", lb, "hb=", hb,
@@ -99,8 +97,7 @@ tstb()
 }
 
 func
-tstf()
-{
+tstf() {
        t++;
        if len(fy) != hb-lb {
                panicln("t=", t, "lb=", lb, "hb=", hb,
@@ -121,8 +118,7 @@ tstf()
 }
 
 func
-init()
-{
+init() {
        bx = make([]byte, 10);
        for i:=0; i<len(bx); i++ {
                bx[i] = byte(i+20);
index 03e81a05d57422da0d6bdc6b02ab9e61be63ef64..14617de9c76a89d24ea12734b534eb7709ed3301 100644 (file)
@@ -8,8 +8,7 @@
 package main
 
 func
-main()
-{
+main() {
        var c string;
 
        a := `abc`;
index 4a29217952e68df693bcfc17fc89802d38579630..dfaaf12131cc732565cb72eb3af8224f725c41b7 100644 (file)
@@ -12,8 +12,7 @@ var   g1      x2;
 var    g2      struct { a,b,c int; d x2; };
 
 func
-main()
-{
+main() {
        var x int;
        var s1 *x2;
        var s2 *struct { a,b,c int; d x2; };