diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/bench/timing.log | 8 | ||||
| -rw-r--r-- | test/ddd1.go | 1 | ||||
| -rw-r--r-- | test/fixedbugs/bug226.dir/y.go | 2 | ||||
| -rw-r--r-- | test/fixedbugs/bug322.dir/lib.go (renamed from test/bugs/bug322.dir/lib.go) | 0 | ||||
| -rw-r--r-- | test/fixedbugs/bug322.dir/main.go (renamed from test/bugs/bug322.dir/main.go) | 7 | ||||
| -rw-r--r-- | test/fixedbugs/bug322.go (renamed from test/bugs/bug322.go) | 0 | ||||
| -rw-r--r-- | test/fixedbugs/bug337.go | 19 | ||||
| -rw-r--r-- | test/fixedbugs/bug338.go | 22 | ||||
| -rw-r--r-- | test/fixedbugs/bug339.go | 20 | ||||
| -rw-r--r-- | test/fixedbugs/bug340.go | 17 | ||||
| -rw-r--r-- | test/fixedbugs/bug341.go | 22 | ||||
| -rw-r--r-- | test/fixedbugs/bug342.go | 24 | ||||
| -rw-r--r-- | test/fixedbugs/bug343.go | 33 | ||||
| -rw-r--r-- | test/golden.out | 5 | ||||
| -rw-r--r-- | test/shift1.go | 36 | ||||
| -rw-r--r-- | test/shift2.go | 42 | 
16 files changed, 245 insertions, 13 deletions
| diff --git a/test/bench/timing.log b/test/bench/timing.log index c658fa098..e66797982 100644 --- a/test/bench/timing.log +++ b/test/bench/timing.log @@ -844,3 +844,11 @@ NEW:  	gcc -O2 chameneosredux.c -lpthread	8.05u 63.43s 11.16r  	gccgo -O2 chameneosredux.go	82.95u 304.37s 207.64r  	gc chameneosredux	9.42u 0.00s 9.43r + +# May 13, 2011 +# after gc update to inline append when possible - 35% faster + +regex-dna 100000 +	gc regex-dna	3.94u 0.00s 3.95r +	gc regex-dna-parallel	4.15u 0.01s 1.63r +	gc_B regex-dna	4.01u 0.01s 4.02r diff --git a/test/ddd1.go b/test/ddd1.go index a0bc73814..96a358e1c 100644 --- a/test/ddd1.go +++ b/test/ddd1.go @@ -43,4 +43,5 @@ func bad(args ...int) {  	var x int  	_ = unsafe.Pointer(&x...)	// ERROR "[.][.][.]"  	_ = unsafe.Sizeof(x...)	// ERROR "[.][.][.]" +	_ = [...]byte("foo") // ERROR "[.][.][.]"  } diff --git a/test/fixedbugs/bug226.dir/y.go b/test/fixedbugs/bug226.dir/y.go index 01e8b7b43..c66d592b7 100644 --- a/test/fixedbugs/bug226.dir/y.go +++ b/test/fixedbugs/bug226.dir/y.go @@ -15,7 +15,7 @@ func f() {  	_ = x.T{};  	_ = x.T{Y:2}; -	ok1.M();	// ERROR "assignment.*T" +	ok1.M();  	bad1 := *ok;	// ERROR "assignment.*T"  	bad2 := ok1;	// ERROR "assignment.*T"  	*ok4 = ok1;	// ERROR "assignment.*T" diff --git a/test/bugs/bug322.dir/lib.go b/test/fixedbugs/bug322.dir/lib.go index 0de56d3d6..0de56d3d6 100644 --- a/test/bugs/bug322.dir/lib.go +++ b/test/fixedbugs/bug322.dir/lib.go diff --git a/test/bugs/bug322.dir/main.go b/test/fixedbugs/bug322.dir/main.go index 0ab5b32e4..f403c7d32 100644 --- a/test/bugs/bug322.dir/main.go +++ b/test/fixedbugs/bug322.dir/main.go @@ -38,10 +38,3 @@ func main() {  	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:32: implicit assignment of unexported field 'x' of lib.T in method receiver -*/ diff --git a/test/bugs/bug322.go b/test/fixedbugs/bug322.go index ad0e62dc8..ad0e62dc8 100644 --- a/test/bugs/bug322.go +++ b/test/fixedbugs/bug322.go diff --git a/test/fixedbugs/bug337.go b/test/fixedbugs/bug337.go new file mode 100644 index 000000000..62e310e72 --- /dev/null +++ b/test/fixedbugs/bug337.go @@ -0,0 +1,19 @@ +// 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. + +// Issue 1722. + +// Check that the error messages says  +//	bug337.go:16: len("foo") not used +// and not +//	bug337.go:16: 3 not used + +package main + +func main() { +	len("foo")	// ERROR "len" +} + diff --git a/test/fixedbugs/bug338.go b/test/fixedbugs/bug338.go new file mode 100644 index 000000000..c368a7fad --- /dev/null +++ b/test/fixedbugs/bug338.go @@ -0,0 +1,22 @@ +// $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. + +// Issue 1787. + +package main + +import "unsafe" + +const x = unsafe.Sizeof([8]byte{}) + +func main() { +	var b [x]int +	_ = b +} + +/* +bug338.go:14: array bound must be non-negative +*/ diff --git a/test/fixedbugs/bug339.go b/test/fixedbugs/bug339.go new file mode 100644 index 000000000..eac7c5ee6 --- /dev/null +++ b/test/fixedbugs/bug339.go @@ -0,0 +1,20 @@ +// $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. + +// Issue 1608. +// Size used to be -1000000000. + +package main + +import "unsafe" + +func main() { +	var a interface{} = 0 +	size := unsafe.Sizeof(a) +	if size != 2*unsafe.Sizeof((*int)(nil)) { +		println("wrong size: ", size) +	} +} diff --git a/test/fixedbugs/bug340.go b/test/fixedbugs/bug340.go new file mode 100644 index 000000000..461cc6cd4 --- /dev/null +++ b/test/fixedbugs/bug340.go @@ -0,0 +1,17 @@ +// 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. + +// Issue 1606. + +package main + +func main() { +	var x interface{} +	switch t := x.(type) { // ERROR "0 is not a type" +	case 0: +		t.x = 1 // ERROR "type interface \{ \}" +	} +} diff --git a/test/fixedbugs/bug341.go b/test/fixedbugs/bug341.go new file mode 100644 index 000000000..8ee52e1ef --- /dev/null +++ b/test/fixedbugs/bug341.go @@ -0,0 +1,22 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug341 + +// 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. + +// Used to panic because 8g was generating incorrect +// code for converting a negative float to a uint64. + +package main + +func main() { +	var x float32 = -2.5 + +	_ = uint64(x) +	_ = float32(0) +} +/* +panic: runtime error: floating point error + +[signal 0x8 code=0x6 addr=0x8048c64 pc=0x8048c64] +*/ diff --git a/test/fixedbugs/bug342.go b/test/fixedbugs/bug342.go new file mode 100644 index 000000000..0852cdd34 --- /dev/null +++ b/test/fixedbugs/bug342.go @@ -0,0 +1,24 @@ +// 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. + +// Issue 1871. + +package p + +type a interface { +	foo(x int) (x int) // ERROR "redeclared|redefinition" +} + +var b interface { +	bar(y int) (y int) // ERROR "redeclared|redefinition" +} + +/* +Previously: + +bug.go:1 x redclared in this block +    previous declaration at bug.go:1 +*/ diff --git a/test/fixedbugs/bug343.go b/test/fixedbugs/bug343.go new file mode 100644 index 000000000..efc87e3d7 --- /dev/null +++ b/test/fixedbugs/bug343.go @@ -0,0 +1,33 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug343 + +// 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. + +// issue 1900 + +package main + +func getArgs(data map[string]interface{}, keys ...string) map[string]string { +       ret := map[string]string{} +       var ok bool +       for _, k := range keys { +               ret[k], ok = data[k].(string) +               if !ok {} +       } +       return ret +} + +func main() { +	x := getArgs(map[string]interface{}{"x":"y"}, "x") +	if x["x"] != "y" { +		println("BUG bug343", x) +	} +} +	 + +/* +typecheck [1008592b0] +.   INDREG a(1) l(15) x(24) tc(2) runtime.ret G0 string +bug343.go:15: internal compiler error: typecheck INDREG +*/ diff --git a/test/golden.out b/test/golden.out index 725e8de44..4400e41dd 100644 --- a/test/golden.out +++ b/test/golden.out @@ -161,8 +161,3 @@ panic: interface conversion: interface is main.T, not main.T  0x0  == 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:32: implicit assignment of unexported field 'x' of lib.T in method receiver -BUG: fails incorrectly diff --git a/test/shift1.go b/test/shift1.go new file mode 100644 index 000000000..8fa48a03c --- /dev/null +++ b/test/shift1.go @@ -0,0 +1,36 @@ +// errchk $G -e $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. + +// Issue 1708, illegal cases. + +package p + +func f(x int) int         { return 0 } +func g(x interface{}) int { return 0 } +func h(x float64) int     { return 0 } + +// from the spec +var ( +	s uint    = 33 +	u         = 1.0 << s // ERROR "invalid operation" +	v float32 = 1 << s   // ERROR "invalid operation" +) + +// non-constant shift expressions +var ( +	e1       = g(2.0 << s) // ERROR "invalid operation" +	f1       = h(2 << s)   // ERROR "invalid operation" +	g1 int64 = 1.1 << s    // ERROR "truncated" +) + +// constant shift expressions +const c uint = 65 + +var ( +	a2 int = 1.0 << c    // ERROR "overflow" +	b2     = 1.0 << c    // ERROR "overflow" +	d2     = f(1.0 << c) // ERROR "overflow" +) diff --git a/test/shift2.go b/test/shift2.go new file mode 100644 index 000000000..ec4c7addc --- /dev/null +++ b/test/shift2.go @@ -0,0 +1,42 @@ +// $G $D/$F.go || echo BUG: shift2 + +// 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. + +// Issue 1708, legal cases. + +package p + +func f(x int) int         { return 0 } +func g(x interface{}) int { return 0 } +func h(x float64) int     { return 0 } + +// from the spec +var ( +	s uint  = 33 +	i       = 1 << s         // 1 has type int +	j int32 = 1 << s         // 1 has type int32; j == 0 +	k       = uint64(1 << s) // 1 has type uint64; k == 1<<33 +	m int   = 1.0 << s       // legal: 1.0 has type int +	w int64 = 1.0 << 33      // legal: 1.0<<33 is a constant shift expression +) + +// non-constant shift expressions +var ( +	a1 int = 2.0 << s    // typeof(2.0) is int in this context => legal shift +	d1     = f(2.0 << s) // typeof(2.0) is int in this context => legal shift +) + +// constant shift expressions +const c uint = 5 + +var ( +	a2 int     = 2.0 << c    // a2 == 64 (type int) +	b2         = 2.0 << c    // b2 == 64 (untyped integer) +	_          = f(b2)       // verify b2 has type int +	c2 float64 = 2 << c      // c2 == 64.0 (type float64) +	d2         = f(2.0 << c) // == f(64) +	e2         = g(2.0 << c) // == g(int(64)) +	f2         = h(2 << c)   // == h(float64(64.0)) +) | 
