]> Cypherpunks.ru repositories - gostls13.git/commitdiff
single argument panic
authorRuss Cox <rsc@golang.org>
Tue, 30 Mar 2010 17:34:57 +0000 (10:34 -0700)
committerRuss Cox <rsc@golang.org>
Tue, 30 Mar 2010 17:34:57 +0000 (10:34 -0700)
note that sortmain.go has been run through hg gofmt;
only the formatting of the day initializers changed.
i'm happy to revert that formatting if you'd prefer.

stop on error in doc/progs/run

R=r
CC=golang-dev
https://golang.org/cl/850041

60 files changed:
doc/progs/run
doc/progs/sortmain.go
src/cmd/cgo/ast.go
src/cmd/godoc/index.go
src/cmd/goinstall/download.go
src/pkg/bufio/bufio.go
src/pkg/bytes/bytes_test.go
src/pkg/crypto/block/cmac.go
src/pkg/exp/eval/eval_test.go
src/pkg/exp/eval/expr.go
src/pkg/exp/eval/expr1.go
src/pkg/exp/eval/gen.go
src/pkg/exp/eval/type.go
src/pkg/exp/ogle/rvalue.go
src/pkg/exp/ogle/vars.go
src/pkg/go/ast/walk.go
src/pkg/go/parser/parser.go
src/pkg/go/printer/printer.go
src/pkg/gob/decode.go
src/pkg/http/lex.go
src/pkg/net/fd.go
src/pkg/net/unixsock.go
src/pkg/reflect/value.go
src/pkg/strconv/ftoa_test.go
src/pkg/template/template.go
src/pkg/time/time.go
src/pkg/websocket/server.go
test/235.go
test/chan/doubleselect.go
test/chan/nonblock.go
test/chan/sieve1.go
test/chan/sieve2.go
test/cmp1.go
test/fixedbugs/bug082.go
test/fixedbugs/bug084.go
test/fixedbugs/bug097.go
test/fixedbugs/bug110.go
test/fixedbugs/bug117.go
test/fixedbugs/bug168.go
test/fixedbugs/bug194.go
test/fixedbugs/bug221.go
test/fixedbugs/bug227.go
test/fixedbugs/bug234.go
test/fixedbugs/bug244.go
test/fixedbugs/bug253.go
test/fixedbugs/bug262.go
test/func5.go
test/golden.out
test/interface/convert.go
test/interface/receiver.go
test/ken/array.go
test/ken/chan.go
test/ken/string.go
test/mallocfin.go
test/mallocrep.go
test/peano.go
test/simassign.go
test/typeswitch1.go
test/varinit.go
test/vectors.go

index c0e4b53e0c022ef26fb999a4af06ab8a611ee94c..07bc141dffdac2dcdc469aaf5204c3172c3ff058 100755 (executable)
@@ -3,6 +3,8 @@
 # Use of this source code is governed by a BSD-style
 # license that can be found in the LICENSE file.
 
+set -e
+
 GOBIN="${GOBIN:-$HOME/bin}"
 
 . "$GOROOT"/src/Make.$GOARCH
index df2abc0587b50a1a2ea7d5dcf9ab322674e158b6..6bd504a5b818ea7992549c3ec2993604db112366 100644 (file)
@@ -14,7 +14,7 @@ func ints() {
        a := sort.IntArray(data)
        sort.Sort(a)
        if !sort.IsSorted(a) {
-               panic()
+               panic("fail")
        }
 }
 
@@ -23,7 +23,7 @@ func strings() {
        a := sort.StringArray(data)
        sort.Sort(a)
        if !sort.IsSorted(a) {
-               panic()
+               panic("fail")
        }
 }
 
