From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- gcc/testsuite/go.test/test/chan/doubleselect.go | 84 +++ gcc/testsuite/go.test/test/chan/fifo.go | 57 ++ gcc/testsuite/go.test/test/chan/goroutines.go | 41 ++ gcc/testsuite/go.test/test/chan/nonblock.go | 232 ++++++++ gcc/testsuite/go.test/test/chan/perm.go | 57 ++ gcc/testsuite/go.test/test/chan/powser1.go | 709 +++++++++++++++++++++++ gcc/testsuite/go.test/test/chan/powser2.go | 722 ++++++++++++++++++++++++ gcc/testsuite/go.test/test/chan/select.go | 56 ++ gcc/testsuite/go.test/test/chan/select2.go | 48 ++ gcc/testsuite/go.test/test/chan/select3.go | 203 +++++++ gcc/testsuite/go.test/test/chan/sieve1.go | 54 ++ gcc/testsuite/go.test/test/chan/sieve2.go | 172 ++++++ 12 files changed, 2435 insertions(+) create mode 100644 gcc/testsuite/go.test/test/chan/doubleselect.go create mode 100644 gcc/testsuite/go.test/test/chan/fifo.go create mode 100644 gcc/testsuite/go.test/test/chan/goroutines.go create mode 100644 gcc/testsuite/go.test/test/chan/nonblock.go create mode 100644 gcc/testsuite/go.test/test/chan/perm.go create mode 100644 gcc/testsuite/go.test/test/chan/powser1.go create mode 100644 gcc/testsuite/go.test/test/chan/powser2.go create mode 100644 gcc/testsuite/go.test/test/chan/select.go create mode 100644 gcc/testsuite/go.test/test/chan/select2.go create mode 100644 gcc/testsuite/go.test/test/chan/select3.go create mode 100644 gcc/testsuite/go.test/test/chan/sieve1.go create mode 100644 gcc/testsuite/go.test/test/chan/sieve2.go (limited to 'gcc/testsuite/go.test/test/chan') diff --git a/gcc/testsuite/go.test/test/chan/doubleselect.go b/gcc/testsuite/go.test/test/chan/doubleselect.go new file mode 100644 index 000000000..592d2f54a --- /dev/null +++ b/gcc/testsuite/go.test/test/chan/doubleselect.go @@ -0,0 +1,84 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out + +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This test is designed to flush out the case where two cases of a select can +// both end up running. See http://codereview.appspot.com/180068. +package main + +import ( + "flag" + "runtime" +) + +var iterations *int = flag.Int("n", 100000, "number of iterations") + +// sender sends a counter to one of four different channels. If two +// cases both end up running in the same iteration, the same value will be sent +// to two different channels. +func sender(n int, c1, c2, c3, c4 chan<- int) { + defer close(c1) + defer close(c2) + + for i := 0; i < n; i++ { + select { + case c1 <- i: + case c2 <- i: + case c3 <- i: + case c4 <- i: + } + } +} + +// mux receives the values from sender and forwards them onto another channel. +// It would be simplier to just have sender's four cases all be the same +// channel, but this doesn't actually trigger the bug. +func mux(out chan<- int, in <-chan int) { + for { + v := <-in + if closed(in) { + close(out) + break + } + out <- v + } +} + +// recver gets a steam of values from the four mux's and checks for duplicates. +func recver(in <-chan int) { + seen := make(map[int]bool) + + for { + v := <-in + if closed(in) { + break + } + if _, ok := seen[v]; ok { + println("got duplicate value: ", v) + panic("fail") + } + seen[v] = true + } +} + +func main() { + runtime.GOMAXPROCS(2) + + c1 := make(chan int) + c2 := make(chan int) + c3 := make(chan int) + c4 := make(chan int) + cmux := make(chan int) + go sender(*iterations, c1, c2, c3, c4) + go mux(cmux, c1) + go mux(cmux, c2) + go mux(cmux, c3) + go mux(cmux, c4) + // We keep the recver because it might catch more bugs in the future. + // However, the result of the bug linked to at the top is that we'll + // end up panicing with: "throw: bad g->status in ready". + recver(cmux) + print("PASS\n") +} diff --git a/gcc/testsuite/go.test/test/chan/fifo.go b/gcc/testsuite/go.test/test/chan/fifo.go new file mode 100644 index 000000000..0dddfcaa0 --- /dev/null +++ b/gcc/testsuite/go.test/test/chan/fifo.go @@ -0,0 +1,57 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out + +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Verify that unbuffered channels act as pure fifos. + +package main + +import "os" + +const N = 10 + +func AsynchFifo() { + ch := make(chan int, N) + for i := 0; i < N; i++ { + ch <- i + } + for i := 0; i < N; i++ { + if <-ch != i { + print("bad receive\n") + os.Exit(1) + } + } +} + +func Chain(ch <-chan int, val int, in <-chan int, out chan<- int) { + <-in + if <-ch != val { + panic(val) + } + out <- 1 +} + +// thread together a daisy chain to read the elements in sequence +func SynchFifo() { + ch := make(chan int) + in := make(chan int) + start := in + for i := 0; i < N; i++ { + out := make(chan int) + go Chain(ch, i, in, out) + in = out + } + start <- 0 + for i := 0; i < N; i++ { + ch <- i + } + <-in +} + +func main() { + AsynchFifo() + SynchFifo() +} + diff --git a/gcc/testsuite/go.test/test/chan/goroutines.go b/gcc/testsuite/go.test/test/chan/goroutines.go new file mode 100644 index 000000000..d8f8803df --- /dev/null +++ b/gcc/testsuite/go.test/test/chan/goroutines.go @@ -0,0 +1,41 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out + +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// make a lot of goroutines, threaded together. +// tear them down cleanly. + +package main + +import ( + "os" + "strconv" +) + +func f(left, right chan int) { + left <- <-right +} + +func main() { + var n = 10000 + if len(os.Args) > 1 { + var err os.Error + n, err = strconv.Atoi(os.Args[1]) + if err != nil { + print("bad arg\n") + os.Exit(1) + } + } + leftmost := make(chan int) + right := leftmost + left := leftmost + for i := 0; i < n; i++ { + right = make(chan int) + go f(left, right) + left = right + } + go func(c chan int) { c <- 1 }(right) + <-leftmost +} diff --git a/gcc/testsuite/go.test/test/chan/nonblock.go b/gcc/testsuite/go.test/test/chan/nonblock.go new file mode 100644 index 000000000..52f04bfb1 --- /dev/null +++ b/gcc/testsuite/go.test/test/chan/nonblock.go @@ -0,0 +1,232 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out + +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Verify channel operations that test for blocking +// Use several sizes and types of operands + +package main + +import "runtime" +import "time" + +func i32receiver(c chan int32, strobe chan bool) { + if <-c != 123 { + panic("i32 value") + } + strobe <- true +} + +func i32sender(c chan int32, strobe chan bool) { + c <- 234 + strobe <- true +} + +func i64receiver(c chan int64, strobe chan bool) { + if <-c != 123456 { + panic("i64 value") + } + strobe <- true +} + +func i64sender(c chan int64, strobe chan bool) { + c <- 234567 + strobe <- true +} + +func breceiver(c chan bool, strobe chan bool) { + if !<-c { + panic("b value") + } + strobe <- true +} + +func bsender(c chan bool, strobe chan bool) { + c <- true + strobe <- true +} + +func sreceiver(c chan string, strobe chan bool) { + if <-c != "hello" { + panic("s value") + } + strobe <- true +} + +func ssender(c chan string, strobe chan bool) { + c <- "hello again" + strobe <- true +} + +var ticker = time.Tick(10 * 1000) // 10 us +func sleep() { + <-ticker + <-ticker + runtime.Gosched() + runtime.Gosched() + runtime.Gosched() +} + +const maxTries = 10000 // Up to 100ms per test. + +func main() { + var i32 int32 + var i64 int64 + var b bool + var s string + var ok 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) + try := 0 + for !(c32 <- 123) { + try++ + if try > maxTries { + println("i32receiver buffer=", buffer) + panic("fail") + } + sleep() + } + <-sync + + go i32sender(c32, sync) + if buffer > 0 { + <-sync + } + try = 0 + for i32, ok = <-c32; !ok; i32, ok = <-c32 { + try++ + if try > maxTries { + println("i32sender buffer=", buffer) + panic("fail") + } + sleep() + } + if i32 != 234 { + panic("i32sender value") + } + if buffer == 0 { + <-sync + } + + go i64receiver(c64, sync) + try = 0 + for !(c64 <- 123456) { + try++ + if try > maxTries { + panic("i64receiver") + } + sleep() + } + <-sync + + go i64sender(c64, sync) + if buffer > 0 { + <-sync + } + try = 0 + for i64, ok = <-c64; !ok; i64, ok = <-c64 { + try++ + if try > maxTries { + panic("i64sender") + } + sleep() + } + if i64 != 234567 { + panic("i64sender value") + } + if buffer == 0 { + <-sync + } + + go breceiver(cb, sync) + try = 0 + for !(cb <- true) { + try++ + if try > maxTries { + panic("breceiver") + } + sleep() + } + <-sync + + go bsender(cb, sync) + if buffer > 0 { + <-sync + } + try = 0 + for b, ok = <-cb; !ok; b, ok = <-cb { + try++ + if try > maxTries { + panic("bsender") + } + sleep() + } + if !b { + panic("bsender value") + } + if buffer == 0 { + <-sync + } + + go sreceiver(cs, sync) + try = 0 + for !(cs <- "hello") { + try++ + if try > maxTries { + panic("sreceiver") + } + sleep() + } + <-sync + + go ssender(cs, sync) + if buffer > 0 { + <-sync + } + try = 0 + for s, ok = <-cs; !ok; s, ok = <-cs { + try++ + if try > maxTries { + panic("ssender") + } + sleep() + } + if s != "hello again" { + panic("ssender value") + } + if buffer == 0 { + <-sync + } + } + print("PASS\n") +} diff --git a/gcc/testsuite/go.test/test/chan/perm.go b/gcc/testsuite/go.test/test/chan/perm.go new file mode 100644 index 000000000..d08c03519 --- /dev/null +++ b/gcc/testsuite/go.test/test/chan/perm.go @@ -0,0 +1,57 @@ +// errchk $G -e $D/$F.go + +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +var ( + cr <-chan int + cs chan<- int + c chan int +) + +func main() { + cr = c // ok + cs = c // ok + c = cr // ERROR "illegal types|incompatible|cannot" + c = cs // ERROR "illegal types|incompatible|cannot" + cr = cs // ERROR "illegal types|incompatible|cannot" + cs = cr // ERROR "illegal types|incompatible|cannot" + + c <- 0 // ok + ok := c <- 0 // ok + _ = ok + <-c // ok + x, ok := <-c // ok + _, _ = x, ok + + cr <- 0 // ERROR "send" + ok = cr <- 0 // ERROR "send" + _ = ok + <-cr // ok + x, ok = <-cr // ok + _, _ = x, ok + + cs <- 0 // ok + ok = cs <- 0 // ok + _ = ok + <-cs // ERROR "receive" + x, ok = <-cs // ERROR "receive" + _, _ = x, ok + + select { + case c <- 0: // ok + case x := <-c: // ok + _ = x + + case cr <- 0: // ERROR "send" + case x := <-cr: // ok + _ = x + + case cs <- 0: // ok + case x := <-cs: // ERROR "receive" + _ = x + } +} diff --git a/gcc/testsuite/go.test/test/chan/powser1.go b/gcc/testsuite/go.test/test/chan/powser1.go new file mode 100644 index 000000000..dc4ff5325 --- /dev/null +++ b/gcc/testsuite/go.test/test/chan/powser1.go @@ -0,0 +1,709 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out + +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Power series package +// A power series is a channel, along which flow rational +// coefficients. A denominator of zero signifies the end. +// Original code in Newsqueak by Doug McIlroy. +// See Squinting at Power Series by Doug McIlroy, +// http://www.cs.bell-labs.com/who/rsc/thread/squint.pdf + +package main + +import "os" + +type rat struct { + num, den int64 // numerator, denominator +} + +func (u rat) pr() { + if u.den==1 { + print(u.num) + } else { + print(u.num, "/", u.den) + } + print(" ") +} + +func (u rat) eq(c rat) bool { + return u.num == c.num && u.den == c.den +} + +type dch struct { + req chan int + dat chan rat + nam int +} + +type dch2 [2] *dch + +var chnames string +var chnameserial int +var seqno int + +func mkdch() *dch { + c := chnameserial % len(chnames) + chnameserial++ + d := new(dch) + d.req = make(chan int) + d.dat = make(chan rat) + d.nam = c + return d +} + +func mkdch2() *dch2 { + d2 := new(dch2) + d2[0] = mkdch() + d2[1] = mkdch() + return d2 +} + +// split reads a single demand channel and replicates its +// output onto two, which may be read at different rates. +// A process is created at first demand for a rat and dies +// after the rat has been sent to both outputs. + +// When multiple generations of split exist, the newest +// will service requests on one channel, which is +// always renamed to be out[0]; the oldest will service +// requests on the other channel, out[1]. All generations but the +// newest hold queued data that has already been sent to +// out[0]. When data has finally been sent to out[1], +// a signal on the release-wait channel tells the next newer +// generation to begin servicing out[1]. + +func dosplit(in *dch, out *dch2, wait chan int ) { + both := false // do not service both channels + + select { + case <-out[0].req: + + case <-wait: + both = true + select { + case <-out[0].req: + + case <-out[1].req: + out[0], out[1] = out[1], out[0] + } + } + + seqno++ + in.req <- seqno + release := make(chan int) + go dosplit(in, out, release) + dat := <-in.dat + out[0].dat <- dat + if !both { + <-wait + } + <-out[1].req + out[1].dat <- dat + release <- 0 +} + +func split(in *dch, out *dch2) { + release := make(chan int) + go dosplit(in, out, release) + release <- 0 +} + +func put(dat rat, out *dch) { + <-out.req + out.dat <- dat +} + +func get(in *dch) rat { + seqno++ + in.req <- seqno + return <-in.dat +} + +// Get one rat from each of n demand channels + +func getn(in []*dch) []rat { + n := len(in) + if n != 2 { panic("bad n in getn") } + req := new([2] chan int) + dat := new([2] chan rat) + out := make([]rat, 2) + var i int + var it rat + for i=0; i0; n-- { + seqno++ + + select { + case req[0] <- seqno: + dat[0] = in[0].dat + req[0] = nil + case req[1] <- seqno: + dat[1] = in[1].dat + req[1] = nil + case it = <-dat[0]: + out[0] = it + dat[0] = nil + case it = <-dat[1]: + out[1] = it + dat[1] = nil + } + } + return out +} + +// Get one rat from each of 2 demand channels + +func get2(in0 *dch, in1 *dch) []rat { + return getn([]*dch{in0, in1}) +} + +func copy(in *dch, out *dch) { + for { + <-out.req + out.dat <- get(in) + } +} + +func repeat(dat rat, out *dch) { + for { + put(dat, out) + } +} + +type PS *dch // power series +type PS2 *[2] PS // pair of power series + +var Ones PS +var Twos PS + +func mkPS() *dch { + return mkdch() +} + +func mkPS2() *dch2 { + return mkdch2() +} + +// Conventions +// Upper-case for power series. +// Lower-case for rationals. +// Input variables: U,V,... +// Output variables: ...,Y,Z + +// Integer gcd; needed for rational arithmetic + +func gcd (u, v int64) int64 { + if u < 0 { return gcd(-u, v) } + if u == 0 { return v } + return gcd(v%u, u) +} + +// Make a rational from two ints and from one int + +func i2tor(u, v int64) rat { + g := gcd(u,v) + var r rat + if v > 0 { + r.num = u/g + r.den = v/g + } else { + r.num = -u/g + r.den = -v/g + } + return r +} + +func itor(u int64) rat { + return i2tor(u, 1) +} + +var zero rat +var one rat + + +// End mark and end test + +var finis rat + +func end(u rat) int64 { + if u.den==0 { return 1 } + return 0 +} + +// Operations on rationals + +func add(u, v rat) rat { + g := gcd(u.den,v.den) + return i2tor(u.num*(v.den/g)+v.num*(u.den/g),u.den*(v.den/g)) +} + +func mul(u, v rat) rat { + g1 := gcd(u.num,v.den) + g2 := gcd(u.den,v.num) + var r rat + r.num = (u.num/g1)*(v.num/g2) + r.den = (u.den/g2)*(v.den/g1) + return r +} + +func neg(u rat) rat { + return i2tor(-u.num, u.den) +} + +func sub(u, v rat) rat { + return add(u, neg(v)) +} + +func inv(u rat) rat { // invert a rat + if u.num == 0 { panic("zero divide in inv") } + return i2tor(u.den, u.num) +} + +// print eval in floating point of PS at x=c to n terms +func evaln(c rat, U PS, n int) { + xn := float64(1) + x := float64(c.num)/float64(c.den) + val := float64(0) + for i:=0; i0; n-- { + u := get(U) + if end(u) != 0 { + done = true + } else { + u.pr() + } + } + print(("\n")) +} + +// Evaluate n terms of power series U at x=c +func eval(c rat, U PS, n int) rat { + if n==0 { return zero } + y := get(U) + if end(y) != 0 { return zero } + return add(y,mul(c,eval(c,U,n-1))) +} + +// Power-series constructors return channels on which power +// series flow. They start an encapsulated generator that +// puts the terms of the series on the channel. + +// Make a pair of power series identical to a given power series + +func Split(U PS) *dch2 { + UU := mkdch2() + go split(U,UU) + return UU +} + +// Add two power series +func Add(U, V PS) PS { + Z := mkPS() + go func() { + var uv []rat + for { + <-Z.req + uv = get2(U,V) + switch end(uv[0])+2*end(uv[1]) { + case 0: + Z.dat <- add(uv[0], uv[1]) + case 1: + Z.dat <- uv[1] + copy(V,Z) + case 2: + Z.dat <- uv[0] + copy(U,Z) + case 3: + Z.dat <- finis + } + } + }() + return Z +} + +// Multiply a power series by a constant +func Cmul(c rat,U PS) PS { + Z := mkPS() + go func() { + done := false + for !done { + <-Z.req + u := get(U) + if end(u) != 0 { + done = true + } else { + Z.dat <- mul(c,u) + } + } + Z.dat <- finis + }() + return Z +} + +// Subtract + +func Sub(U, V PS) PS { + return Add(U, Cmul(neg(one), V)) +} + +// Multiply a power series by the monomial x^n + +func Monmul(U PS, n int) PS { + Z := mkPS() + go func() { + for ; n>0; n-- { put(zero,Z) } + copy(U,Z) + }() + return Z +} + +// Multiply by x + +func Xmul(U PS) PS { + return Monmul(U,1) +} + +func Rep(c rat) PS { + Z := mkPS() + go repeat(c,Z) + return Z +} + +// Monomial c*x^n + +func Mon(c rat, n int) PS { + Z:=mkPS() + go func() { + if(c.num!=0) { + for ; n>0; n=n-1 { put(zero,Z) } + put(c,Z) + } + put(finis,Z) + }() + return Z +} + +func Shift(c rat, U PS) PS { + Z := mkPS() + go func() { + put(c,Z) + copy(U,Z) + }() + return Z +} + +// simple pole at 1: 1/(1-x) = 1 1 1 1 1 ... + +// Convert array of coefficients, constant term first +// to a (finite) power series + +/* +func Poly(a []rat) PS { + Z:=mkPS() + begin func(a []rat, Z PS) { + j:=0 + done:=0 + for j=len(a); !done&&j>0; j=j-1) + if(a[j-1].num!=0) done=1 + i:=0 + for(; i 1 { // print + print("Ones: "); printn(Ones, 10) + print("Twos: "); printn(Twos, 10) + print("Add: "); printn(Add(Ones, Twos), 10) + print("Diff: "); printn(Diff(Ones), 10) + print("Integ: "); printn(Integ(zero, Ones), 10) + print("CMul: "); printn(Cmul(neg(one), Ones), 10) + print("Sub: "); printn(Sub(Ones, Twos), 10) + print("Mul: "); printn(Mul(Ones, Ones), 10) + print("Exp: "); printn(Exp(Ones), 15) + print("MonSubst: "); printn(MonSubst(Ones, neg(one), 2), 10) + print("ATan: "); printn(Integ(zero, MonSubst(Ones, neg(one), 2)), 10) + } else { // test + check(Ones, one, 5, "Ones") + check(Add(Ones, Ones), itor(2), 0, "Add Ones Ones") // 1 1 1 1 1 + check(Add(Ones, Twos), itor(3), 0, "Add Ones Twos") // 3 3 3 3 3 + a := make([]rat, N) + d := Diff(Ones) + for i:=0; i < N; i++ { + a[i] = itor(int64(i+1)) + } + checka(d, a, "Diff") // 1 2 3 4 5 + in := Integ(zero, Ones) + a[0] = zero // integration constant + for i:=1; i < N; i++ { + a[i] = i2tor(1, int64(i)) + } + checka(in, a, "Integ") // 0 1 1/2 1/3 1/4 1/5 + check(Cmul(neg(one), Twos), itor(-2), 10, "CMul") // -1 -1 -1 -1 -1 + check(Sub(Ones, Twos), itor(-1), 0, "Sub Ones Twos") // -1 -1 -1 -1 -1 + m := Mul(Ones, Ones) + for i:=0; i < N; i++ { + a[i] = itor(int64(i+1)) + } + checka(m, a, "Mul") // 1 2 3 4 5 + e := Exp(Ones) + a[0] = itor(1) + a[1] = itor(1) + a[2] = i2tor(3,2) + a[3] = i2tor(13,6) + a[4] = i2tor(73,24) + a[5] = i2tor(167,40) + a[6] = i2tor(4051,720) + a[7] = i2tor(37633,5040) + a[8] = i2tor(43817,4480) + a[9] = i2tor(4596553,362880) + checka(e, a, "Exp") // 1 1 3/2 13/6 73/24 + at := Integ(zero, MonSubst(Ones, neg(one), 2)) + for c, i := 1, 0; i < N; i++ { + if i%2 == 0 { + a[i] = zero + } else { + a[i] = i2tor(int64(c), int64(i)) + c *= -1 + } + } + checka(at, a, "ATan") // 0 -1 0 -1/3 0 -1/5 +/* + t := Revert(Integ(zero, MonSubst(Ones, neg(one), 2))) + a[0] = zero + a[1] = itor(1) + a[2] = zero + a[3] = i2tor(1,3) + a[4] = zero + a[5] = i2tor(2,15) + a[6] = zero + a[7] = i2tor(17,315) + a[8] = zero + a[9] = i2tor(62,2835) + checka(t, a, "Tan") // 0 1 0 1/3 0 2/15 +*/ + } +} diff --git a/gcc/testsuite/go.test/test/chan/powser2.go b/gcc/testsuite/go.test/test/chan/powser2.go new file mode 100644 index 000000000..bc329270d --- /dev/null +++ b/gcc/testsuite/go.test/test/chan/powser2.go @@ -0,0 +1,722 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out + +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Power series package +// A power series is a channel, along which flow rational +// coefficients. A denominator of zero signifies the end. +// Original code in Newsqueak by Doug McIlroy. +// See Squinting at Power Series by Doug McIlroy, +// http://www.cs.bell-labs.com/who/rsc/thread/squint.pdf +// Like powser1.go but uses channels of interfaces. +// Has not been cleaned up as much as powser1.go, to keep +// it distinct and therefore a different test. + +package main + +import "os" + +type rat struct { + num, den int64 // numerator, denominator +} + +type item interface { + pr() + eq(c item) bool +} + +func (u *rat) pr(){ + if u.den==1 { + print(u.num) + } else { + print(u.num, "/", u.den) + } + print(" ") +} + +func (u *rat) eq(c item) bool { + c1 := c.(*rat) + return u.num == c1.num && u.den == c1.den +} + +type dch struct { + req chan int + dat chan item + nam int +} + +type dch2 [2] *dch + +var chnames string +var chnameserial int +var seqno int + +func mkdch() *dch { + c := chnameserial % len(chnames) + chnameserial++ + d := new(dch) + d.req = make(chan int) + d.dat = make(chan item) + d.nam = c + return d +} + +func mkdch2() *dch2 { + d2 := new(dch2) + d2[0] = mkdch() + d2[1] = mkdch() + return d2 +} + +// split reads a single demand channel and replicates its +// output onto two, which may be read at different rates. +// A process is created at first demand for an item and dies +// after the item has been sent to both outputs. + +// When multiple generations of split exist, the newest +// will service requests on one channel, which is +// always renamed to be out[0]; the oldest will service +// requests on the other channel, out[1]. All generations but the +// newest hold queued data that has already been sent to +// out[0]. When data has finally been sent to out[1], +// a signal on the release-wait channel tells the next newer +// generation to begin servicing out[1]. + +func dosplit(in *dch, out *dch2, wait chan int ){ + both := false // do not service both channels + + select { + case <-out[0].req: + + case <-wait: + both = true + select { + case <-out[0].req: + + case <-out[1].req: + out[0],out[1] = out[1], out[0] + } + } + + seqno++ + in.req <- seqno + release := make(chan int) + go dosplit(in, out, release) + dat := <-in.dat + out[0].dat <- dat + if !both { + <-wait + } + <-out[1].req + out[1].dat <- dat + release <- 0 +} + +func split(in *dch, out *dch2){ + release := make(chan int) + go dosplit(in, out, release) + release <- 0 +} + +func put(dat item, out *dch){ + <-out.req + out.dat <- dat +} + +func get(in *dch) *rat { + seqno++ + in.req <- seqno + return (<-in.dat).(*rat) +} + +// Get one item from each of n demand channels + +func getn(in []*dch) []item { + n:=len(in) + if n != 2 { panic("bad n in getn") } + req := make([] chan int, 2) + dat := make([] chan item, 2) + out := make([]item, 2) + var i int + var it item + for i=0; i0; n-- { + seqno++ + + select{ + case req[0] <- seqno: + dat[0] = in[0].dat + req[0] = nil + case req[1] <- seqno: + dat[1] = in[1].dat + req[1] = nil + case it = <-dat[0]: + out[0] = it + dat[0] = nil + case it = <-dat[1]: + out[1] = it + dat[1] = nil + } + } + return out +} + +// Get one item from each of 2 demand channels + +func get2(in0 *dch, in1 *dch) []item { + return getn([]*dch{in0, in1}) +} + +func copy(in *dch, out *dch){ + for { + <-out.req + out.dat <- get(in) + } +} + +func repeat(dat item, out *dch){ + for { + put(dat, out) + } +} + +type PS *dch // power series +type PS2 *[2] PS // pair of power series + +var Ones PS +var Twos PS + +func mkPS() *dch { + return mkdch() +} + +func mkPS2() *dch2 { + return mkdch2() +} + +// Conventions +// Upper-case for power series. +// Lower-case for rationals. +// Input variables: U,V,... +// Output variables: ...,Y,Z + +// Integer gcd; needed for rational arithmetic + +func gcd (u, v int64) int64{ + if u < 0 { return gcd(-u, v) } + if u == 0 { return v } + return gcd(v%u, u) +} + +// Make a rational from two ints and from one int + +func i2tor(u, v int64) *rat{ + g := gcd(u,v) + r := new(rat) + if v > 0 { + r.num = u/g + r.den = v/g + } else { + r.num = -u/g + r.den = -v/g + } + return r +} + +func itor(u int64) *rat{ + return i2tor(u, 1) +} + +var zero *rat +var one *rat + + +// End mark and end test + +var finis *rat + +func end(u *rat) int64 { + if u.den==0 { return 1 } + return 0 +} + +// Operations on rationals + +func add(u, v *rat) *rat { + g := gcd(u.den,v.den) + return i2tor(u.num*(v.den/g)+v.num*(u.den/g),u.den*(v.den/g)) +} + +func mul(u, v *rat) *rat{ + g1 := gcd(u.num,v.den) + g2 := gcd(u.den,v.num) + r := new(rat) + r.num =(u.num/g1)*(v.num/g2) + r.den = (u.den/g2)*(v.den/g1) + return r +} + +func neg(u *rat) *rat{ + return i2tor(-u.num, u.den) +} + +func sub(u, v *rat) *rat{ + return add(u, neg(v)) +} + +func inv(u *rat) *rat{ // invert a rat + if u.num == 0 { panic("zero divide in inv") } + return i2tor(u.den, u.num) +} + +// print eval in floating point of PS at x=c to n terms +func Evaln(c *rat, U PS, n int) { + xn := float64(1) + x := float64(c.num)/float64(c.den) + val := float64(0) + for i:=0; i0; n-- { + u := get(U) + if end(u) != 0 { + done = true + } else { + u.pr() + } + } + print(("\n")) +} + +func Print(U PS){ + Printn(U,1000000000) +} + +// Evaluate n terms of power series U at x=c +func eval(c *rat, U PS, n int) *rat{ + if n==0 { return zero } + y := get(U) + if end(y) != 0 { return zero } + return add(y,mul(c,eval(c,U,n-1))) +} + +// Power-series constructors return channels on which power +// series flow. They start an encapsulated generator that +// puts the terms of the series on the channel. + +// Make a pair of power series identical to a given power series + +func Split(U PS) *dch2{ + UU := mkdch2() + go split(U,UU) + return UU +} + +// Add two power series +func Add(U, V PS) PS{ + Z := mkPS() + go func(U, V, Z PS){ + var uv [] item + for { + <-Z.req + uv = get2(U,V) + switch end(uv[0].(*rat))+2*end(uv[1].(*rat)) { + case 0: + Z.dat <- add(uv[0].(*rat), uv[1].(*rat)) + case 1: + Z.dat <- uv[1] + copy(V,Z) + case 2: + Z.dat <- uv[0] + copy(U,Z) + case 3: + Z.dat <- finis + } + } + }(U, V, Z) + return Z +} + +// Multiply a power series by a constant +func Cmul(c *rat,U PS) PS{ + Z := mkPS() + go func(c *rat, U, Z PS){ + done := false + for !done { + <-Z.req + u := get(U) + if end(u) != 0 { + done = true + } else { + Z.dat <- mul(c,u) + } + } + Z.dat <- finis + }(c, U, Z) + return Z +} + +// Subtract + +func Sub(U, V PS) PS{ + return Add(U, Cmul(neg(one), V)) +} + +// Multiply a power series by the monomial x^n + +func Monmul(U PS, n int) PS{ + Z := mkPS() + go func(n int, U PS, Z PS){ + for ; n>0; n-- { put(zero,Z) } + copy(U,Z) + }(n, U, Z) + return Z +} + +// Multiply by x + +func Xmul(U PS) PS{ + return Monmul(U,1) +} + +func Rep(c *rat) PS{ + Z := mkPS() + go repeat(c,Z) + return Z +} + +// Monomial c*x^n + +func Mon(c *rat, n int) PS{ + Z:=mkPS() + go func(c *rat, n int, Z PS){ + if(c.num!=0) { + for ; n>0; n=n-1 { put(zero,Z) } + put(c,Z) + } + put(finis,Z) + }(c, n, Z) + return Z +} + +func Shift(c *rat, U PS) PS{ + Z := mkPS() + go func(c *rat, U, Z PS){ + put(c,Z) + copy(U,Z) + }(c, U, Z) + return Z +} + +// simple pole at 1: 1/(1-x) = 1 1 1 1 1 ... + +// Convert array of coefficients, constant term first +// to a (finite) power series + +/* +func Poly(a [] *rat) PS{ + Z:=mkPS() + begin func(a [] *rat, Z PS){ + j:=0 + done:=0 + for j=len(a); !done&&j>0; j=j-1) + if(a[j-1].num!=0) done=1 + i:=0 + for(; i 1 { // print + print("Ones: "); Printn(Ones, 10) + print("Twos: "); Printn(Twos, 10) + print("Add: "); Printn(Add(Ones, Twos), 10) + print("Diff: "); Printn(Diff(Ones), 10) + print("Integ: "); Printn(Integ(zero, Ones), 10) + print("CMul: "); Printn(Cmul(neg(one), Ones), 10) + print("Sub: "); Printn(Sub(Ones, Twos), 10) + print("Mul: "); Printn(Mul(Ones, Ones), 10) + print("Exp: "); Printn(Exp(Ones), 15) + print("MonSubst: "); Printn(MonSubst(Ones, neg(one), 2), 10) + print("ATan: "); Printn(Integ(zero, MonSubst(Ones, neg(one), 2)), 10) + } else { // test + check(Ones, one, 5, "Ones") + check(Add(Ones, Ones), itor(2), 0, "Add Ones Ones") // 1 1 1 1 1 + check(Add(Ones, Twos), itor(3), 0, "Add Ones Twos") // 3 3 3 3 3 + a := make([]*rat, N) + d := Diff(Ones) + for i:=0; i < N; i++ { + a[i] = itor(int64(i+1)) + } + checka(d, a, "Diff") // 1 2 3 4 5 + in := Integ(zero, Ones) + a[0] = zero // integration constant + for i:=1; i < N; i++ { + a[i] = i2tor(1, int64(i)) + } + checka(in, a, "Integ") // 0 1 1/2 1/3 1/4 1/5 + check(Cmul(neg(one), Twos), itor(-2), 10, "CMul") // -1 -1 -1 -1 -1 + check(Sub(Ones, Twos), itor(-1), 0, "Sub Ones Twos") // -1 -1 -1 -1 -1 + m := Mul(Ones, Ones) + for i:=0; i < N; i++ { + a[i] = itor(int64(i+1)) + } + checka(m, a, "Mul") // 1 2 3 4 5 + e := Exp(Ones) + a[0] = itor(1) + a[1] = itor(1) + a[2] = i2tor(3,2) + a[3] = i2tor(13,6) + a[4] = i2tor(73,24) + a[5] = i2tor(167,40) + a[6] = i2tor(4051,720) + a[7] = i2tor(37633,5040) + a[8] = i2tor(43817,4480) + a[9] = i2tor(4596553,362880) + checka(e, a, "Exp") // 1 1 3/2 13/6 73/24 + at := Integ(zero, MonSubst(Ones, neg(one), 2)) + for c, i := 1, 0; i < N; i++ { + if i%2 == 0 { + a[i] = zero + } else { + a[i] = i2tor(int64(c), int64(i)) + c *= -1 + } + } + checka(at, a, "ATan"); // 0 -1 0 -1/3 0 -1/5 +/* + t := Revert(Integ(zero, MonSubst(Ones, neg(one), 2))) + a[0] = zero + a[1] = itor(1) + a[2] = zero + a[3] = i2tor(1,3) + a[4] = zero + a[5] = i2tor(2,15) + a[6] = zero + a[7] = i2tor(17,315) + a[8] = zero + a[9] = i2tor(62,2835) + checka(t, a, "Tan") // 0 1 0 1/3 0 2/15 +*/ + } +} diff --git a/gcc/testsuite/go.test/test/chan/select.go b/gcc/testsuite/go.test/test/chan/select.go new file mode 100644 index 000000000..be4eb3f42 --- /dev/null +++ b/gcc/testsuite/go.test/test/chan/select.go @@ -0,0 +1,56 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out + +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +var counter uint +var shift uint + +func GetValue() uint { + counter++ + return 1 << shift +} + +func Send(a, b chan uint) int { + var i int + +LOOP: + for { + select { + case a <- GetValue(): + i++ + a = nil + case b <- GetValue(): + i++ + b = nil + default: + break LOOP + } + shift++ + } + return i +} + +func main() { + a := make(chan uint, 1) + b := make(chan uint, 1) + if v := Send(a, b); v != 2 { + println("Send returned", v, "!= 2") + panic("fail") + } + if av, bv := <-a, <-b; av|bv != 3 { + println("bad values", av, bv) + panic("fail") + } + if v := Send(a, nil); v != 1 { + println("Send returned", v, "!= 1") + panic("fail") + } + if counter != 10 { + println("counter is", counter, "!= 10") + panic("fail") + } +} diff --git a/gcc/testsuite/go.test/test/chan/select2.go b/gcc/testsuite/go.test/test/chan/select2.go new file mode 100644 index 000000000..e24c51ed1 --- /dev/null +++ b/gcc/testsuite/go.test/test/chan/select2.go @@ -0,0 +1,48 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out + +// Copyright 2010 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import "runtime" + +func sender(c chan int, n int) { + for i := 0; i < n; i++ { + c <- 1 + } +} + +func receiver(c, dummy chan int, n int) { + for i := 0; i < n; i++ { + select { + case <-c: + // nothing + case <-dummy: + panic("dummy") + } + } +} + +func main() { + runtime.MemProfileRate = 0 + + c := make(chan int) + dummy := make(chan int) + + // warm up + go sender(c, 100000) + receiver(c, dummy, 100000) + runtime.GC() + runtime.MemStats.Alloc = 0 + + // second time shouldn't increase footprint by much + go sender(c, 100000) + receiver(c, dummy, 100000) + runtime.GC() + + if runtime.MemStats.Alloc > 1e5 { + println("BUG: too much memory for 100,000 selects:", runtime.MemStats.Alloc) + } +} diff --git a/gcc/testsuite/go.test/test/chan/select3.go b/gcc/testsuite/go.test/test/chan/select3.go new file mode 100644 index 000000000..a1a2ef50b --- /dev/null +++ b/gcc/testsuite/go.test/test/chan/select3.go @@ -0,0 +1,203 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out + +// Copyright 2010 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Tests verifying the semantics of the select statement +// for basic empty/non-empty cases. + +package main + +import "time" + +const always = "function did not" +const never = "function did" + + +func unreachable() { + panic("control flow shouldn't reach here") +} + + +// Calls f and verifies that f always/never panics depending on signal. +func testPanic(signal string, f func()) { + defer func() { + s := never + if recover() != nil { + s = always // f panicked + } + if s != signal { + panic(signal + " panic") + } + }() + f() +} + + +// Calls f and empirically verifies that f always/never blocks depending on signal. +func testBlock(signal string, f func()) { + c := make(chan string) + go func() { + f() + c <- never // f didn't block + }() + go func() { + time.Sleep(1e8) // 0.1s seems plenty long + c <- always // f blocked always + }() + if <-c != signal { + panic(signal + " block") + } +} + + +func main() { + const async = 1 // asynchronous channels + var nilch chan int + closedch := make(chan int) + close(closedch) + + // sending/receiving from a nil channel outside a select panics + testPanic(always, func() { + nilch <- 7 + }) + testPanic(always, func() { + <-nilch + }) + + // sending/receiving from a nil channel inside a select never panics + testPanic(never, func() { + select { + case nilch <- 7: + unreachable() + default: + } + }) + testPanic(never, func() { + select { + case <-nilch: + unreachable() + default: + } + }) + + // sending to an async channel with free buffer space never blocks + testBlock(never, func() { + ch := make(chan int, async) + ch <- 7 + }) + + // receiving (a small number of times) from a closed channel never blocks + testBlock(never, func() { + for i := 0; i < 10; i++ { + if <-closedch != 0 { + panic("expected zero value when reading from closed channel") + } + } + }) + + // sending (a small number of times) to a closed channel is not specified + // but the current implementation doesn't block: test that different + // implementations behave the same + testBlock(never, func() { + for i := 0; i < 10; i++ { + closedch <- 7 + } + }) + + // receiving from a non-ready channel always blocks + testBlock(always, func() { + ch := make(chan int) + <-ch + }) + + // empty selects always block + testBlock(always, func() { + select { + } + }) + + // selects with only nil channels always block + testBlock(always, func() { + select { + case <-nilch: + unreachable() + } + }) + testBlock(always, func() { + select { + case nilch <- 7: + unreachable() + } + }) + testBlock(always, func() { + select { + case <-nilch: + unreachable() + case nilch <- 7: + unreachable() + } + }) + + // selects with non-ready non-nil channels always block + testBlock(always, func() { + ch := make(chan int) + select { + case <-ch: + unreachable() + } + }) + + // selects with default cases don't block + testBlock(never, func() { + select { + default: + } + }) + testBlock(never, func() { + select { + case <-nilch: + unreachable() + default: + } + }) + testBlock(never, func() { + select { + case nilch <- 7: + unreachable() + default: + } + }) + + // selects with ready channels don't block + testBlock(never, func() { + ch := make(chan int, async) + select { + case ch <- 7: + default: + unreachable() + } + }) + testBlock(never, func() { + ch := make(chan int, async) + ch <- 7 + select { + case <-ch: + default: + unreachable() + } + }) + + // selects with closed channels don't block + testBlock(never, func() { + select { + case <-closedch: + } + }) + testBlock(never, func() { + select { + case closedch <- 7: + } + }) +} diff --git a/gcc/testsuite/go.test/test/chan/sieve1.go b/gcc/testsuite/go.test/test/chan/sieve1.go new file mode 100644 index 000000000..55076c925 --- /dev/null +++ b/gcc/testsuite/go.test/test/chan/sieve1.go @@ -0,0 +1,54 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out + +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Generate primes up to 100 using channels, checking the results. +// This sieve consists of a linear chain of divisibility filters, +// equivalent to trial-dividing each n by all primes p ≤ n. + +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'. + } +} + +// 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'. + } + } +} + +// 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. + for { + // Note that ch is different on each iteration. + 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} + for i := 0; i < len(a); i++ { + if x := <-primes; x != a[i] { + println(x, " != ", a[i]) + panic("fail") + } + } +} diff --git a/gcc/testsuite/go.test/test/chan/sieve2.go b/gcc/testsuite/go.test/test/chan/sieve2.go new file mode 100644 index 000000000..7f2ed9157 --- /dev/null +++ b/gcc/testsuite/go.test/test/chan/sieve2.go @@ -0,0 +1,172 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out + +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Generate primes up to 100 using channels, checking the results. +// This sieve is Eratosthenesque and only considers odd candidates. +// See discussion at . + +package main + +import ( + "container/heap" + "container/ring" + "container/vector" +) + +// Return a chan of odd numbers, starting from 5. +func odds() chan int { + out := make(chan int, 50) + go func() { + n := 5 + for { + out <- n + n += 2 + } + }() + return out +} + +// Return a chan of odd multiples of the prime number p, starting from p*p. +func multiples(p int) chan int { + out := make(chan int, 10) + go func() { + n := p * p + for { + out <- n + n += 2 * p + } + }() + return out +} + +type PeekCh struct { + head int + ch chan int +} + +// Heap of PeekCh, sorting by head values. +type PeekChHeap struct { + *vector.Vector +} + +func (h *PeekChHeap) Less(i, j int) bool { + return h.At(i).(*PeekCh).head < h.At(j).(*PeekCh).head +} + +// Return a channel to serve as a sending proxy to 'out'. +// Use a goroutine to receive values from 'out' and store them +// in an expanding buffer, so that sending to 'out' never blocks. +func sendproxy(out chan<- int) chan<- int { + proxy := make(chan int, 10) + go func() { + n := 16 // the allocated size of the circular queue + first := ring.New(n) + last := first + var c chan<- int + var e int + for { + c = out + if first == last { + // buffer empty: disable output + c = nil + } else { + e = first.Value.(int) + } + select { + case e = <-proxy: + last.Value = e + if last.Next() == first { + // buffer full: expand it + last.Link(ring.New(n)) + n *= 2 + } + last = last.Next() + case c <- e: + first = first.Next() + } + } + }() + return proxy +} + +// Return a chan int of primes. +func Sieve() chan int { + // The output values. + out := make(chan int, 10) + out <- 2 + out <- 3 + + // The channel of all composites to be eliminated in increasing order. + composites := make(chan int, 50) + + // The feedback loop. + primes := make(chan int, 10) + primes <- 3 + + // Merge channels of multiples of 'primes' into 'composites'. + go func() { + h := &PeekChHeap{new(vector.Vector)} + min := 15 + for { + m := multiples(<-primes) + head := <-m + for min < head { + composites <- min + minchan := heap.Pop(h).(*PeekCh) + min = minchan.head + minchan.head = <-minchan.ch + heap.Push(h, minchan) + } + for min == head { + minchan := heap.Pop(h).(*PeekCh) + min = minchan.head + minchan.head = <-minchan.ch + heap.Push(h, minchan) + } + composites <- head + heap.Push(h, &PeekCh{<-m, m}) + } + }() + + // Sieve out 'composites' from 'candidates'. + go func() { + // In order to generate the nth prime we only need multiples of + // primes ≤ sqrt(nth prime). Thus, the merging goroutine will + // receive from 'primes' much slower than this goroutine + // will send to it, making the buffer accumulate and block this + // goroutine from sending, causing a deadlock. The solution is to + // use a proxy goroutine to do automatic buffering. + primes := sendproxy(primes) + + candidates := odds() + p := <-candidates + + for { + c := <-composites + for p < c { + primes <- p + out <- p + p = <-candidates + } + if p == c { + p = <-candidates + } + } + }() + + return out +} + +func main() { + primes := Sieve() + 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] { + println(x, " != ", a[i]) + panic("fail") + } + } +} -- cgit v1.2.3