diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/bugs/bug322.dir/lib.go | 15 | ||||
| -rw-r--r-- | test/bugs/bug322.dir/main.go | 47 | ||||
| -rw-r--r-- | test/bugs/bug322.go | 8 | ||||
| -rw-r--r-- | test/chan/select5.go | 2 | ||||
| -rw-r--r-- | test/fixedbugs/bug320.go | 45 | ||||
| -rw-r--r-- | test/fixedbugs/bug321.go | 30 | ||||
| -rw-r--r-- | test/fixedbugs/bug322.go | 20 | ||||
| -rw-r--r-- | test/golden.out | 6 | ||||
| -rwxr-xr-x | test/run | 4 | 
9 files changed, 173 insertions, 4 deletions
| diff --git a/test/bugs/bug322.dir/lib.go b/test/bugs/bug322.dir/lib.go new file mode 100644 index 000000000..0de56d3d6 --- /dev/null +++ b/test/bugs/bug322.dir/lib.go @@ -0,0 +1,15 @@ +// Copyright 2011 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 lib + +type T struct { +	x int  // non-exported field +} + +func (t T) M() { +} + +func (t *T) PM() { +} diff --git a/test/bugs/bug322.dir/main.go b/test/bugs/bug322.dir/main.go new file mode 100644 index 000000000..a99ed3bc2 --- /dev/null +++ b/test/bugs/bug322.dir/main.go @@ -0,0 +1,47 @@ +// Copyright 2011 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 "./lib" + +type I interface { +	M() +} + +type PI interface { +	PM() +} + +func main() { +	var t lib.T +	t.M() +	t.PM() + +	var i1 I = t +	i1.M() +	 +	// This combination is illegal because +	// PM requires a pointer receiver. +	// var pi1 PI = t +	// pi1.PM() + +	var pt = &t +	pt.M() +	pt.PM() + +	var i2 I = pt +	i2.M() + +	var pi2 PI = pt +	pi2.PM() +} + +/* +These should not be errors anymore: + +bug322.dir/main.go:19: implicit assignment of unexported field 'x' of lib.T in method receiver +bug322.dir/main.go:22: implicit assignment of unexported field 'x' of lib.T in assignment +bug322.dir/main.go:31: implicit assignment of unexported field 'x' of lib.T in method receiver +*/
\ No newline at end of file diff --git a/test/bugs/bug322.go b/test/bugs/bug322.go new file mode 100644 index 000000000..ad0e62dc8 --- /dev/null +++ b/test/bugs/bug322.go @@ -0,0 +1,8 @@ +// $G $D/$F.dir/lib.go && $G $D/$F.dir/main.go && $L main.$A && ./$A.out || echo BUG: fails incorrectly + +// Copyright 2011 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. + +// Test case for issue 1402. +ignored diff --git a/test/chan/select5.go b/test/chan/select5.go index 0678b8dab..e7ca9e015 100644 --- a/test/chan/select5.go +++ b/test/chan/select5.go @@ -49,7 +49,7 @@ func main() {  }  func run(t *template.Template, a interface{}, out io.Writer) { -	if err := t.Execute(a, out); err != nil { +	if err := t.Execute(out, a); err != nil {  		panic(err)  	}  } diff --git a/test/fixedbugs/bug320.go b/test/fixedbugs/bug320.go new file mode 100644 index 000000000..06d41f2ed --- /dev/null +++ b/test/fixedbugs/bug320.go @@ -0,0 +1,45 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out + +// Copyright 2011 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 + +func main() { +	c := make(chan int, 1) +	dummy := make(chan int) +	v := 0x12345678 +	for i := 0; i < 10; i++ { +		// 6g had a bug that caused select to pass &t to +		// selectrecv before allocating the memory for t, +		// which caused non-deterministic crashes. +		// This test looks for the bug by checking that the +		// value received actually ends up in t. +		// If the allocation happens after storing through +		// whatever garbage &t holds, the later reference +		// to t in the case body will use the new pointer and +		// not see the received value. +		v += 0x1020304 +		c <- v +		select { +		case t := <-c: +			go func() { +				f(t) +			}() +			escape(&t) +			if t != v { +				println(i, v, t) +				panic("wrong values") +			} +		case dummy <- 1: +		} +	} +} + +func escape(*int) { +} + +func f(int) { +} + diff --git a/test/fixedbugs/bug321.go b/test/fixedbugs/bug321.go new file mode 100644 index 000000000..d0595ff59 --- /dev/null +++ b/test/fixedbugs/bug321.go @@ -0,0 +1,30 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug321 + +// Copyright 2011 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. + +// Troublesome floating point constants. Issue 1463. + +package main + +import "fmt" + +func check(test string, got, want float64) bool { +	if got != want { +		fmt.Println(test, "got", got, "want", want) +		return false +	} +	return true +} + +func main() { +	good := true +	// http://www.exploringbinary.com/java-hangs-when-converting-2-2250738585072012e-308/ +	good = good && check("2.2250738585072012e-308", 2.2250738585072012e-308, 2.2250738585072014e-308) +	// http://www.exploringbinary.com/php-hangs-on-numeric-value-2-2250738585072011e-308/ +	good = good && check("2.2250738585072011e-308", 2.2250738585072011e-308, 2.225073858507201e-308) +	if !good { +		panic("fail") +	} +} diff --git a/test/fixedbugs/bug322.go b/test/fixedbugs/bug322.go new file mode 100644 index 000000000..bfb528318 --- /dev/null +++ b/test/fixedbugs/bug322.go @@ -0,0 +1,20 @@ +// errchk $G $D/$F.go + +// Copyright 2011 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 + +type T struct{} +type P *T + +func (t *T) Meth() {} +func (t T) Meth2() {} + +func main() { +	t := &T{} +	p := P(t) +	p.Meth()  // ERROR "undefined \(type P" +	p.Meth2() // ERROR "undefined \(type P" +}
\ No newline at end of file diff --git a/test/golden.out b/test/golden.out index 425771b4a..7883973e0 100644 --- a/test/golden.out +++ b/test/golden.out @@ -158,3 +158,9 @@ panic: interface conversion: interface is main.T, not main.T  == bugs/ + +=========== bugs/bug322.go +bugs/bug322.dir/main.go:19: implicit assignment of unexported field 'x' of lib.T in method receiver +bugs/bug322.dir/main.go:22: implicit assignment of unexported field 'x' of lib.T in assignment +bugs/bug322.dir/main.go:31: implicit assignment of unexported field 'x' of lib.T in method receiver +BUG: fails incorrectly @@ -42,9 +42,7 @@ TMP2FILE=/tmp/gotest2-$$-$USER  # don't run the machine out of memory: limit individual processes to 4GB.  # on thresher, 3GB suffices to run the tests; with 2GB, peano fails. -# Linux charges reserved but not mapped addresses to ulimit -v -# so we have to use ulimit -m. -ulimit -m 4000000 +ulimit -v 4000000  # no core files please  ulimit -c 0 | 