@@ -42,18 +42,18 @@ func (p *dayArray) Less(i, j int) bool  { return p.data[i].num < p.data[j].num }
 func (p *dayArray) Swap(i, j int)       { p.data[i], p.data[j] = p.data[j], p.data[i] }
 
 func days() {
-       Sunday :=    day{ 0, "SUN", "Sunday" }
-       Monday :=    day{ 1, "MON", "Monday" }
-       Tuesday :=   day{ 2, "TUE", "Tuesday" }
-       Wednesday := day{ 3, "WED", "Wednesday" }
-       Thursday :=  day{ 4, "THU", "Thursday" }
-       Friday :=    day{ 5, "FRI", "Friday" }
-       Saturday :=  day{ 6, "SAT", "Saturday" }
+       Sunday :=    day{0, "SUN", "Sunday"}
+       Monday :=    day{1, "MON", "Monday"}
+       Tuesday :=   day{2, "TUE", "Tuesday"}
+       Wednesday := day{3, "WED", "Wednesday"}
+       Thursday :=  day{4, "THU", "Thursday"}
+       Friday :=    day{5, "FRI", "Friday"}
+       Saturday :=  day{6, "SAT", "Saturday"}
        data := []*day{&Tuesday, &Thursday, &Wednesday, &Sunday, &Monday, &Friday, &Saturday}
        a := dayArray{data}
        sort.Sort(&a)
        if !sort.IsSorted(&a) {
-               panic()
+               panic("fail")
        }
        for _, d := range data {
                fmt.Printf("%s ", d.longName)
index 1bde1b77bbedb495a1ebc2302baeffce50e2cdda..0dfe9217a88f8476f65d0642f5003a1ad8a835a6 100644 (file)
@@ -157,7 +157,7 @@ func walk(x interface{}, p *Prog, context string) {
        // everything else just recurs
        default:
                error(noPos, "unexpected type %T in walk", x)
-               panic()
+               panic("unexpected type")
 
        case nil:
 
index d6fdba15dea4de5f9cfb8624c32db83e35112ce0..aa108d0db5ffdeade6eb23636270c1d7dc8240e7 100644 (file)
@@ -119,7 +119,7 @@ func init() {
        // sanity check: if nKinds is too large, the SpotInfo
        // accessor functions may need to be updated
        if nKinds > 8 {
-               panic()
+               panic("nKinds > 8")
        }
 }
 
index 13a2f65ab855ecdd63a4bebbb14b54060cc9fb97..df1cde6e9cb7615abcabc5038cfdb2a3bcd95e21 100644 (file)
@@ -55,7 +55,7 @@ func download(pkg string) (string, os.Error) {
                        v = &svn
                default:
                        // regexp only allows hg, svn to get through
-                       panic("missing case in download: ", pkg)
+                       panic("missing case in download: " + pkg)
                }
                if err := vcsCheckout(v, root+m[1], "http://"+m[1], m[1]); err != nil {
                        return "", err
index 9b52a363a327f56957928f07e0b50a4fa3df2e3f..1af9545dc5351548ff6a350d96f50cce3633798d 100644 (file)
@@ -75,7 +75,7 @@ func NewReader(rd io.Reader) *Reader {
        b, err := NewReaderSize(rd, defaultBufSize)
        if err != nil {
                // cannot happen - defaultBufSize is a valid size
-               panic("bufio: NewReader: ", err.String())
+               panic(err)
        }
        return b
 }
@@ -353,7 +353,7 @@ func NewWriter(wr io.Writer) *Writer {
        b, err := NewWriterSize(wr, defaultBufSize)
        if err != nil {
                // cannot happen - defaultBufSize is valid size
-               panic("bufio: NewWriter: ", err.String())
+               panic(err)
        }
        return b
 }
index efec1eb8b9be53425ebe20a2dc6488168f9c1397..df55ce3ccda17d4b7a10c711c7aa114a654ae6fb 100644 (file)
@@ -188,7 +188,8 @@ func bmIndex(b *testing.B, index func([]byte, byte) int, n int) {
        for i := 0; i < b.N; i++ {
                j := index(buf, 'x')
                if j != n-1 {
-                       panic("bad index", j)
+                       println("bad index", j)
+                       panic("bad index")
                }
        }
        buf[n-1] = '0'
index a2f80fe4b35a0b70bf72be695921d63f61dcc3e5..6082299ab5e4a95b1b8b57c6255e64bf298438bd 100644 (file)
@@ -37,7 +37,7 @@ func NewCMAC(c Cipher) hash.Hash {
        case 128 / 8:
                r = r128
        default:
-               panic("crypto/block: NewCMAC: invalid cipher block size", n)
+               panic("crypto/block: NewCMAC: invalid cipher block size")
        }
 
        d := new(cmac)
index 911c7e4a52ec3d23cb304daab55c4eae0950bbf4..837c4fabdcf4f7677a6d9a492d9af7748a07d9ba 100644 (file)
@@ -196,7 +196,7 @@ func toValue(val interface{}) Value {
                return &funcV{val}
        }
        log.Crashf("toValue(%T) not implemented", val)
-       panic()
+       panic("unreachable")
 }
 
 /*
index 5547aee3190c476320df5d416c4e9d58317bb286..e630578bdd01e0c827f51b53401f2377e4aafd86 100644 (file)
@@ -642,7 +642,7 @@ func (a *exprCompiler) compile(x ast.Expr, callCtx bool) *expr {
                return ei.compileUnaryExpr(x.Op, v)
        }
        log.Crashf("unexpected ast node type %T", x)
-       panic()
+       panic("unreachable")
 
 typeexpr:
        if !callCtx {
@@ -704,7 +704,7 @@ func (a *exprInfo) compileIdent(b *block, constant bool, callCtx bool, name stri
                return nil
        }
        log.Crashf("name %s has unknown type %T", name, def)
-       panic()
+       panic("unreachable")
 }
 
 func (a *exprInfo) compileVariable(level int, v *Variable) *expr {
@@ -1424,7 +1424,7 @@ func (a *exprInfo) compileBuiltinCallExpr(b *block, ft *FuncType, as []*expr) *e
        }
 
        log.Crashf("unexpected built-in function '%s'", ft.builtin)
-       panic()
+       panic("unreachable")
 }
 
 func (a *exprInfo) compileStarExpr(v *expr) *expr {
index 28da8eea1b6ef12a1da8999f7bef4665a1f3cf43..0e83053f46a314664563f3980fcd59a7e95fa4ef 100644 (file)
@@ -12,9 +12,15 @@ import (
  * "As" functions.  These retrieve evaluator functions from an
  * expr, panicking if the requested evaluator has the wrong type.
  */
-func (a *expr) asBool() func(*Thread) bool   { return a.eval.(func(*Thread) bool) }
-func (a *expr) asUint() func(*Thread) uint64 { return a.eval.(func(*Thread) uint64) }
-func (a *expr) asInt() func(*Thread) int64   { return a.eval.(func(*Thread) int64) }
+func (a *expr) asBool() func(*Thread) bool {
+       return a.eval.(func(*Thread) bool)
+}
+func (a *expr) asUint() func(*Thread) uint64 {
+       return a.eval.(func(*Thread) uint64)
+}
+func (a *expr) asInt() func(*Thread) int64 {
+       return a.eval.(func(*Thread) int64)
+}
 func (a *expr) asIdealInt() func() *bignum.Integer {
        return a.eval.(func() *bignum.Integer)
 }
@@ -33,10 +39,18 @@ func (a *expr) asArray() func(*Thread) ArrayValue {
 func (a *expr) asStruct() func(*Thread) StructValue {
        return a.eval.(func(*Thread) StructValue)
 }
-func (a *expr) asPtr() func(*Thread) Value   { return a.eval.(func(*Thread) Value) }
-func (a *expr) asFunc() func(*Thread) Func   { return a.eval.(func(*Thread) Func) }
-func (a *expr) asSlice() func(*Thread) Slice { return a.eval.(func(*Thread) Slice) }
-func (a *expr) asMap() func(*Thread) Map     { return a.eval.(func(*Thread) Map) }
+func (a *expr) asPtr() func(*Thread) Value {
+       return a.eval.(func(*Thread) Value)
+}
+func (a *expr) asFunc() func(*Thread) Func {
+       return a.eval.(func(*Thread) Func)
+}
+func (a *expr) asSlice() func(*Thread) Slice {
+       return a.eval.(func(*Thread) Slice)
+}
+func (a *expr) asMap() func(*Thread) Map {
+       return a.eval.(func(*Thread) Map)
+}
 func (a *expr) asMulti() func(*Thread) []Value {
        return a.eval.(func(*Thread) []Value)
 }
@@ -72,7 +86,7 @@ func (a *expr) asInterface() func(*Thread) interface{} {
        default:
                log.Crashf("unexpected expression node type %T at %v", a.eval, a.pos)
        }
-       panic()
+       panic("fail")
 }
 
 /*
@@ -210,26 +224,17 @@ func (a *expr) genUnaryOpNeg(v *expr) {
        switch a.t.lit().(type) {
        case *uintType:
                vf := v.asUint()
-               a.eval = func(t *Thread) uint64 {
-                       v := vf(t)
-                       return -v
-               }
+               a.eval = func(t *Thread) uint64 { v := vf(t); return -v }
        case *intType:
                vf := v.asInt()
-               a.eval = func(t *Thread) int64 {
-                       v := vf(t)
-                       return -v
-               }
+               a.eval = func(t *Thread) int64 { v := vf(t); return -v }
        case *idealIntType:
                v := v.asIdealInt()()
                val := v.Neg()
                a.eval = func() *bignum.Integer { return val }
        case *floatType:
                vf := v.asFloat()
-               a.eval = func(t *Thread) float64 {
-                       v := vf(t)
-                       return -v
-               }
+               a.eval = func(t *Thread) float64 { v := vf(t); return -v }
        case *idealFloatType:
                v := v.asIdealFloat()()
                val := v.Neg()
@@ -243,10 +248,7 @@ func (a *expr) genUnaryOpNot(v *expr) {
        switch a.t.lit().(type) {
        case *boolType:
                vf := v.asBool()
-               a.eval = func(t *Thread) bool {
-                       v := vf(t)
-                       return !v
-               }
+               a.eval = func(t *Thread) bool { v := vf(t); return !v }
        default:
                log.Crashf("unexpected type %v at %v", a.t, a.pos)
        }
@@ -256,16 +258,10 @@ func (a *expr) genUnaryOpXor(v *expr) {
        switch a.t.lit().(type) {
        case *uintType:
                vf := v.asUint()
-               a.eval = func(t *Thread) uint64 {
-                       v := vf(t)
-                       return ^v
-               }
+               a.eval = func(t *Thread) uint64 { v := vf(t); return ^v }
        case *intType:
                vf := v.asInt()
-               a.eval = func(t *Thread) int64 {
-                       v := vf(t)
-                       return ^v
-               }
+               a.eval = func(t *Thread) int64 { v := vf(t); return ^v }
        case *idealIntType:
                v := v.asIdealInt()()
                val := v.Neg().Sub(bignum.Int(1))
@@ -1905,5 +1901,5 @@ func genAssign(lt Type, r *expr) func(lv Value, t *Thread) {
        default:
                log.Crashf("unexpected left operand type %v at %v", lt, r.pos)
        }
-       panic()
+       panic("fail")
 }
index ea421ff9c419ad233f8a593722c439b1b471fa51..969d65586239d75208ff03a0a1403a87538d8cb7 100644 (file)
@@ -103,12 +103,12 @@ var binOps = []Op{
        Op{Name: "Sub", Expr: "l - r", ConstExpr: "l.Sub(r)", Types: numbers},
        Op{Name: "Mul", Expr: "l * r", ConstExpr: "l.Mul(r)", Types: numbers},
        Op{Name: "Quo",
-               Body:      "if r == 0 { t.Abort(DivByZeroError{}) } ret =  l / r",
+               Body:      "if r == 0 { t.Abort(DivByZeroError{}) }; ret =  l / r",
                ConstExpr: "l.Quo(r)",
                Types:     numbers,
        },
        Op{Name: "Rem",
-               Body:      "if r == 0 { t.Abort(DivByZeroError{}) } ret = l % r",
+               Body:      "if r == 0 { t.Abort(DivByZeroError{}) }; ret = l % r",
                ConstExpr: "l.Rem(r)",
                Types:     integers,
        },
@@ -186,7 +186,7 @@ func (a *expr) asInterface() (func(*Thread) interface{}) {
        default:
                log.Crashf("unexpected expression node type %T at %v", a.eval, a.pos);
        }
-       panic();
+       panic("fail");
 }
 
 /*
@@ -357,7 +357,7 @@ func genAssign(lt Type, r *expr) (func(lv Value, t *Thread)) {
        default:
                log.Crashf("unexpected left operand type %v at %v", lt, r.pos);
        }
-       panic();
+       panic("fail");
 }
 `
 
index 2b2a632cd04b43ec3bb2fb3b1069f19db983aa84..fbb428679e1edd8d2421172995ff798935ff15b0 100644 (file)
@@ -231,7 +231,7 @@ func (t *uintType) Zero() Value {
                res := uint64V(0)
                return &res
        }
-       panic("unexpected uint bit count: ", t.Bits)
+       panic("unexpected uint bit count")
 }
 
 func (t *uintType) minVal() *bignum.Rational { return bignum.Rat(0, 1) }
@@ -304,7 +304,7 @@ func (t *intType) Zero() Value {
                res := intV(0)
                return &res
        }
-       panic("unexpected int bit count: ", t.Bits)
+       panic("unexpected int bit count")
 }
 
 func (t *intType) minVal() *bignum.Rational {
@@ -390,7 +390,7 @@ func (t *floatType) Zero() Value {
                res := floatV(0)
                return &res
        }
-       panic("unexpected float bit count: ", t.Bits)
+       panic("unexpected float bit count")
 }
 
 var maxFloat32Val = bignum.MakeRat(bignum.Int(0xffffff).Shl(127-23), bignum.Nat(1))
@@ -410,7 +410,7 @@ func (t *floatType) minVal() *bignum.Rational {
                return minFloat64Val
        }
        log.Crashf("unexpected floating point bit count: %d", bits)
-       panic()
+       panic("unreachable")
 }
 
 func (t *floatType) maxVal() *bignum.Rational {
@@ -425,7 +425,7 @@ func (t *floatType) maxVal() *bignum.Rational {
                return maxFloat64Val
        }
        log.Crashf("unexpected floating point bit count: %d", bits)
-       panic()
+       panic("unreachable")
 }
 
 /*
index ba915ed5cbb203350f548878ab07eed03bbfe74d..3d630f936644c678c6a030b250e21d41eb294e44 100644 (file)
@@ -232,7 +232,7 @@ func (v remoteFloat) aGet(a aborter) float64 {
        case 8:
                return v.r.p.ToFloat64(bits)
        }
-       panic("Unexpected float size ", v.size)
+       panic("Unexpected float size")
 }
 
 func (v remoteFloat) Set(t *eval.Thread, x float64) {
@@ -247,7 +247,7 @@ func (v remoteFloat) aSet(a aborter, x float64) {
        case 8:
                bits = v.r.p.FromFloat64(x)
        default:
-               panic("Unexpected float size ", v.size)
+               panic("Unexpected float size")
        }
        v.r.Set(a, v.size, bits)
 }
index e6298bc48172dc81c141bcd88c0f947fb9b8e7ba..eed60acec5f97f44fa0e3732bbeb46f7fee82cf4 100644 (file)
@@ -63,7 +63,7 @@ func (v remoteFramePtr) Get(t *eval.Thread) eval.Value {
        }
 
        t.Abort(NotOnStack{v.fn, g})
-       panic()
+       panic("fail")
 }
 
 func (v remoteFramePtr) Set(t *eval.Thread, x eval.Value) {
index 2137ddaa4664e60b22a5a1a40d81d9b6a35c188c..6c9837a01d546e243b65a117d7a3a4530db6819e 100644 (file)
@@ -316,7 +316,7 @@ func Walk(v Visitor, node interface{}) {
 
        default:
                fmt.Printf("ast.Walk: unexpected type %T", n)
-               panic()
+               panic("ast.Walk")
        }
 
        v.Visit(nil)
index 2002d3818b44b266647de5365230c68c9303133e..6831a53de2e2d726a1d2292bf718c5d26f923251 100644 (file)
@@ -1738,8 +1738,7 @@ func (p *parser) parseForStmt() ast.Stmt {
                return &ast.ForStmt{pos, s1, p.makeExpr(s2), s3, body}
        }
 
-       panic() // unreachable
-       return nil
+       panic("unreachable")
 }
 
 
index 5a12c6edb5e0e331a8fbd720580ea631577e7836..2316a459bbb213f53ba1b81156048354ec540dee 100644 (file)
@@ -107,7 +107,7 @@ func (p *printer) internalError(msg ...interface{}) {
        if debug {
                fmt.Print(p.pos.String() + ": ")
                fmt.Println(msg)
-               panic()
+               panic("go/printer")
        }
 }
 
@@ -791,7 +791,7 @@ func (p *printer) print(args ...interface{}) {
                        }
                default:
                        fmt.Fprintf(os.Stderr, "print: unsupported argument type %T\n", f)
-                       panic()
+                       panic("go/printer type")
                }
                p.pos = next
 
index 9dea080f8f59af8262f755da9fb8222dbec323eb..3b14841afd1d34d4061d97d133b5da32f428c35b 100644 (file)
@@ -777,7 +777,7 @@ func init() {
        case unsafe.Sizeof(float64(0)):
                op = decFloat64
        default:
-               panic("gob: unknown size of float", unsafe.Sizeof(float(0)))
+               panic("gob: unknown size of float")
        }
        decOpMap[valueKind(float(0))] = op
 
@@ -791,7 +791,7 @@ func init() {
                op = decInt64
                uop = decUint64
        default:
-               panic("gob: unknown size of int/uint", unsafe.Sizeof(int(0)))
+               panic("gob: unknown size of int/uint")
        }
        decOpMap[valueKind(int(0))] = op
        decOpMap[valueKind(uint(0))] = uop
@@ -803,7 +803,7 @@ func init() {
        case unsafe.Sizeof(uint64(0)):
                uop = decUint64
        default:
-               panic("gob: unknown size of uintptr", unsafe.Sizeof(uintptr(0)))
+               panic("gob: unknown size of uintptr")
        }
        decOpMap[valueKind(uintptr(0))] = uop
 }
index d25c4e4038ce5dec29ca69ed16b1daa0dc284088..93b67e701761285817db97f5bf3b154475777dae 100644 (file)
@@ -10,20 +10,16 @@ func isSeparator(c byte) bool {
        switch c {
        case '(', ')', '<', '>', '@', ',', ';', ':', '\\', '"', '/', '[', ']', '?', '=', '{', '}', ' ', '\t':
                return true
-       default:
-               return false
        }
-       panic()
+       return false
 }
 
 func isSpace(c byte) bool {
        switch c {
        case ' ', '\t', '\r', '\n':
                return true
-       default:
-               return false
        }
-       panic()
+       return false
 }
 
 func isCtl(c byte) bool { return (0 <= c && c <= 31) || c == 127 }
index 5619b9ec5838c0df97d4ff3692d88224d8980327..28e85be2a3ddf45620018ca523e4f0dea638274d 100644 (file)
@@ -11,6 +11,7 @@ import (
        "os"
        "sync"
        "syscall"
+       "time"
 )
 
 // Network file descriptor.
@@ -176,12 +177,7 @@ func (s *pollServer) WakeFD(fd *netFD, mode int) {
 }
 
 func (s *pollServer) Now() int64 {
-       sec, nsec, err := os.Time()
-       if err != nil {
-               panic("net: os.Time: ", err.String())
-       }
-       nsec += sec * 1e9
-       return nsec
+       return time.Nanoseconds()
 }
 
 func (s *pollServer) CheckDeadlines() {
index 727b99f7af7acb12d491094a0c63324ee37466a5..daf71c0066d5c35d7b8603d9e360eb69467aa9a6 100644 (file)
@@ -25,7 +25,7 @@ func unixSocket(net string, laddr, raddr *UnixAddr, mode string) (fd *netFD, err
        var la, ra syscall.Sockaddr
        switch mode {
        default:
-               panic("unixSocket", mode)
+               panic("unixSocket mode " + mode)
 
        case "dial":
                if laddr != nil {
index be786e91a32a176429723684428a54a7595c11a6..f21c564d537c3b76e5743022cc66e40e5455051c 100644 (file)
@@ -571,7 +571,7 @@ func (v *ArrayValue) Elem(i int) Value {
        typ := v.typ.(*ArrayType).Elem()
        n := v.Len()
        if i < 0 || i >= n {
-               panic("index", i, "in array len", n)
+               panic("array index out of bounds")
        }
        p := addr(uintptr(v.addr()) + uintptr(i)*typ.Size())
        return newValue(typ, p, v.canSet)
@@ -642,7 +642,7 @@ func (v *SliceValue) Get() uintptr {
 func (v *SliceValue) Slice(beg, end int) *SliceValue {
        cap := v.Cap()
        if beg < 0 || end < beg || end > cap {
-               panic("slice bounds [", beg, ":", end, "] with capacity ", cap)
+               panic("slice index out of bounds")
        }
        typ := v.typ.(*SliceType)
        s := new(SliceHeader)
index 70497bf82a73a3dd54d00e8604207aa56b673d07..3771c40b9197251253d3637dd0af702bd0978372 100644 (file)
@@ -101,7 +101,8 @@ var ftoatests = []ftoaTest{
 
 func TestFtoa(t *testing.T) {
        if FloatSize != 32 {
-               panic("floatsize: ", FloatSize)
+               println("floatsize: ", FloatSize)
+               panic("floatsize")
        }
        for i := 0; i < len(ftoatests); i++ {
                test := &ftoatests[i]
index e2f70c1a530ddbc8f7f9f08754239bb54be90095..54c22ba8df6e8fa5656d65965d56b25208ac8e12 100644 (file)
@@ -983,7 +983,7 @@ func ParseFile(filename string, fmap FormatterMap) (t *Template, err os.Error) {
 func MustParse(s string, fmap FormatterMap) *Template {
        t, err := Parse(s, fmap)
        if err != nil {
-               panic("template parse error: ", err.String())
+               panic("template.MustParse error: " + err.String())
        }
        return t
 }
@@ -993,7 +993,7 @@ func MustParse(s string, fmap FormatterMap) *Template {
 func MustParseFile(filename string, fmap FormatterMap) *Template {
        b, err := ioutil.ReadFile(filename)
        if err != nil {
-               panic("template parse error: ", err.String())
+               panic("template.MustParseFile error: " + err.String())
        }
        return MustParse(string(b), fmap)
 }
index d84807e836e1fbcd104bf06229688f04e0d20997..7b7887485267170c884a5963a588e9cd9c10cb65 100644 (file)
@@ -15,7 +15,7 @@ import (
 func Seconds() int64 {
        sec, _, err := os.Time()
        if err != nil {
-               panic("time: os.Time: ", err.String())
+               panic(err)
        }
        return sec
 }
@@ -25,7 +25,7 @@ func Seconds() int64 {
 func Nanoseconds() int64 {
        sec, nsec, err := os.Time()
        if err != nil {
-               panic("time: os.Time: ", err.String())
+               panic(err)
        }
        return sec*1e9 + nsec
 }
index 78c42990a0e2089476240bc8e9d3f75ff397dd0d..cc1ff938549deda36127ec102dc793c73a0bada5 100644 (file)
@@ -62,7 +62,7 @@ func getKeyNumber(s string) (r uint32) {
 func (f Handler) ServeHTTP(c *http.Conn, req *http.Request) {
        rwc, buf, err := c.Hijack()
        if err != nil {
-               panic("Hijack failed: ", err.String())
+               panic("Hijack failed: " + err.String())
                return
        }
        // The server should abort the WebSocket connection if it finds
@@ -200,7 +200,7 @@ func (f Draft75Handler) ServeHTTP(c *http.Conn, req *http.Request) {
 
        rwc, buf, err := c.Hijack()
        if err != nil {
-               panic("Hijack failed: ", err.String())
+               panic("Hijack failed: " + err.String())
                return
        }
        defer rwc.Close()
index 7507a3ef56f0c4b610f4ad8f4052204f94103a97..03143a60d83fef499ccc34dd798cc7aecdb9e870 100644 (file)
@@ -6,34 +6,34 @@
 
 package main
 
-type T chan uint64;
+type T chan uint64
 
 func M(f uint64) (in, out T) {
-       in = make(T, 100);
-       out = make(T, 100);
+       in = make(T, 100)
+       out = make(T, 100)
        go func(in, out T, f uint64) {
                for {
-                       out <- f * <-in;
+                       out <- f*<-in
                }
-       }(in, out, f);
-       return in, out;
+       }(in, out, f)
+       return in, out
 }
 
 
 func min(xs []uint64) uint64 {
-       m := xs[0];
+       m := xs[0]
        for i := 1; i < len(xs); i++ {
                if xs[i] < m {
-                       m = xs[i];
+                       m = xs[i]
                }
        }
-       return m;
+       return m
 }
 
 
 func main() {
-       F := []uint64{2, 3, 5};
-       var n = len(F);
+       F := []uint64{2, 3, 5}
+       var n = len(F)
        OUT := []uint64{
                2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24, 25, 27, 30, 32, 36,
                40, 45, 48, 50, 54, 60, 64, 72, 75, 80, 81, 90, 96, 100, 108, 120, 125,
@@ -41,27 +41,32 @@ func main() {
                256, 270, 288, 300, 320, 324, 360, 375, 384, 400, 405, 432, 450, 480,
                486, 500, 512, 540, 576, 600, 625, 640, 648, 675, 720, 729, 750, 768,
                800, 810, 864, 900, 960, 972, 1000, 1024, 1080, 1125, 1152, 1200, 1215,
-               1250, 1280, 1296, 1350, 1440, 1458, 1500, 1536, 1600 };
+               1250, 1280, 1296, 1350, 1440, 1458, 1500, 1536, 1600}
 
-       x := uint64(1);
-       ins := make([]T, n);
-       outs := make([]T, n);
-       xs := make([]uint64, n);
+       x := uint64(1)
+       ins := make([]T, n)
+       outs := make([]T, n)
+       xs := make([]uint64, n)
        for i := 0; i < n; i++ {
-               ins[i], outs[i] = M(F[i]);
-               xs[i] = x;
+               ins[i], outs[i] = M(F[i])
+               xs[i] = x
        }
 
        for i := 0; i < len(OUT); i++ {
                for i := 0; i < n; i++ {
-                       ins[i] <- x;
+                       ins[i] <- x
                }
 
                for i := 0; i < n; i++ {
-                       if xs[i] == x { xs[i] = <- outs[i]; }
+                       if xs[i] == x {
+                               xs[i] = <-outs[i]
+                       }
                }
 
-               x = min(xs);
-               if x != OUT[i] { panic("bad: ", x, " should be ", OUT[i]); }
+               x = min(xs)
+               if x != OUT[i] {
+                       println("bad: ", x, " should be ", OUT[i])
+                       panic("235")
+               }
        }
 }
index 53dafeb1aa5fa10f810c6c92ded687c6d9c51d04..592d2f54a431e0c71bcfaa5f411929793093d243 100644 (file)
@@ -56,7 +56,8 @@ func recver(in <-chan int) {
                        break
                }
                if _, ok := seen[v]; ok {
-                       panic("got duplicate value: ", v)
+                       println("got duplicate value: ", v)
+                       panic("fail")
                }
                seen[v] = true
        }
index 5fd7f0d45d2d020d2001c05ec568c40920760e34..2bc5b6cb2b1a5b095b48a77df69ab425cfe881bc 100644 (file)
@@ -13,132 +13,198 @@ import "runtime"
 import "time"
 
 func i32receiver(c chan int32, strobe chan bool) {
-       if <-c != 123 { panic("i32 value") }
+       if <-c != 123 {
+               panic("i32 value")
+       }
        strobe <- true
 }
 
 func i32sender(c chan int32, strobe chan bool) {
-       c <- 234;
+       c <- 234
        strobe <- true
 }
 
 func i64receiver(c chan int64, strobe chan bool) {
-       if <-c != 123456 { panic("i64 value") }
+       if <-c != 123456 {
+               panic("i64 value")
+       }
        strobe <- true
 }
 
 func i64sender(c chan int64, strobe chan bool) {
-       c <- 234567;
+       c <- 234567
        strobe <- true
 }
 
 func breceiver(c chan bool, strobe chan bool) {
-       if ! <-c { panic("b value") }
+       if !<-c {
+               panic("b value")
+       }
        strobe <- true
 }
 
 func bsender(c chan bool, strobe chan bool) {
-       c <- true;
+       c <- true
        strobe <- true
 }
 
 func sreceiver(c chan string, strobe chan bool) {
-       if <-c != "hello" { panic("s value") }
+       if <-c != "hello" {
+               panic("s value")
+       }
        strobe <- true
 }
 
 func ssender(c chan string, strobe chan bool) {
-       c <- "hello again";
+       c <- "hello again"
        strobe <- true
 }
 
-var ticker = time.Tick(10*1000);       // 10 us
+var ticker = time.Tick(10 * 1000) // 10 us
 func sleep() {
-       <-ticker;
-       <-ticker;
-       runtime.Gosched();
-       runtime.Gosched();
-       runtime.Gosched();
+       <-ticker
+       <-ticker
+       runtime.Gosched()
+       runtime.Gosched()
+       runtime.Gosched()
 }
 
 func main() {
-       var i32 int32;
-       var i64 int64;
-       var b bool;
-       var s string;
-       var ok bool;
+       var i32 int32
+       var i64 int64
+       var b bool
+       var s string
+       var ok bool
 
-       var sync = make(chan bool);
+       var sync = make(chan bool)
 
        for buffer := 0; buffer < 2; buffer++ {
-               c32 := make(chan int32, buffer);
-               c64 := make(chan int64, buffer);
-               cb := make(chan bool, buffer);
-               cs := make(chan string, buffer);
-
-               i32, ok = <-c32;
-               if ok { panic("blocked i32sender") }
-
-               i64, ok = <-c64;
-               if ok { panic("blocked i64sender") }
-
-               b, ok = <-cb;
-               if ok { panic("blocked bsender") }
-
-               s, ok = <-cs;
-               if ok { panic("blocked ssender") }
-
-               go i32receiver(c32, sync);
-               sleep();
-               ok = c32 <- 123;
-               if !ok { panic("i32receiver buffer=", buffer) }
-               <-sync;
-
-               go i32sender(c32, sync);
-               if buffer > 0 { <-sync } else { sleep() }
-               i32, ok = <-c32;
-               if !ok { panic("i32sender buffer=", buffer) }
-               if i32 != 234 { panic("i32sender value") }
-               if buffer == 0 { <-sync }
-
-               go i64receiver(c64, sync);
-               sleep();
-               ok = c64 <- 123456;
-               if !ok { panic("i64receiver") }
-               <-sync;
-
-               go i64sender(c64, sync);
-               if buffer > 0 { <-sync } else { sleep() }
-               i64, ok = <-c64;
-               if !ok { panic("i64sender") }
-               if i64 != 234567 { panic("i64sender value") }
-               if buffer == 0 { <-sync }
-
-               go breceiver(cb, sync);
-               sleep();
-               ok = cb <- true;
-               if !ok { panic("breceiver") }
-               <-sync;
-
-               go bsender(cb, sync);
-               if buffer > 0 { <-sync } else { sleep() }
-               b, ok = <-cb;
-               if !ok { panic("bsender") }
-               if !b{ panic("bsender value") }
-               if buffer == 0 { <-sync }
-
-               go sreceiver(cs, sync);
-               sleep();
-               ok = cs <- "hello";
-               if !ok { panic("sreceiver") }
-               <-sync;
-
-               go ssender(cs, sync);
-               if buffer > 0 { <-sync } else { sleep() }
-               s, ok = <-cs;
-               if !ok { panic("ssender") }
-               if s != "hello again" { panic("ssender value") }
-               if buffer == 0 { <-sync }
+               c32 := make(chan int32, buffer)
+               c64 := make(chan int64, buffer)
+               cb := make(chan bool, buffer)
+               cs := make(chan string, buffer)
+
+               i32, ok = <-c32
+               if ok {
+                       panic("blocked i32sender")
+               }
+
+               i64, ok = <-c64
+               if ok {
+                       panic("blocked i64sender")
+               }
+
+               b, ok = <-cb
+               if ok {
+                       panic("blocked bsender")
+               }
+
+               s, ok = <-cs
+               if ok {
+                       panic("blocked ssender")
+               }
+
+               go i32receiver(c32, sync)
+               sleep()
+               ok = c32 <- 123
+               if !ok {
+                       println("i32receiver buffer=", buffer)
+                       panic("fail")
+               }
+               <-sync
+
+               go i32sender(c32, sync)
+               if buffer > 0 {
+                       <-sync
+               } else {
+                       sleep()
+               }
+               i32, ok = <-c32
+               if !ok {
+                       println("i32sender buffer=", buffer)
+                       panic("fail")
+               }
+               if i32 != 234 {
+                       panic("i32sender value")
+               }
+               if buffer == 0 {
+                       <-sync
+               }
+
+               go i64receiver(c64, sync)
+               sleep()
+               ok = c64 <- 123456
+               if !ok {
+                       panic("i64receiver")
+               }
+               <-sync
+
+               go i64sender(c64, sync)
+               if buffer > 0 {
+                       <-sync
+               } else {
+                       sleep()
+               }
+               i64, ok = <-c64
+               if !ok {
+                       panic("i64sender")
+               }
+               if i64 != 234567 {
+                       panic("i64sender value")
+               }
+               if buffer == 0 {
+                       <-sync
+               }
+
+               go breceiver(cb, sync)
+               sleep()
+               ok = cb <- true
+               if !ok {
+                       panic("breceiver")
+               }
+               <-sync
+
+               go bsender(cb, sync)
+               if buffer > 0 {
+                       <-sync
+               } else {
+                       sleep()
+               }
+               b, ok = <-cb
+               if !ok {
+                       panic("bsender")
+               }
+               if !b {
+                       panic("bsender value")
+               }
+               if buffer == 0 {
+                       <-sync
+               }
+
+               go sreceiver(cs, sync)
+               sleep()
+               ok = cs <- "hello"
+               if !ok {
+                       panic("sreceiver")
+               }
+               <-sync
+
+               go ssender(cs, sync)
+               if buffer > 0 {
+                       <-sync
+               } else {
+                       sleep()
+               }
+               s, ok = <-cs
+               if !ok {
+                       panic("ssender")
+               }
+               if s != "hello again" {
+                       panic("ssender value")
+               }
+               if buffer == 0 {
+                       <-sync
+               }
        }
        print("PASS\n")
 }
index d2e7f878697a2379ab07831c2b4b8de9a888085c..55076c9253c6aaceb304d0e52b763f9e37664502 100644 (file)
@@ -13,39 +13,42 @@ package main
 // Send the sequence 2, 3, 4, ... to channel 'ch'.
 func Generate(ch chan<- int) {
        for i := 2; ; i++ {
-               ch <- i  // Send 'i' to channel 'ch'.
+               ch <- i // Send 'i' to channel 'ch'.
        }
 }
 
 // Copy the values from channel 'in' to channel 'out',
 // removing those divisible by 'prime'.
 func Filter(in <-chan int, out chan<- int, prime int) {
-       for i := range in {  // Loop over values received from 'in'.
-               if i % prime != 0 {
-                       out <- i  // Send 'i' to channel 'out'.
+       for i := range in { // Loop over values received from 'in'.
+               if i%prime != 0 {
+                       out <- i // Send 'i' to channel 'out'.
                }
        }
 }
 
 // The prime sieve: Daisy-chain Filter processes together.
 func Sieve(primes chan<- int) {
-       ch := make(chan int) // Create a new channel.
-       go Generate(ch);  // Start Generate() as a subprocess.
+       ch := make(chan int) // Create a new channel.
+       go Generate(ch)      // Start Generate() as a subprocess.
        for {
                // Note that ch is different on each iteration.
-               prime := <-ch;
-               primes <- prime;
-               ch1 := make(chan int);
-               go Filter(ch, ch1, prime);
+               prime := <-ch
+               primes <- prime
+               ch1 := make(chan int)
+               go Filter(ch, ch1, prime)
                ch = ch1
        }
 }
 
 func main() {
-       primes := make(chan int);
-       go Sieve(primes);
-       a := []int{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};
+       primes := make(chan int)
+       go Sieve(primes)
+       a := []int{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97}
        for i := 0; i < len(a); i++ {
-               if x := <-primes; x != a[i] { panic(x, " != ", a[i]) }
+               if x := <-primes; x != a[i] {
+                       println(x, " != ", a[i])
+                       panic("fail")
+               }
        }
 }
index e612ff3c37c7151156126a136f5fa57fba8a9590..7f2ed9157990f3c8e1ee894a0f9736f12f123974 100644 (file)
@@ -165,7 +165,8 @@ func main() {
        a := []int{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97}
        for i := 0; i < len(a); i++ {
                if x := <-primes; x != a[i] {
-                       panic(x, " != ", a[i])
+                       println(x, " != ", a[i])
+                       panic("fail")
                }
        }
 }
index 12e65bec53d34c15eb5d00958af7e3519f4361e3..db0a486dd339f6f6df3688a02a725bade8d5f77b 100644 (file)
@@ -70,6 +70,7 @@ func main() {
        m[ic] = 1
        m[id] = 2
        if m[ic] != 2 {
-               panic("m[ic] = ", m[ic])
+               println("m[ic] = ", m[ic])
+               panic("bad m[ic]")
        }
 }
index 12a2da06174adc6a11da343a8111e8d317e4b4ba..8353ec200e4c633026abe1834f5cf520d254647c 100644 (file)
@@ -4,15 +4,18 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package main   
-       
+package main
+
 func main() {
-       x := 0;
-       x = ^x;  // unary ^ not yet implemented
-       if x != ^0 { panic(x, " ", ^0) }
+       x := 0
+       x = ^x // unary ^ not yet implemented
+       if x != ^0 {
+               println(x, " ", ^0)
+               panic("fail")
+       }
 }
 
 /*
-uetli:~/Source/go/test/bugs gri$ 6g bug082.go 
+uetli:~/Source/go/test/bugs gri$ 6g bug082.go
 bug082.go:7: fatal error: optoas: no entry COM-<int32>INT32
 */
index 7556f8dc562b6aa22ca7f68a6efa0b26e9e53e11..c1054e550cc1702880211e47908711f352a2cee2 100644 (file)
@@ -7,18 +7,21 @@
 package main
 
 type Service struct {
-       rpc [2]int;
+       rpc [2]int
 }
 
 func (s *Service) Serve(a int64) {
-       if a != 1234 { panic(a, " not 1234\n") }
+       if a != 1234 {
+               print(a, " not 1234\n")
+               panic("fail")
+       }
 }
 
 var arith Service
 
 func main() {
-       c := make(chan string);
-       a := new(Service);
-       go a.Serve(1234);
-       _ = c;
+       c := make(chan string)
+       a := new(Service)
+       go a.Serve(1234)
+       _ = c
 }
index d5e40999cef71808304dde518197b67839b2bb82..ec3c21543d336b2120932053b88fd510dce08256 100644 (file)
@@ -6,16 +6,22 @@
 
 package main
 
-type A []int;
+type A []int
 
 func main() {
-       var a [3]A;
+       var a [3]A
        for i := 0; i < 3; i++ {
-               a[i] = A{i};
+               a[i] = A{i}
+       }
+       if a[0][0] != 0 {
+               panic("fail a[0][0]")
+       }
+       if a[1][0] != 1 {
+               panic("fail a[1][0]")
+       }
+       if a[2][0] != 2 {
+               panic("fail a[2][0]")
        }
-       if a[0][0] != 0 { panic(); }
-       if a[1][0] != 1 { panic(); }
-       if a[2][0] != 2 { panic(); }
 }
 
 /*
@@ -41,7 +47,7 @@ pc: 0x4558
 */
 
 /* An array composite literal needs to be created freshly every time.
-        It is a "construction" of an array after all. If I pass the address
-        of the array to some function, it may store it globally. Same applies
-        to struct literals.
+It is a "construction" of an array after all. If I pass the address
+of the array to some function, it may store it globally. Same applies
+to struct literals.
 */
index b5e5875919e75729109641815fac5c95b57f2b89..4e43d1c01b8051a450e9cd90b2d836322042ab9a 100644 (file)
@@ -14,6 +14,7 @@ func f() {
 
 func main() {
        if a != 0 {
-               panic("a=", a)
+               println("a=", a)
+               panic("fail")
        }
 }
index 2cb6d6c31b581ed89dd40745ce10acaa8e7acb4c..ad89ebf52a9b9108179bfce0ccf4de2bf2c3211f 100644 (file)
@@ -5,8 +5,12 @@
 // license that can be found in the LICENSE file.
 
 package main
-type S struct { a int }
+
+type S struct {
+       a int
+}
 type PS *S
+
 func (p *S) get() int {
        return p.a
 }
@@ -15,11 +19,11 @@ func fn(p PS) int {
        // p has type PS, and PS has no methods.
        // (a compiler might see that p is a pointer
        // and go looking in S without noticing PS.)
-       return p.get()  // ERROR "undefined"
+       return p.get() // ERROR "undefined"
 }
 func main() {
-       s := S{1};
+       s := S{1}
        if s.get() != 1 {
-               panic()
+               panic("fail")
        }
 }
index 221eb555852a416e233222bb30920029102680a5..e25eb56b0b3259d8f0f98a4d8695da94531bd640 100644 (file)
@@ -6,13 +6,14 @@
 
 package main
 
-var g byte = 123;
-var f *byte = &g;
-var b = make([]byte, 5);
+var g byte = 123
+var f *byte = &g
+var b = make([]byte, 5)
 
 func main() {
-       b[0:1][0] = *f;
+       b[0:1][0] = *f
        if b[0] != 123 {
-               panic("want 123 got ", b[0]);
-       }       
+               println("want 123 got", b[0])
+               panic("fail")
+       }
 }
index 42d06311cd6c640d327a2b109686ecc1d79736f7..dcd633ddefa892c732b0b870cf20c53b058bde89 100644 (file)
@@ -8,25 +8,28 @@ package main
 
 var v1 = T1(1)
 var v2 = T2{2}
-var v3 = T3{0:3, 1:4}
-var v4 = T4{0:5, 1:6}
-var v5 = T5{0:7, 1:8}
-var v6 = T2{f:9}
-var v7 = T4{f:10}
-var v8 = T5{f:11}
+var v3 = T3{0: 3, 1: 4}
+var v4 = T4{0: 5, 1: 6}
+var v5 = T5{0: 7, 1: 8}
+var v6 = T2{f: 9}
+var v7 = T4{f: 10}
+var v8 = T5{f: 11}
 var pf func(T1)
 
 func main() {
        if v1 != 1 || v2.f != 2 || v3[0] != 3 || v3[1] != 4 ||
-          v4[0] != 5 || v4[1] != 6 || v5[0] != 7 || v5[1] != 8 ||
-          v6.f != 9 || v7[0] != 10 || v8[0] != 11 {
-               panic()
+               v4[0] != 5 || v4[1] != 6 || v5[0] != 7 || v5[1] != 8 ||
+               v6.f != 9 || v7[0] != 10 || v8[0] != 11 {
+               panic("fail")
        }
 }
 
 type T1 int
-type T2 struct { f int }
+type T2 struct {
+       f int
+}
 type T3 []int
 type T4 [2]int
-type T5 map[int] int
+type T5 map[int]int
+
 const f = 0
index 39255d6f9c1ec9612d9a2f1aa60d11cd3c878093..b64583114f484e8ad404d2667da2d2f058a2cae1 100644 (file)
 package main
 
 var gen = 'a'
+
 func f(n int) string {
-       s := string(gen) + string(n+'A'-1);
-       gen++;
-       return s;
+       s := string(gen) + string(n+'A'-1)
+       gen++
+       return s
 }
 
 func g(x, y string) string {
@@ -23,16 +24,19 @@ func g(x, y string) string {
 }
 
 func main() {
-       s := f(1) + f(2);
+       s := f(1) + f(2)
        if s != "aAbB" {
-               panic("BUG: bug221a: ", s);
+               println("BUG: bug221a: ", s)
+               panic("fail")
        }
-       s = g(f(3), f(4));
+       s = g(f(3), f(4))
        if s != "cCdD" {
-               panic("BUG: bug221b: ", s);
+               println("BUG: bug221b: ", s)
+               panic("fail")
        }
-       s = f(5) + f(6) + f(7) + f(8) + f(9);
+       s = f(5) + f(6) + f(7) + f(8) + f(9)
        if s != "eEfFgGhHiI" {
-               panic("BUG: bug221c: ", s);
+               println("BUG: bug221c: ", s)
+               panic("fail")
        }
 }
index be27a68cec9ca75872aa42124fc9e321c315c0c8..a60866044d1f6ff628f3e949bc851187024617da 100644 (file)
@@ -7,11 +7,11 @@
 package main
 
 var (
-       nf int
+       nf      int
        x, y, z = f(), f(), f()
-       m = map[string]string{"a":"A"}
-       a, aok = m["a"]
-       b, bok = m["b"]
+       m       = map[string]string{"a": "A"}
+       a, aok  = m["a"]
+       b, bok  = m["b"]
 )
 
 func look(s string) (string, bool) {
@@ -26,9 +26,11 @@ func f() int {
 
 func main() {
        if nf != 3 || x != 1 || y != 2 || z != 3 {
-               panic("nf=", nf, " x=", x, " y=", y)
+               println("nf=", nf, " x=", x, " y=", y)
+               panic("fail")
        }
        if a != "A" || aok != true || b != "" || bok != false {
-               panic("a=", a, " aok=", aok, " b=", b, " bok=", bok)
+               println("a=", a, " aok=", aok, " b=", b, " bok=", bok)
+               panic("fail")
        }
 }
index 882bc74017daeed18685b33e5081097a68679672..b806ca64e98f2cad5ba97cb580afff2dd210fc91 100644 (file)
@@ -11,10 +11,12 @@ func main() {
        c <- 100
        x, ok := <-c
        if x != 100 || !ok {
-               panic("x=", x, " ok=", ok, " want 100, true")
+               println("x=", x, " ok=", ok, " want 100, true")
+               panic("fail")
        }
        x, ok = <-c
        if x != 0 || ok {
-               panic("x=", x, " ok=", ok, " want 0, false")
+               println("x=", x, " ok=", ok, " want 0, false")
+               panic("fail")
        }
 }
index 26db78777f44f743d1245f67a268b4925522bfe4..915c3fcd095add6c64a6df2379d9c8dcaa56d003 100644 (file)
@@ -25,6 +25,7 @@ var v, ok = m[g()]
 
 func main() {
        if x != 1 || y != 2 || z != 3 || nf != 1 || v != 0 || ok != false || ng != 1 {
-               panic("x=", x, " y=", y, " z=", z, " nf=", nf, " v=", v, " ok=", ok, " ng=", ng)
+               println("x=", x, " y=", y, " z=", z, " nf=", nf, " v=", v, " ok=", ok, " ng=", ng)
+               panic("fail")
        }
 }
index f3599614d8166185e9dd1ee130f5fdbd5f289757..bb5b770f51a2211a187551ac94520d8060f90cd9 100644 (file)
@@ -20,9 +20,10 @@ type S4 struct {
        S3
        S1
 }
+
 func main() {
        var s4 S4
-       if s4.i != 0 {  // .i refers to s4.S1.i, unambiguously
-               panic()
+       if s4.i != 0 { // .i refers to s4.S1.i, unambiguously
+               panic("fail")
        }
 }
index 1ace12ee356a18c443bd903cab452114cc659b35..66f580bd1c2ab81efa3b01e80a7584de94d9d709 100644 (file)
@@ -40,13 +40,15 @@ func main() {
        m := make(map[string]int)
        m[f()], *g() = strconv.Atoi(h())
        if m["abc"] != 123 || trace != "fgh" {
-               panic("BUG", m["abc"], trace)
+               println("BUG", m["abc"], trace)
+               panic("fail")
        }
        mm := make(map[string]os.Error)
        trace = ""
        mm["abc"] = os.EINVAL
        *i(), mm[f()] = strconv.Atoi(h())
        if mm["abc"] != nil || trace != "ifh" {
-               panic("BUG1", mm["abc"], trace)
+               println("BUG1", mm["abc"], trace)
+               panic("fail")
        }
 }
index 033aa0e3ff5ce7464d7e221b3446315ee3ba7b2c..e27825c2b281cdaff880ca7b4f502556668da73b 100644 (file)
@@ -7,13 +7,13 @@
 package main
 
 func caller(f func(int, int) int, a, b int, c chan int) {
-       c <- f(a,b)
+       c <- f(a, b)
 }
-       
+
 func gocall(f func(int, int) int, a, b int) int {
-       c := make(chan int);
-       go caller(f, a, b, c);
-       return <-c;
+       c := make(chan int)
+       go caller(f, a, b, c)
+       return <-c
 }
 
 func call(f func(int, int) int, a, b int) int {
@@ -30,7 +30,7 @@ func add(x, y int) int {
        return x + y
 }
 
-func fn() (func(int, int) int) {
+func fn() func(int, int) int {
        return f
 }
 
@@ -40,50 +40,50 @@ func addc(x, y int, c chan int) {
        c <- x+y
 }
 
-func fnc() (func(int, int, chan int)) {
+func fnc() func(int, int, chan int) {
        return fc
 }
 
 func three(x int) {
        if x != 3 {
-               panic("wrong val", x)
+               println("wrong val", x)
+               panic("fail")
        }
 }
 
 var notmain func()
 
-func emptyresults() () {}
-func noresults() {}
+func emptyresults() {}
+func noresults()    {}
 
 var nothing func()
 
 func main() {
-       three(call(add, 1, 2));
-       three(call1(add, 1, 2));
-       f = add;
-       three(call(f, 1, 2));
-       three(call1(f, 1, 2));
-       three(call(fn(), 1, 2));
-       three(call1(fn(), 1, 2));
-       three(call(func(a,b int) int {return a+b}, 1, 2));
-       three(call1(func(a,b int) int {return a+b}, 1, 2));
-
-       fc = addc;
-       c := make(chan int);
-       go addc(1, 2, c);
-       three(<-c);
-       go fc(1, 2, c);
-       three(<-c);
-       go fnc()(1, 2, c);
-       three(<-c);
-       go func(a, b int, c chan int){c <- a+b}(1, 2, c);
-       three(<-c);
-
-       emptyresults();
-       noresults();
-       nothing = emptyresults;
-       nothing();
-       nothing = noresults;
-       nothing();
+       three(call(add, 1, 2))
+       three(call1(add, 1, 2))
+       f = add
+       three(call(f, 1, 2))
+       three(call1(f, 1, 2))
+       three(call(fn(), 1, 2))
+       three(call1(fn(), 1, 2))
+       three(call(func(a, b int) int { return a + b }, 1, 2))
+       three(call1(func(a, b int) int { return a + b }, 1, 2))
+
+       fc = addc
+       c := make(chan int)
+       go addc(1, 2, c)
+       three(<-c)
+       go fc(1, 2, c)
+       three(<-c)
+       go fnc()(1, 2, c)
+       three(<-c)
+       go func(a, b int, c chan int) { c <- a+b }(1, 2, c)
+       three(<-c)
+
+       emptyresults()
+       noresults()
+       nothing = emptyresults
+       nothing()
+       nothing = noresults
+       nothing()
 }
-
index 9e08b20e01f6301c7e996d152d889d307bb04b13..e8f7037cf57212fe9c721d1d891f1a9f99d7e5f0 100644 (file)
@@ -189,6 +189,6 @@ bar
 bar
 bal
 bal
-barCount != 1
+panic: barCount != 1
 panic PC=xxx
 BUG
index bc219c72f5268f7f599c0a98a9c383efbb4b2d07..7f429f7031e14274113816eefe9947ee4cee6f74 100644 (file)
@@ -9,21 +9,28 @@
 
 package main
 
-type Stringer interface { String() string }
-type StringLengther interface { String() string; Length() int }
-type Empty interface { }
+type Stringer interface {
+       String() string
+}
+type StringLengther interface {
+       String() string
+       Length() int
+}
+type Empty interface{}
 
 type T string
+
 func (t T) String() string {
-       return string(t);
+       return string(t)
 }
 func (t T) Length() int {
-       return len(t);
+       return len(t)
 }
 
 type U string
+
 func (u U) String() string {
-       return string(u);
+       return string(u)
 }
 
 var t = T("hello")
@@ -36,104 +43,105 @@ var ok bool
 
 func hello(s string) {
        if s != "hello" {
-               panic("not hello: ", s);
+               println("not hello: ", s)
+               panic("fail")
        }
 }
 
 func five(i int) {
        if i != 5 {
-               panic("not 5: ", i);
+               println("not 5: ", i)
+               panic("fail")
        }
 }
 
 func true(ok bool) {
        if !ok {
-               panic("not true");
+               panic("not true")
        }
 }
 
 func false(ok bool) {
        if ok {
-               panic("not false");
+               panic("not false")
        }
 }
 
 func main() {
        // T2I
-       s = t;
-       hello(s.String());
+       s = t
+       hello(s.String())
 
        // I2T
-       t = s.(T);
-       hello(t.String());
+       t = s.(T)
+       hello(t.String())
 
        // T2E
-       e = t;
+       e = t
 
        // E2T
-       t = e.(T);
-       hello(t.String());
+       t = e.(T)
+       hello(t.String())
 
        // T2I again
-       sl = t;
-       hello(sl.String());
-       five(sl.Length());
+       sl = t
+       hello(sl.String())
+       five(sl.Length())
 
        // I2I static
-       s = sl;
-       hello(s.String());
+       s = sl
+       hello(s.String())
 
        // I2I dynamic
-       sl = s.(StringLengther);
-       hello(sl.String());
-       five(sl.Length());
+       sl = s.(StringLengther)
+       hello(sl.String())
+       five(sl.Length())
 
        // I2E (and E2T)
-       e = s;
-       hello(e.(T).String());
+       e = s
+       hello(e.(T).String())
 
        // E2I
-       s = e.(Stringer);
-       hello(s.String());
+       s = e.(Stringer)
+       hello(s.String())
 
        // I2T2 true
-       t, ok = s.(T);
-       true(ok);
-       hello(t.String());
+       t, ok = s.(T)
+       true(ok)
+       hello(t.String())
 
        // I2T2 false
-       _, ok = s.(U);
-       false(ok);
+       _, ok = s.(U)
+       false(ok)
 
        // I2I2 true
-       sl, ok = s.(StringLengther);
-       true(ok);
-       hello(sl.String());
-       five(sl.Length());
+       sl, ok = s.(StringLengther)
+       true(ok)
+       hello(sl.String())
+       five(sl.Length())
 
        // I2I2 false (and T2I)
-       s = u;
-       sl, ok = s.(StringLengther);
-       false(ok);
+       s = u
+       sl, ok = s.(StringLengther)
+       false(ok)
 
        // E2T2 true
-       t, ok = e.(T);
-       true(ok);
-       hello(t.String());
+       t, ok = e.(T)
+       true(ok)
+       hello(t.String())
 
        // E2T2 false
-       i, ok = e.(int);
-       false(ok);
+       i, ok = e.(int)
+       false(ok)
 
        // E2I2 true
-       sl, ok = e.(StringLengther);
-       true(ok);
-       hello(sl.String());
-       five(sl.Length());
+       sl, ok = e.(StringLengther)
+       true(ok)
+       hello(sl.String())
+       five(sl.Length())
 
        // E2I2 false (and T2E)
-       e = u;
-       sl, ok = e.(StringLengther);
-       false(ok);
+       e = u
+       sl, ok = e.(StringLengther)
+       false(ok)
 }
-
index 59f3986d7f1edec850c0eeba1d9355507692b211..f74cecb2c89fa7bc903682942436c631b6702b3c 100644 (file)
@@ -22,7 +22,8 @@ func (t T) V() {
 
 func (t *T) P() {
        if *t != 42 {
-               panic(t, *t)
+               println(t, *t)
+               panic("fail")
        }
        np++
 }
index 9600e8a1a6acb5c80adb3555255abb08eacc7c2c..7785cdf8f6ecee032fea01d4f344ee4d3b21af2a 100644 (file)
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package        main
+package main
 
-func
-setpd(a []int) {
-//     print("setpd a=", a, " len=", len(a), " cap=", cap(a), "\n");
-       for i:=0; i<len(a); i++ {
-               a[i] = i;
+func setpd(a []int) {
+       //      print("setpd a=", a, " len=", len(a), " cap=", cap(a), "\n");
+       for i := 0; i < len(a); i++ {
+               a[i] = i
        }
 }
 
-func
-sumpd(a []int) int {
-//     print("sumpd a=", a, " len=", len(a), " cap=", cap(a), "\n");
-       t := 0;
-       for i:=0; i<len(a); i++ {
-               t += a[i];
+func sumpd(a []int) int {
+       //      print("sumpd a=", a, " len=", len(a), " cap=", cap(a), "\n");
+       t := 0
+       for i := 0; i < len(a); i++ {
+               t += a[i]
        }
-//     print("sumpd t=", t, "\n");
-       return t;
+       //      print("sumpd t=", t, "\n");
+       return t
 }
 
-func
-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;
+func 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
        }
 }
 
-func
-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++ {
-               t += a[i];
+func 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++ {
+               t += a[i]
        }
-//     print("sumpf t=", t, "\n");
-       return t;
+       //      print("sumpf t=", t, "\n");
+       return t
 }
 
-func
-res(t int, lb, hb int) {
-       sb := (hb-lb)*(hb+lb-1)/2;
+func res(t int, lb, hb int) {
+       sb := (hb - lb) * (hb + lb - 1) / 2
        if t != sb {
-               print(  "lb=", lb,
+               print("lb=", lb,
                        "; hb=", hb,
                        "; t=", t,
                        "; sb=", sb,
-                       "\n");
+                       "\n")
                panic("res")
        }
 }
 
 // call ptr dynamic with ptr dynamic
-func
-testpdpd() {
-       a := make([]int, 10, 100);
+func testpdpd() {
+       a := make([]int, 10, 100)
        if len(a) != 10 && cap(a) != 100 {
-               panic("len and cap from new: ", len(a), " ", cap(a), "\n");
+               print("len and cap from new: ", len(a), " ", cap(a), "\n")
+               panic("fail")
        }
 
-       a = a[0:100];
-       setpd(a);
+       a = a[0:100]
+       setpd(a)
 
-       a = a[0:10];
-       res(sumpd(a), 0, 10);
+       a = a[0:10]
+       res(sumpd(a), 0, 10)
 
-       a = a[5:25];
-       res(sumpd(a), 5, 25);
+       a = a[5:25]
+       res(sumpd(a), 5, 25)
 }
 
 // call ptr fixed with ptr fixed
-func
-testpfpf() {
-       var a [20]int;
+func testpfpf() {
+       var a [20]int
 
-       setpf(&a);
-       res(sumpf(&a), 0, 20);
+       setpf(&a)
+       res(sumpf(&a), 0, 20)
 }
 
 // call ptr dynamic with ptr fixed from new
-func
-testpdpf1() {
-       a := new([40]int);
-       setpd(a);
-       res(sumpd(a), 0, 40);
-
-       b := (*a)[5:30];
-       res(sumpd(b), 5, 30);
+func testpdpf1() {
+       a := new([40]int)
+       setpd(a)
+       res(sumpd(a), 0, 40)
+
+       b := (*a)[5:30]
+       res(sumpd(b), 5, 30)
 }
 
 // call ptr dynamic with ptr fixed from var
-func
-testpdpf2() {
-       var a [80]int;
+func testpdpf2() {
+       var a [80]int
 
-       setpd(&a);
-       res(sumpd(&a), 0, 80);
+       setpd(&a)
+       res(sumpd(&a), 0, 80)
 }
 
 // generate bounds error with ptr dynamic
-func
-testpdfault() {
-       a := make([]int, 100);
+func testpdfault() {
+       a := make([]int, 100)
 
-       print("good\n");
-       for i:=0; i<100; i++ {
-               a[i] = 0;
+       print("good\n")
+       for i := 0; i < 100; i++ {
+               a[i] = 0
        }
-       print("should fault\n");
-       a[100] = 0;
-       print("bad\n");
+       print("should fault\n")
+       a[100] = 0
+       print("bad\n")
 }
 
 // generate bounds error with ptr fixed
-func
-testfdfault() {
-       var a [80]int;
+func testfdfault() {
+       var a [80]int
 
-       print("good\n");
-       for i:=0; i<80; i++ {
-               a[i] = 0;
+       print("good\n")
+       for i := 0; i < 80; i++ {
+               a[i] = 0
        }
-       print("should fault\n");
-       x := 80;
-       a[x] = 0;
-       print("bad\n");
+       print("should fault\n")
+       x := 80
+       a[x] = 0
+       print("bad\n")
 }
 
-func
-main() {
-       testpdpd();
-       testpfpf();
-       testpdpf1();
-       testpdpf2();
-//     print("testpdfault\n"); testpdfault();
-//     print("testfdfault\n"); testfdfault();
+func main() {
+       testpdpd()
+       testpfpf()
+       testpdpf1()
+       testpdpf2()
+       //      print("testpdfault\n"); testpdfault();
+       //      print("testfdfault\n"); testfdfault();
 }
index 7504b49685d654c9106a6759cee5ea16535763b0..ef75b044d7c45ad78248d5d6c1c0f59e19a19ef4 100644 (file)
@@ -10,36 +10,33 @@ import "os"
 import "runtime"
 import "sync"
 
-var    randx   int;
+var randx int
 
-func
-nrand(n int) int {
-       randx += 10007;
+func nrand(n int) int {
+       randx += 10007
        if randx >= 1000000 {
-               randx -= 1000000;
+               randx -= 1000000
        }
-       return randx%n;
+       return randx % n
 }
 
-type   Chan struct {
-       sc,rc   chan int;       // send and recv chan
-       sv,rv   int;            // send and recv seq
+type Chan struct {
+       sc, rc chan int // send and recv chan
+       sv, rv int      // send and recv seq
 }
 
-var
-(
-       nproc           int;
-       nprocLock       sync.Mutex;
-       cval            int;
-       end             int     = 10000;
-       totr,tots       int;
-       totLock         sync.Mutex;
-       nc              *Chan;
+var (
+       nproc      int
+       nprocLock  sync.Mutex
+       cval       int
+       end        int = 10000
+       totr, tots int
+       totLock    sync.Mutex
+       nc         *Chan
 )
 
-func
-init() {
-       nc = new(Chan);
+func init() {
+       nc = new(Chan)
 }
 
 func changeNproc(adjust int) int {
@@ -50,280 +47,283 @@ func changeNproc(adjust int) int {
        return ret
 }
 
-func
-mkchan(c,n int) []*Chan {
-       ca := make([]*Chan, n);
-       for i:=0; i<n; i++ {
-               cval = cval+100;
-               ch := new(Chan);
-               ch.sc = make(chan int, c);
-               ch.rc = ch.sc;
-               ch.sv = cval;
-               ch.rv = cval;
-               ca[i] = ch;
+func mkchan(c, n int) []*Chan {
+       ca := make([]*Chan, n)
+       for i := 0; i < n; i++ {
+               cval = cval + 100
+               ch := new(Chan)
+               ch.sc = make(chan int, c)
+               ch.rc = ch.sc
+               ch.sv = cval
+               ch.rv = cval
+               ca[i] = ch
        }
-       return ca;
+       return ca
 }
 
-func
-expect(v, v0 int) (newv int) {
+func expect(v, v0 int) (newv int) {
        if v == v0 {
                if v%100 == 75 {
-                       return end;
+                       return end
                }
-               return v+1;
+               return v + 1
        }
-       panic("got ", v, " expected ", v0+1, "\n");
+       print("got ", v, " expected ", v0+1, "\n")
+       panic("fail")
 }
 
 func (c *Chan) send() bool {
-//     print("send ", c.sv, "\n");
-       totLock.Lock();
-       tots++;
-       totLock.Unlock();
-       c.sv = expect(c.sv, c.sv);
+       //      print("send ", c.sv, "\n");
+       totLock.Lock()
+       tots++
+       totLock.Unlock()
+       c.sv = expect(c.sv, c.sv)
        if c.sv == end {
-               c.sc = nil;
-               return true;
+               c.sc = nil
+               return true
        }
-       return false;
+       return false
 }
 
-func
-send(c *Chan) {
+func send(c *Chan) {
        for {
-               for r:=nrand(10); r>=0; r-- {
-                       runtime.Gosched();
+               for r := nrand(10); r >= 0; r-- {
+                       runtime.Gosched()
                }
-               c.sc <- c.sv;
+               c.sc <- c.sv
                if c.send() {
-                       break;
+                       break
                }
        }
        changeNproc(-1)
 }
 
 func (c *Chan) recv(v int) bool {
-//     print("recv ", v, "\n");
-       totLock.Lock();
-       totr++;
-       totLock.Unlock();
-       c.rv = expect(c.rv, v);
+       //      print("recv ", v, "\n");
+       totLock.Lock()
+       totr++
+       totLock.Unlock()
+       c.rv = expect(c.rv, v)
        if c.rv == end {
-               c.rc = nil;
-               return true;
+               c.rc = nil
+               return true
        }
-       return false;
+       return false
 }
 
-func
-recv(c *Chan) {
-       var v int;
+func recv(c *Chan) {
+       var v int
 
        for {
-               for r:=nrand(10); r>=0; r-- {
-                       runtime.Gosched();
+               for r := nrand(10); r >= 0; r-- {
+                       runtime.Gosched()
                }
-               v = <-c.rc;
+               v = <-c.rc
                if c.recv(v) {
-                       break;
+                       break
                }
        }
-       changeNproc(-1);
+       changeNproc(-1)
 }
 
-func
-sel(r0,r1,r2,r3, s0,s1,s2,s3 *Chan) {
-       var v int;
+func sel(r0, r1, r2, r3, s0, s1, s2, s3 *Chan) {
+       var v int
 
-       a := 0;         // local chans running
+       a := 0 // local chans running
 
-       if r0.rc != nil { a++ }
-       if r1.rc != nil { a++ }
-       if r2.rc != nil { a++ }
-       if r3.rc != nil { a++ }
-       if s0.sc != nil { a++ }
-       if s1.sc != nil { a++ }
-       if s2.sc != nil { a++ }
-       if s3.sc != nil { a++ }
+       if r0.rc != nil {
+               a++
+       }
+       if r1.rc != nil {
+               a++
+       }
+       if r2.rc != nil {
+               a++
+       }
+       if r3.rc != nil {
+               a++
+       }
+       if s0.sc != nil {
+               a++
+       }
+       if s1.sc != nil {
+               a++
+       }
+       if s2.sc != nil {
+               a++
+       }
+       if s3.sc != nil {
+               a++
+       }
 
        for {
-               for r:=nrand(5); r>=0; r-- {
-                       runtime.Gosched();
+               for r := nrand(5); r >= 0; r-- {
+                       runtime.Gosched()
                }
 
                select {
                case v = <-r0.rc:
                        if r0.recv(v) {
-                               a--;
+                               a--
                        }
                case v = <-r1.rc:
                        if r1.recv(v) {
-                               a--;
+                               a--
                        }
                case v = <-r2.rc:
                        if r2.recv(v) {
-                               a--;
+                               a--
                        }
                case v = <-r3.rc:
                        if r3.recv(v) {
-                               a--;
+                               a--
                        }
                case s0.sc <- s0.sv:
                        if s0.send() {
-                               a--;
+                               a--
                        }
                case s1.sc <- s1.sv:
                        if s1.send() {
-                               a--;
+                               a--
                        }
                case s2.sc <- s2.sv:
                        if s2.send() {
-                               a--;
+                               a--
                        }
                case s3.sc <- s3.sv:
                        if s3.send() {
-                               a--;
+                               a--
                        }
                }
                if a == 0 {
-                       break;
+                       break
                }
        }
-       changeNproc(-1);
+       changeNproc(-1)
 }
 
 // direct send to direct recv
-func
-test1(c *Chan) {
+func test1(c *Chan) {
        changeNproc(2)
-       go send(c);
-       go recv(c);
+       go send(c)
+       go recv(c)
 }
 
 // direct send to select recv
-func
-test2(c int) {
-       ca := mkchan(c,4);
+func test2(c int) {
+       ca := mkchan(c, 4)
 
        changeNproc(4)
-       go send(ca[0]);
-       go send(ca[1]);
-       go send(ca[2]);
-       go send(ca[3]);
+       go send(ca[0])
+       go send(ca[1])
+       go send(ca[2])
+       go send(ca[3])
 
        changeNproc(1)
-       go sel(ca[0],ca[1],ca[2],ca[3], nc,nc,nc,nc);
+       go sel(ca[0], ca[1], ca[2], ca[3], nc, nc, nc, nc)
 }
 
 // select send to direct recv
-func
-test3(c int) {
-       ca := mkchan(c,4);
+func test3(c int) {
+       ca := mkchan(c, 4)
 
        changeNproc(4)
-       go recv(ca[0]);
-       go recv(ca[1]);
-       go recv(ca[2]);
-       go recv(ca[3]);
+       go recv(ca[0])
+       go recv(ca[1])
+       go recv(ca[2])
+       go recv(ca[3])
 
        changeNproc(1)
-       go sel(nc,nc,nc,nc, ca[0],ca[1],ca[2],ca[3]);
+       go sel(nc, nc, nc, nc, ca[0], ca[1], ca[2], ca[3])
 }
 
 // select send to select recv
-func
-test4(c int) {
-       ca := mkchan(c,4);
+func test4(c int) {
+       ca := mkchan(c, 4)
 
        changeNproc(2)
-       go sel(nc,nc,nc,nc, ca[0],ca[1],ca[2],ca[3]);
-       go sel(ca[0],ca[1],ca[2],ca[3], nc,nc,nc,nc);
+       go sel(nc, nc, nc, nc, ca[0], ca[1], ca[2], ca[3])
+       go sel(ca[0], ca[1], ca[2], ca[3], nc, nc, nc, nc)
 }
 
-func
-test5(c int) {
-       ca := mkchan(c,8);
+func test5(c int) {
+       ca := mkchan(c, 8)
 
        changeNproc(2)
-       go sel(ca[4],ca[5],ca[6],ca[7], ca[0],ca[1],ca[2],ca[3]);
-       go sel(ca[0],ca[1],ca[2],ca[3], ca[4],ca[5],ca[6],ca[7]);
+       go sel(ca[4], ca[5], ca[6], ca[7], ca[0], ca[1], ca[2], ca[3])
+       go sel(ca[0], ca[1], ca[2], ca[3], ca[4], ca[5], ca[6], ca[7])
 }
 
-func
-test6(c int) {
-       ca := mkchan(c,12);
+func test6(c int) {
+       ca := mkchan(c, 12)
 
        changeNproc(4)
-       go send(ca[4]);
-       go send(ca[5]);
-       go send(ca[6]);
-       go send(ca[7]);
+       go send(ca[4])
+       go send(ca[5])
+       go send(ca[6])
+       go send(ca[7])
 
        changeNproc(4)
-       go recv(ca[8]);
-       go recv(ca[9]);
-       go recv(ca[10]);
-       go recv(ca[11]);
+       go recv(ca[8])
+       go recv(ca[9])
+       go recv(ca[10])
+       go recv(ca[11])
 
        changeNproc(2)
-       go sel(ca[4],ca[5],ca[6],ca[7], ca[0],ca[1],ca[2],ca[3]);
-       go sel(ca[0],ca[1],ca[2],ca[3], ca[8],ca[9],ca[10],ca[11]);
+       go sel(ca[4], ca[5], ca[6], ca[7], ca[0], ca[1], ca[2], ca[3])
+       go sel(ca[0], ca[1], ca[2], ca[3], ca[8], ca[9], ca[10], ca[11])
 }
 
 // wait for outstanding tests to finish
-func
-wait() {
-       runtime.Gosched();
+func wait() {
+       runtime.Gosched()
        for changeNproc(0) != 0 {
-               runtime.Gosched();
+               runtime.Gosched()
        }
 }
 
 // run all tests with specified buffer size
-func
-tests(c int) {
-       ca := mkchan(c,4);
-       test1(ca[0]);
-       test1(ca[1]);
-       test1(ca[2]);
-       test1(ca[3]);
-       wait();
+func tests(c int) {
+       ca := mkchan(c, 4)
+       test1(ca[0])
+       test1(ca[1])
+       test1(ca[2])
+       test1(ca[3])
+       wait()
 
-       test2(c);
-       wait();
+       test2(c)
+       wait()
 
-       test3(c);
-       wait();
+       test3(c)
+       wait()
 
-       test4(c);
-       wait();
+       test4(c)
+       wait()
 
-       test5(c);
-       wait();
+       test5(c)
+       wait()
 
-       test6(c);
-       wait();
+       test6(c)
+       wait()
 }
 
 // run all test with 4 buffser sizes
-func
-main() {
+func main() {
 
-       tests(0);
-       tests(1);
-       tests(10);
-       tests(100);
+       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");
-               os.Exit(1);
+               print("tots=", tots, " totr=", totr, " sb=", t, "\n")
+               os.Exit(1)
        }
-       os.Exit(0);
+       os.Exit(0)
 }
index 14617de9c76a89d24ea12734b534eb7709ed3301..6c15b16164624ce607973e565c64f386a48ee86e 100644 (file)
 
 package main
 
-func
-main() {
-       var c string;
+func main() {
+       var c string
 
-       a := `abc`;
-       b := `xyz`;
+       a := `abc`
+       b := `xyz`
 
        /* print a literal */
-       print(`abc`);
+       print(`abc`)
 
        /* print a variable */
-       print(b, "-");
+       print(b, "-")
 
        /* catenate literals */
-       print(`abc` + `xyz`, "-");
+       print(`abc`+`xyz`, "-")
 
        /* catenate variables */
-       print(a+b, "-");
+       print(a+b, "-")
 
        /* compare literals */
        if `abc` == `xyz` || `abc` != "abc" || `abc` > `xyz` {
-               panic("compare literals");
+               panic("compare literals")
        }
 
        /* compare variables */
        if a == b || a != a || a > b {
-               panic("compare variables");
+               panic("compare variables")
        }
 
        /* cat */
-       c = a+b;
-       print(c, "-");
+       c = a + b
+       print(c, "-")
 
        /* catequal */
-       c = a;
-       c += b;
-       print(c, "-");
+       c = a
+       c += b
+       print(c, "-")
 
        /* clumsy evaluation */
-       c = b;
-       c = a + c;
-       print(c, "-");
+       c = b
+       c = a + c
+       print(c, "-")
 
        /* len */
        if len(c) != 6 {
-               panic("len ", len(c));
+               print("len ", len(c))
+               panic("fail")
        }
 
        /* index strings */
-       for i:=0; i<len(c); i=i+1 {
-               if c[i] != (a+b)[i] {
-                       panic("index ", i, " ", c[i], " ", (a+b)[i]);
+       for i := 0; i < len(c); i = i + 1 {
+               if c[i] != (a + b)[i] {
+                       print("index ", i, " ", c[i], " ", (a + b)[i])
+                       panic("fail")
                }
        }
 
        /* slice strings */
-       print(c[0:3], c[3:]);
+       print(c[0:3], c[3:])
 
-       print("\n");
+       print("\n")
 
        /* create string with integer constant */
-       c = string('x');
+       c = string('x')
        if c != "x" {
-               panic("create int ", c);
+               print("create int ", c)
+               panic("fail")
        }
 
        /* create string with integer variable */
-       v := 'x';
-       c = string(v);
+       v := 'x'
+       c = string(v)
        if c != "x" {
-               panic("create int ", c);
+               print("create int ", c)
+               panic("fail")
        }
 
        /* create string with byte array */
-       var z1 [3]byte;
-       z1[0] = 'a';
-       z1[1] = 'b';
-       z1[2] = 'c';
-       c = string(&z1);
+       var z1 [3]byte
+       z1[0] = 'a'
+       z1[1] = 'b'
+       z1[2] = 'c'
+       c = string(&z1)
        if c != "abc" {
-               panic("create byte array ", c);
+               print("create byte array ", c)
+               panic("fail")
        }
 
        /* create string with int array */
-       var z2 [3]int;
-       z2[0] = 'a';
-       z2[1] = '\u1234';
-       z2[2] = 'c';
-       c = string(&z2);
+       var z2 [3]int
+       z2[0] = 'a'
+       z2[1] = '\u1234'
+       z2[2] = 'c'
+       c = string(&z2)
        if c != "a\u1234c" {
-               panic("create int array ", c);
+               print("create int array ", c)
+               panic("fail")
        }
 
        /* create string with byte array pointer */
-       z3 := new([3]byte);
-       z3[0] = 'a';
-       z3[1] = 'b';
-       z3[2] = 'c';
-       c = string(z3);
+       z3 := new([3]byte)
+       z3[0] = 'a'
+       z3[1] = 'b'
+       z3[2] = 'c'
+       c = string(z3)
        if c != "abc" {
-               panic("create array pointer ", c);
+               print("create array pointer ", c)
+               panic("fail")
        }
 }
index 44229d490c35b2b4f2e79025e9dff284b1c99149..dc6d74bad6849b78ea4be50482932fb3378a11e8 100644 (file)
@@ -58,9 +58,10 @@ func main() {
        for i := 0; i < N; i++ {
                runtime.GC()
                runtime.Gosched()
-               time.Sleep(1e6);
+               time.Sleep(1e6)
        }
        if nfinal < N*8/10 {
-               panic("not enough finalizing:", nfinal, "/", N)
+               println("not enough finalizing:", nfinal, "/", N)
+               panic("fail")
        }
 }
index e7f3f06f4e55116a5c5352497d26f69c50245f51..2357d83753f85d4842a4a9151a7a6bd0a701642c 100644 (file)
@@ -47,7 +47,8 @@ func main() {
                        during := runtime.MemStats.Alloc
                        runtime.Free(b)
                        if a := runtime.MemStats.Alloc; a != 0 {
-                               panic("allocated ", j, ": wrong stats: during=", during, " after=", a, " (want 0)")
+                               println("allocated ", j, ": wrong stats: during=", during, " after=", a, " (want 0)")
+                               panic("fail")
                        }
                        bigger()
                }
index ccff66bfef966e6588ba7e5810568abcba93d0e6..77a0d1272b62a6bf1800d2373ead233f3deb6ec4 100644 (file)
@@ -15,51 +15,51 @@ type Number struct {
 // Peano primitives
 
 func zero() *Number {
-       return nil;
+       return nil
 }
 
 
 func is_zero(x *Number) bool {
-       return x == nil;
+       return x == nil
 }
 
 
 func add1(x *Number) *Number {
-       e := new(Number);
-       e.next = x;
-       return e;
+       e := new(Number)
+       e.next = x
+       return e
 }
 
 
 func sub1(x *Number) *Number {
-       return x.next;
+       return x.next
 }
 
 
-func add(x, y *Number) *Number{
+func add(x, y *Number) *Number {
        if is_zero(y) {
-               return x;
+               return x
        }
 
-       return add(add1(x), sub1(y));
+       return add(add1(x), sub1(y))
 }
 
 
 func mul(x, y *Number) *Number {
-       if is_zero(x) || is_zero(y){
-               return zero();
+       if is_zero(x) || is_zero(y) {
+               return zero()
        }
 
-       return add(mul(x, sub1(y)), x);
+       return add(mul(x, sub1(y)), x)
 }
 
 
 func fact(n *Number) *Number {
        if is_zero(n) {
-               return add1(zero());
+               return add1(zero())
        }
 
-       return mul(fact(sub1(n)), n);
+       return mul(fact(sub1(n)), n)
 }
 
 
@@ -68,26 +68,27 @@ func fact(n *Number) *Number {
 
 func gen(n int) *Number {
        if n > 0 {
-               return add1(gen(n - 1));
+               return add1(gen(n - 1))
        }
 
-       return zero();
+       return zero()
 }
 
 
 func count(x *Number) int {
        if is_zero(x) {
-               return 0;
+               return 0
        }
 
-       return count(sub1(x)) + 1;
+       return count(sub1(x)) + 1
 }
 
 
 func check(x *Number, expected int) {
-       var c = count(x);
+       var c = count(x)
        if c != expected {
-               panic("error: found ", c, "; expected ", expected, "\n");
+               print("error: found ", c, "; expected ", expected, "\n")
+               panic("fail")
        }
 }
 
@@ -96,24 +97,24 @@ func check(x *Number, expected int) {
 // Test basic functionality
 
 func verify() {
-       check(zero(), 0);
-       check(add1(zero()), 1);
-       check(gen(10), 10);
-
-       check(add(gen(3), zero()), 3);
-       check(add(zero(), gen(4)), 4);
-       check(add(gen(3), gen(4)), 7);
-
-       check(mul(zero(), zero()), 0);
-       check(mul(gen(3), zero()), 0);
-       check(mul(zero(), gen(4)), 0);
-       check(mul(gen(3), add1(zero())), 3);
-       check(mul(add1(zero()), gen(4)), 4);
-       check(mul(gen(3), gen(4)), 12);
-
-       check(fact(zero()), 1);
-       check(fact(add1(zero())), 1);
-       check(fact(gen(5)), 120);
+       check(zero(), 0)
+       check(add1(zero()), 1)
+       check(gen(10), 10)
+
+       check(add(gen(3), zero()), 3)
+       check(add(zero(), gen(4)), 4)
+       check(add(gen(3), gen(4)), 7)
+
+       check(mul(zero(), zero()), 0)
+       check(mul(gen(3), zero()), 0)
+       check(mul(zero(), gen(4)), 0)
+       check(mul(gen(3), add1(zero())), 3)
+       check(mul(add1(zero()), gen(4)), 4)
+       check(mul(gen(3), gen(4)), 12)
+
+       check(fact(zero()), 1)
+       check(fact(add1(zero())), 1)
+       check(fact(gen(5)), 120)
 }
 
 
@@ -123,9 +124,8 @@ func verify() {
 
 func main() {
 
-       verify();
+       verify()
        for i := 0; i <= 9; i++ {
-               print(i, "! = ", count(fact(gen(i))), "\n");
+               print(i, "! = ", count(fact(gen(i))), "\n")
        }
 }
-
index 16f5a571433ca8c8345462fef5b3411efdc58560..28408abc23aba228772d324c53921a960fdd7fbd 100644 (file)
@@ -6,74 +6,72 @@
 
 package main
 
-var    a,b,c,d,e,f,g,h,i int;
+var a, b, c, d, e, f, g, h, i int
 
-func
-printit() {
-       println(a,b,c,d,e,f,g,h,i);
+func printit() {
+       println(a, b, c, d, e, f, g, h, i)
 }
 
-func
-testit(permuteok bool) bool {
+func testit(permuteok bool) bool {
        if a+b+c+d+e+f+g+h+i != 45 {
-               print("sum does not add to 45\n");
-               printit();
-               return false;
+               print("sum does not add to 45\n")
+               printit()
+               return false
        }
-       return  permuteok ||
+       return permuteok ||
                a == 1 &&
-               b == 2 &&
-               c == 3 &&
-               d == 4 &&
-               e == 5 &&
-               f == 6 &&
-               g == 7 &&
-               h == 8 &&
-               i == 9;
+                       b == 2 &&
+                       c == 3 &&
+                       d == 4 &&
+                       e == 5 &&
+                       f == 6 &&
+                       g == 7 &&
+                       h == 8 &&
+                       i == 9
 }
 
-func
-swap(x, y int) (u, v int) {
+func swap(x, y int) (u, v int) {
        return y, x
 }
 
-func
-main() {
-       a = 1;
-       b = 2;
-       c = 3;
-       d = 4;
-       e = 5;
-       f = 6;
-       g = 7;
-       h = 8;
-       i = 9;
+func main() {
+       a = 1
+       b = 2
+       c = 3
+       d = 4
+       e = 5
+       f = 6
+       g = 7
+       h = 8
+       i = 9
 
-       if !testit(false) { panic("init val\n"); }
+       if !testit(false) {
+               panic("init val\n")
+       }
 
-       for z:=0; z<100; z++ {
-               a,b,c,d, e,f,g,h,i = b,c,d,a, i,e,f,g,h;
+       for z := 0; z < 100; z++ {
+               a, b, c, d, e, f, g, h, i = b, c, d, a, i, e, f, g, h
 
                if !testit(z%20 != 19) {
-                       print("on ", z, "th iteration\n");
-                       printit();
-                       panic();
+                       print("on ", z, "th iteration\n")
+                       printit()
+                       panic("fail")
                }
        }
 
        if !testit(false) {
-               print("final val\n");
-               printit();
-               panic();
+               print("final val\n")
+               printit()
+               panic("fail")
        }
 
-       a, b = swap(1, 2);
+       a, b = swap(1, 2)
        if a != 2 || b != 1 {
-               panic("bad swap");
+               panic("bad swap")
        }
 
-       a, b = swap(swap(a, b));
+       a, b = swap(swap(a, b))
        if a != 2 || b != 1 {
-               panic("bad swap");
+               panic("bad swap")
        }
 }
index 879cfb98304b31caa1241a13a64e6c138e1188de..9613b166f18bb15cd1491f468775f2fa869cb180 100644 (file)
@@ -9,76 +9,75 @@ package main
 import "fmt"
 
 const (
-       a = iota;
-       b;
-       c;
-       d;
-       e;
+       a = iota
+       b
+       c
+       d
+       e
 )
 
-var x = []int{1,2,3}
+var x = []int{1, 2, 3}
 
 func f(x int, len *byte) {
-       *len = byte(x);
+       *len = byte(x)
 }
 
 func whatis(x interface{}) string {
        switch xx := x.(type) {
        default:
-               return fmt.Sprint("default ", xx);
+               return fmt.Sprint("default ", xx)
        case int, int8, int16, int32:
-               return fmt.Sprint("signed ", xx);
+               return fmt.Sprint("signed ", xx)
        case int64:
-               return fmt.Sprint("signed64 ", int64(xx));
+               return fmt.Sprint("signed64 ", int64(xx))
        case uint, uint8, uint16, uint32:
-               return fmt.Sprint("unsigned ", xx);
+               return fmt.Sprint("unsigned ", xx)
        case uint64:
-               return fmt.Sprint("unsigned64 ", uint64(xx));
+               return fmt.Sprint("unsigned64 ", uint64(xx))
        case nil:
-               return fmt.Sprint("nil ", xx);
+               return fmt.Sprint("nil ", xx)
        }
-       panic("not reached");
+       panic("not reached")
 }
 
 func whatis1(x interface{}) string {
-       xx := x;
+       xx := x
        switch xx.(type) {
        default:
-               return fmt.Sprint("default ", xx);
+               return fmt.Sprint("default ", xx)
        case int, int8, int16, int32:
-               return fmt.Sprint("signed ", xx);
+               return fmt.Sprint("signed ", xx)
        case int64:
-               return fmt.Sprint("signed64 ", xx.(int64));
+               return fmt.Sprint("signed64 ", xx.(int64))
        case uint, uint8, uint16, uint32:
-               return fmt.Sprint("unsigned ", xx);
+               return fmt.Sprint("unsigned ", xx)
        case uint64:
-               return fmt.Sprint("unsigned64 ", xx.(uint64));
+               return fmt.Sprint("unsigned64 ", xx.(uint64))
        case nil:
-               return fmt.Sprint("nil ", xx);
+               return fmt.Sprint("nil ", xx)
        }
-       panic("not reached");
+       panic("not reached")
 }
 
 func check(x interface{}, s string) {
-       w := whatis(x);
+       w := whatis(x)
        if w != s {
-               fmt.Println("whatis", x, "=>", w, "!=", s);
-               panic();
+               fmt.Println("whatis", x, "=>", w, "!=", s)
+               panic("fail")
        }
 
-       w = whatis1(x);
+       w = whatis1(x)
        if w != s {
-               fmt.Println("whatis1", x, "=>", w, "!=", s);
-               panic();
+               fmt.Println("whatis1", x, "=>", w, "!=", s)
+               panic("fail")
        }
 }
 
 func main() {
-       check(1, "signed 1");
-       check(uint(1), "unsigned 1");
-       check(int64(1), "signed64 1");
-       check(uint64(1), "unsigned64 1");
-       check(1.5, "default 1.5");
-       check(nil, "nil <nil>");
+       check(1, "signed 1")
+       check(uint(1), "unsigned 1")
+       check(int64(1), "signed64 1")
+       check(uint64(1), "unsigned64 1")
+       check(1.5, "default 1.5")
+       check(nil, "nil <nil>")
 }
-
index 004f9c01b2c69cff06443469d655062896c0f3de..c768777932ac8b9bb80d1f4defa7c63473da7289 100644 (file)
@@ -7,14 +7,23 @@
 package main
 
 func main() {
-       var x int = 1;
-       if x != 1 { panic("found ", x, ", expected 1\n"); }
+       var x int = 1
+       if x != 1 {
+               print("found ", x, ", expected 1\n")
+               panic("fail")
+       }
        {
-               var x int = x + 1;
-               if x != 2 { panic("found ", x, ", expected 2\n"); }
+               var x int = x + 1
+               if x != 2 {
+                       print("found ", x, ", expected 2\n")
+                       panic("fail")
+               }
        }
        {
-               x := x + 1;
-               if x != 2 { panic("found ", x, ", expected 2\n"); }
+               x := x + 1
+               if x != 2 {
+                       print("found ", x, ", expected 2\n")
+                       panic("fail")
+               }
        }
 }
index 5696c2aa5e8bbbca0e24c3dbb134e65902c66d36..ed5905da30cd2dda47763d248978dbd490539565 100644 (file)
@@ -10,42 +10,45 @@ import "container/vector"
 
 
 type S struct {
-       val int;
+       val int
 }
 
 
 func (p *S) Init(val int) *S {
-       p.val = val;
-       return p;
+       p.val = val
+       return p
 }
 
 
 func test0() {
-       v := new(vector.Vector);
+       v := new(vector.Vector)
        if v.Len() != 0 {
-               panic("len = ", v.Len(), "\n")
+               print("len = ", v.Len(), "\n")
+               panic("fail")
        }
 }
 
 
 func test1() {
-       var a [1000]*S;
+       var a [1000]*S
        for i := 0; i < len(a); i++ {
                a[i] = new(S).Init(i)
        }
 
-       v := new(vector.Vector);
+       v := new(vector.Vector)
        for i := 0; i < len(a); i++ {
-               v.Insert(0, a[i]);
+               v.Insert(0, a[i])
                if v.Len() != i+1 {
-                       panic("len = ", v.Len(), "\n")
+                       print("len = ", v.Len(), "\n")
+                       panic("fail")
                }
        }
 
        for i := 0; i < v.Len(); i++ {
-               x := v.At(i).(*S);
+               x := v.At(i).(*S)
                if x.val != v.Len()-i-1 {
-                       panic("expected ", i, ", found ", x.val, "\n")
+                       print("expected ", i, ", found ", x.val, "\n")
+                       panic("fail")
                }
        }
 
@@ -56,6 +59,6 @@ func test1() {
 
 
 func main() {
-       test0();
-       test1();
+       test0()
+       test1()
 }