diff options
author | Ingo Oeser <ingo@jimdo.com> | 2013-06-14 23:22:50 +0200 |
---|---|---|
committer | Ingo Oeser <ingo@jimdo.com> | 2013-06-14 23:22:50 +0200 |
commit | 09f84a75bc63a6316d575f531489d69ec8ade2e8 (patch) | |
tree | b74a4dcecf087639a6898acb55c71dae1e54b299 /test | |
parent | efcc50dfdc94c82ee0292bf71992ecb7c0123061 (diff) | |
download | golang-upstream/1.1.1.tar.gz |
Imported Upstream version 1.1.1upstream/1.1.1
Diffstat (limited to 'test')
-rw-r--r-- | test/fixedbugs/issue5244.go | 18 | ||||
-rw-r--r-- | test/fixedbugs/issue5470.dir/a.go | 27 | ||||
-rw-r--r-- | test/fixedbugs/issue5470.dir/b.go | 13 | ||||
-rw-r--r-- | test/fixedbugs/issue5470.go | 10 | ||||
-rw-r--r-- | test/fixedbugs/issue5493.go | 58 | ||||
-rw-r--r-- | test/fixedbugs/issue5515.go | 34 | ||||
-rw-r--r-- | test/fixedbugs/issue5607.go | 36 | ||||
-rw-r--r-- | test/fixedbugs/issue5614.dir/rethinkgo.go | 16 | ||||
-rw-r--r-- | test/fixedbugs/issue5614.dir/x.go | 7 | ||||
-rw-r--r-- | test/fixedbugs/issue5614.dir/y.go | 5 | ||||
-rw-r--r-- | test/fixedbugs/issue5614.go | 11 |
11 files changed, 235 insertions, 0 deletions
diff --git a/test/fixedbugs/issue5244.go b/test/fixedbugs/issue5244.go new file mode 100644 index 000000000..e26c7b8c4 --- /dev/null +++ b/test/fixedbugs/issue5244.go @@ -0,0 +1,18 @@ +// run + +// Copyright 2013 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. + +// Issue 5244: the init order computation uses the wrong +// order for top-level blank identifier assignments. +// The example used to panic because it tries calling a +// nil function instead of assigning to f before. + +package main + +var f = func() int { return 1 } +var _ = f() + g() +var g = func() int { return 2 } + +func main() {} diff --git a/test/fixedbugs/issue5470.dir/a.go b/test/fixedbugs/issue5470.dir/a.go new file mode 100644 index 000000000..302822d23 --- /dev/null +++ b/test/fixedbugs/issue5470.dir/a.go @@ -0,0 +1,27 @@ +// Copyright 2013 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 a + +type Foo interface { + Hi() string +} + +func Test1() Foo { return make(tst1) } + +type tst1 map[string]bool + +func (r tst1) Hi() string { return "Hi!" } + +func Test2() Foo { return make(tst2, 0) } + +type tst2 []string + +func (r tst2) Hi() string { return "Hi!" } + +func Test3() Foo { return make(tst3) } + +type tst3 chan string + +func (r tst3) Hi() string { return "Hi!" } diff --git a/test/fixedbugs/issue5470.dir/b.go b/test/fixedbugs/issue5470.dir/b.go new file mode 100644 index 000000000..0801c149c --- /dev/null +++ b/test/fixedbugs/issue5470.dir/b.go @@ -0,0 +1,13 @@ +// Copyright 2013 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 b + +import "./a" + +func main() { + a.Test1() + a.Test2() + a.Test3() +} diff --git a/test/fixedbugs/issue5470.go b/test/fixedbugs/issue5470.go new file mode 100644 index 000000000..6123c0983 --- /dev/null +++ b/test/fixedbugs/issue5470.go @@ -0,0 +1,10 @@ +// compiledir + +// Copyright 2013 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. + +// Issue 5470: exported data for inlining may miss +// the type argument of make. + +package ignored diff --git a/test/fixedbugs/issue5493.go b/test/fixedbugs/issue5493.go new file mode 100644 index 000000000..827281bdc --- /dev/null +++ b/test/fixedbugs/issue5493.go @@ -0,0 +1,58 @@ +// run + +// Copyright 2013 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" + "sync" + "sync/atomic" + "time" +) + +const N = 10 +var count int64 + +func run() error { + f1 := func() {} + f2 := func() { + func() { + f1() + }() + } + runtime.SetFinalizer(&f1, func(f *func()) { + atomic.AddInt64(&count, -1) + }) + go f2() + return nil +} + +func main() { + // Does not work on 32-bits due to partially conservative GC. + // Try to enable when we have fully precise GC. + if runtime.GOARCH != "amd64" { + return + } + count = N + var wg sync.WaitGroup + wg.Add(N) + for i := 0; i < N; i++ { + go func() { + run() + wg.Done() + }() + } + wg.Wait() + for i := 0; i < 2*N; i++ { + time.Sleep(10 * time.Millisecond) + runtime.GC() + } + if count != 0 { + println(count, "out of", N, "finalizer are called") + panic("not all finalizers are called") + } +} + diff --git a/test/fixedbugs/issue5515.go b/test/fixedbugs/issue5515.go new file mode 100644 index 000000000..053abf6f7 --- /dev/null +++ b/test/fixedbugs/issue5515.go @@ -0,0 +1,34 @@ +// run + +// Copyright 2013 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. + +// issue 5515: miscompilation doing inlining in generated method wrapper + +package main + +type T uint32 + +func main() { + b := make([]T, 8) + b[0] = 0xdeadbeef + rs := Slice(b) + sort(rs) +} + +type Slice []T + +func (s Slice) Swap(i, j int) { + tmp := s[i] + s[i] = s[j] + s[j] = tmp +} + +type Interface interface { + Swap(i, j int) +} + +func sort(data Interface) { + data.Swap(0, 4) +} diff --git a/test/fixedbugs/issue5607.go b/test/fixedbugs/issue5607.go new file mode 100644 index 000000000..785be7a2c --- /dev/null +++ b/test/fixedbugs/issue5607.go @@ -0,0 +1,36 @@ +// run + +// Copyright 2013 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. + +// Issue 5607: generation of init() function incorrectly +// uses initializers of blank variables inside closures. + +package main + +var Test = func() { + var mymap = map[string]string{"a": "b"} + + var innerTest = func() { + // Used to crash trying to compile this line as + // part of init() (funcdepth mismatch). + var _, x = mymap["a"] + println(x) + } + innerTest() +} + +var Test2 = func() { + // The following initializer should not be part of init() + // The compiler used to generate a call to Panic() in init(). + var _, x = Panic() + _ = x +} + +func Panic() (int, int) { + panic("omg") + return 1, 2 +} + +func main() {} diff --git a/test/fixedbugs/issue5614.dir/rethinkgo.go b/test/fixedbugs/issue5614.dir/rethinkgo.go new file mode 100644 index 000000000..4ae66d679 --- /dev/null +++ b/test/fixedbugs/issue5614.dir/rethinkgo.go @@ -0,0 +1,16 @@ +package rethinkgo + +type Session struct { +} + +func (s *Session) Run(query Exp) *int { return nil } + +type List []interface{} + +type Exp struct { + args []interface{} +} + +func (e Exp) UseOutdated(useOutdated bool) Exp { + return Exp{args: List{e, useOutdated}} +} diff --git a/test/fixedbugs/issue5614.dir/x.go b/test/fixedbugs/issue5614.dir/x.go new file mode 100644 index 000000000..7e4f3a7e6 --- /dev/null +++ b/test/fixedbugs/issue5614.dir/x.go @@ -0,0 +1,7 @@ +package x + +import "./rethinkgo" + +var S *rethinkgo.Session + + diff --git a/test/fixedbugs/issue5614.dir/y.go b/test/fixedbugs/issue5614.dir/y.go new file mode 100644 index 000000000..97cc93a79 --- /dev/null +++ b/test/fixedbugs/issue5614.dir/y.go @@ -0,0 +1,5 @@ +package y + +import "./x" + +var T = x.S diff --git a/test/fixedbugs/issue5614.go b/test/fixedbugs/issue5614.go new file mode 100644 index 000000000..f2518d2a0 --- /dev/null +++ b/test/fixedbugs/issue5614.go @@ -0,0 +1,11 @@ +// compiledir + +// Copyright 2013 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. + +// Issue 5614: exported data for inlining may miss +// named types when used in implicit conversion to +// their underlying type. + +package ignored |