summaryrefslogtreecommitdiff
path: root/gcc/testsuite/go.test/test
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2011-10-26 23:57:58 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2011-10-26 23:57:58 +0000
commitfa5d125b5cfa5c935e46d27a2cbcd71ae37687ac (patch)
tree19d182df05ead7ff8ba7ee00a7d57555e1383fdf /gcc/testsuite/go.test/test
parente3d46e67996cf20ca3a75fccbb5a0007bfa3f992 (diff)
downloadgcc-fa5d125b5cfa5c935e46d27a2cbcd71ae37687ac.tar.gz
Update Go library to last weekly.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@180552 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/go.test/test')
-rw-r--r--gcc/testsuite/go.test/test/chan/sieve2.go38
-rw-r--r--gcc/testsuite/go.test/test/vectors.go64
2 files changed, 26 insertions, 76 deletions
diff --git a/gcc/testsuite/go.test/test/chan/sieve2.go b/gcc/testsuite/go.test/test/chan/sieve2.go
index 7f2ed915799..9a7ab15406c 100644
--- a/gcc/testsuite/go.test/test/chan/sieve2.go
+++ b/gcc/testsuite/go.test/test/chan/sieve2.go
@@ -13,7 +13,6 @@ package main
import (
"container/heap"
"container/ring"
- "container/vector"
)
// Return a chan of odd numbers, starting from 5.
@@ -47,13 +46,28 @@ type PeekCh struct {
ch chan int
}
-// Heap of PeekCh, sorting by head values.
-type PeekChHeap struct {
- *vector.Vector
-}
+// Heap of PeekCh, sorting by head values, satisfies Heap interface.
+type PeekChHeap []*PeekCh
func (h *PeekChHeap) Less(i, j int) bool {
- return h.At(i).(*PeekCh).head < h.At(j).(*PeekCh).head
+ return (*h)[i].head < (*h)[j].head
+}
+
+func (h *PeekChHeap) Swap(i, j int) {
+ (*h)[i], (*h)[j] = (*h)[j], (*h)[i]
+}
+
+func (h *PeekChHeap) Len() int {
+ return len(*h)
+}
+
+func (h *PeekChHeap) Pop() (v interface{}) {
+ *h, v = (*h)[:h.Len()-1], (*h)[h.Len()-1]
+ return
+}
+
+func (h *PeekChHeap) Push(v interface{}) {
+ *h = append(*h, v.(*PeekCh))
}
// Return a channel to serve as a sending proxy to 'out'.
@@ -108,26 +122,26 @@ func Sieve() chan int {
// Merge channels of multiples of 'primes' into 'composites'.
go func() {
- h := &PeekChHeap{new(vector.Vector)}
+ var h PeekChHeap
min := 15
for {
m := multiples(<-primes)
head := <-m
for min < head {
composites <- min
- minchan := heap.Pop(h).(*PeekCh)
+ minchan := heap.Pop(&h).(*PeekCh)
min = minchan.head
minchan.head = <-minchan.ch
- heap.Push(h, minchan)
+ heap.Push(&h, minchan)
}
for min == head {
- minchan := heap.Pop(h).(*PeekCh)
+ minchan := heap.Pop(&h).(*PeekCh)
min = minchan.head
minchan.head = <-minchan.ch
- heap.Push(h, minchan)
+ heap.Push(&h, minchan)
}
composites <- head
- heap.Push(h, &PeekCh{<-m, m})
+ heap.Push(&h, &PeekCh{<-m, m})
}
}()
diff --git a/gcc/testsuite/go.test/test/vectors.go b/gcc/testsuite/go.test/test/vectors.go
deleted file mode 100644
index ed5905da30c..00000000000
--- a/gcc/testsuite/go.test/test/vectors.go
+++ /dev/null
@@ -1,64 +0,0 @@
-// $G $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
-
-import "container/vector"
-
-
-type S struct {
- val int
-}
-
-
-func (p *S) Init(val int) *S {
- p.val = val
- return p
-}
-
-
-func test0() {
- v := new(vector.Vector)
- if v.Len() != 0 {
- print("len = ", v.Len(), "\n")
- panic("fail")
- }
-}
-
-
-func test1() {
- var a [1000]*S
- for i := 0; i < len(a); i++ {
- a[i] = new(S).Init(i)
- }
-
- v := new(vector.Vector)
- for i := 0; i < len(a); i++ {
- v.Insert(0, a[i])
- if v.Len() != i+1 {
- print("len = ", v.Len(), "\n")
- panic("fail")
- }
- }
-
- for i := 0; i < v.Len(); i++ {
- x := v.At(i).(*S)
- if x.val != v.Len()-i-1 {
- print("expected ", i, ", found ", x.val, "\n")
- panic("fail")
- }
- }
-
- for v.Len() > 10 {
- v.Delete(10)
- }
-}
-
-
-func main() {
- test0()
- test1()
-}