From 8b112a682e21e8a8bb5d9b1487c21167396e407e Mon Sep 17 00:00:00 2001 From: Rob Pike Date: Wed, 3 Sep 2008 13:21:05 -0700 Subject: update tests add commands to two new ken tests R=gri OCL=14751 CL=14751 --- test/bugs/bug027.go | 62 ------------------------------------------------ test/bugs/bug072.go | 11 --------- test/bugs/bug076.go | 21 ---------------- test/fixedbugs/bug027.go | 62 ++++++++++++++++++++++++++++++++++++++++++++++++ test/fixedbugs/bug072.go | 11 +++++++++ test/fixedbugs/bug076.go | 21 ++++++++++++++++ test/golden.out | 51 ++++++++++++++++++++++++--------------- test/ken/array.go | 9 ++++--- test/ken/shift.go | 1 - 9 files changed, 130 insertions(+), 119 deletions(-) delete mode 100644 test/bugs/bug027.go delete mode 100644 test/bugs/bug072.go delete mode 100644 test/bugs/bug076.go create mode 100644 test/fixedbugs/bug027.go create mode 100644 test/fixedbugs/bug072.go create mode 100644 test/fixedbugs/bug076.go diff --git a/test/bugs/bug027.go b/test/bugs/bug027.go deleted file mode 100644 index 33005a240..000000000 --- a/test/bugs/bug027.go +++ /dev/null @@ -1,62 +0,0 @@ -// $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 - -type Element interface { -} - -type Vector struct { - nelem int; - elem *[]Element; -} - -func New() *Vector { - v := new(Vector); - v.nelem = 0; - v.elem = new([10]Element); - return v; -} - -func (v *Vector) At(i int) Element { - return v.elem[i]; -} - -func (v *Vector) Insert(e Element) { - v.elem[v.nelem] = e; - v.nelem++; -} - -type I struct { val int; }; // BUG: can't be local; - -func main() { - i0 := new(I); i0.val = 0; - i1 := new(I); i1.val = 11; - i2 := new(I); i2.val = 222; - i3 := new(I); i3.val = 3333; - i4 := new(I); i4.val = 44444; - v := New(); - print("hi\n"); - v.Insert(i4); - v.Insert(i3); - v.Insert(i2); - v.Insert(i1); - v.Insert(i0); - for i := 0; i < v.nelem; i++ { - var x *I; - x = v.At(i); - print(i, " ", x.val, "\n"); // prints correct list - } - for i := 0; i < v.nelem; i++ { - print(i, " ", I(v.At(i)).val, "\n"); // always prints 5 - bad code - should be *I() - } -} -/* -bug027.go:50: illegal types for operand - (I{}) CONV ({}) -bug027.go:50: illegal types for operand - (I{}) CONV ({}) -*/ diff --git a/test/bugs/bug072.go b/test/bugs/bug072.go deleted file mode 100644 index f71179057..000000000 --- a/test/bugs/bug072.go +++ /dev/null @@ -1,11 +0,0 @@ -// errchk $G $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 - -func main() { - s := string(bug); // crash -} diff --git a/test/bugs/bug076.go b/test/bugs/bug076.go deleted file mode 100644 index 0828662c3..000000000 --- a/test/bugs/bug076.go +++ /dev/null @@ -1,21 +0,0 @@ -// $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 - -func f() { -exit: -} - - -func main() { -exit: // this should be legal (labels not properly scoped?) -} - -/* -uetli:~/Source/go/test/bugs gri$ 6g bug076.go -bug076.go:11: label redeclared: exit -*/ diff --git a/test/fixedbugs/bug027.go b/test/fixedbugs/bug027.go new file mode 100644 index 000000000..f7b33c04c --- /dev/null +++ b/test/fixedbugs/bug027.go @@ -0,0 +1,62 @@ +// $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 + +type Element interface { +} + +type Vector struct { + nelem int; + elem *[]Element; +} + +func New() *Vector { + v := new(Vector); + v.nelem = 0; + v.elem = new([10]Element); + return v; +} + +func (v *Vector) At(i int) Element { + return v.elem[i]; +} + +func (v *Vector) Insert(e Element) { + v.elem[v.nelem] = e; + v.nelem++; +} + +type I struct { val int; }; // BUG: can't be local; + +func main() { + i0 := new(I); i0.val = 0; + i1 := new(I); i1.val = 11; + i2 := new(I); i2.val = 222; + i3 := new(I); i3.val = 3333; + i4 := new(I); i4.val = 44444; + v := New(); + print("hi\n"); + v.Insert(i4); + v.Insert(i3); + v.Insert(i2); + v.Insert(i1); + v.Insert(i0); + for i := 0; i < v.nelem; i++ { + var x *I; + x = v.At(i); + print(i, " ", x.val, "\n"); // prints correct list + } + for i := 0; i < v.nelem; i++ { + print(i, " ", v.At(i).(*I).val, "\n"); + } +} +/* +bug027.go:50: illegal types for operand + (I{}) CONV ({}) +bug027.go:50: illegal types for operand + (I{}) CONV ({}) +*/ diff --git a/test/fixedbugs/bug072.go b/test/fixedbugs/bug072.go new file mode 100644 index 000000000..f71179057 --- /dev/null +++ b/test/fixedbugs/bug072.go @@ -0,0 +1,11 @@ +// errchk $G $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 + +func main() { + s := string(bug); // crash +} diff --git a/test/fixedbugs/bug076.go b/test/fixedbugs/bug076.go new file mode 100644 index 000000000..0828662c3 --- /dev/null +++ b/test/fixedbugs/bug076.go @@ -0,0 +1,21 @@ +// $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 + +func f() { +exit: +} + + +func main() { +exit: // this should be legal (labels not properly scoped?) +} + +/* +uetli:~/Source/go/test/bugs gri$ 6g bug076.go +bug076.go:11: label redeclared: exit +*/ diff --git a/test/golden.out b/test/golden.out index 652866e86..0fe042c3b 100644 --- a/test/golden.out +++ b/test/golden.out @@ -34,6 +34,14 @@ Hello World! =========== ken/rob2.go (defn foo (add 12 34)) +=========== ken/shift.go +ken/shift.go:50: stupid shift: 1025 +ken/shift.go:51: stupid shift: 1025 +ken/shift.go:57: stupid shift: 1025 +ken/shift.go:58: stupid shift: 1025 +ken/shift.go:64: stupid shift: 1025 +ken/shift.go:65: stupid shift: 1025 + =========== ken/simpprint.go hello world @@ -54,15 +62,6 @@ BUG should compile sys·printstring: main·sigs_I: not defined BUG: known to fail incorrectly -=========== bugs/bug027.go -bugs/bug027.go:50: illegal types for operand: CONV - (I{}) - ({INT32;}) -bugs/bug027.go:50: illegal types for operand: CONV - (I{}) - ({INT32;}) -BUG: known to fail incorrectly - =========== bugs/bug029.go BUG: known to succeed incorrectly @@ -73,12 +72,8 @@ BUG: compilation succeeds incorrectly BUG: compilation succeeds incorrectly =========== bugs/bug047.go -bugs/bug047.go:13: illegal types for operand: CONV - ({*STRING;FLOAT32;}) bugs/bug047.go:16: illegal types for operand: CONV (MAP[INT32]INT32) -bugs/bug047.go:13: illegal types for operand: CONV - ({*STRING;FLOAT32;}) bugs/bug047.go:16: illegal types for operand: CONV (MAP[INT32]INT32) BUG: known to fail incorrectly @@ -108,14 +103,12 @@ BUG: compilation should succeed bugs/bug068.go:6: unknown escape sequence: ' BUG: compilation should succeed -=========== bugs/bug072.go -bugs/bug072.go:6: bug: undefined -BUG: compiler crashes after error message - Bus error -Bus error $G $D/$F.go - =========== bugs/bug074.go +bugs/bug074.go:6: illegal types for operand: CONV + (*STRING) +bugs/bug074.go:6: illegal types for operand: CONV + (*STRING) BUG: compiler crashes - Bus error -Bus error $G $D/$F.go =========== bugs/bug075.go bugs/bug075.go:11: bad shape across assignment - cr=1 cl=2 @@ -180,6 +173,19 @@ fixedbugs/bug016.go:7: overflow converting constant to UINT32 =========== fixedbugs/bug025.go fixedbugs/bug025.go:7: variable exported but not defined: Foo +=========== fixedbugs/bug027.go +hi +0 44444 +1 3333 +2 222 +3 11 +4 0 +0 44444 +1 3333 +2 222 +3 11 +4 0 + =========== fixedbugs/bug035.go fixedbugs/bug035.go:6: var i redeclared in this block previous declaration at fixedbugs/bug035.go:5 @@ -210,6 +216,13 @@ inner loop top i 0 do break broke +=========== fixedbugs/bug072.go +fixedbugs/bug072.go:6: bug: undefined +fixedbugs/bug072.go:6: illegal types for operand: CONV + (*STRING) +fixedbugs/bug072.go:6: illegal types for operand: CONV + (*STRING) + =========== fixedbugs/bug073.go fixedbugs/bug073.go:8: illegal types for operand: LSH (INT32) diff --git a/test/ken/array.go b/test/ken/array.go index bd17f645c..0dac2a689 100644 --- a/test/ken/array.go +++ b/test/ken/array.go @@ -4,7 +4,6 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. - package main export func @@ -147,10 +146,10 @@ testfdfault() func main() { - print("testpdpd\n"); testpdpd(); - print("testpfpf\n"); testpfpf(); - print("testpdpf1\n"); testpdpf1(); - print("testpdpf2\n"); testpdpf2(); + testpdpd(); + testpfpf(); + testpdpf1(); + testpdpf2(); // print("testpdfault\n"); testpdfault(); // print("testfdfault\n"); testfdfault(); } diff --git a/test/ken/shift.go b/test/ken/shift.go index 180abbf3f..0be8da51b 100644 --- a/test/ken/shift.go +++ b/test/ken/shift.go @@ -4,7 +4,6 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. - package main var ians [18]int; -- cgit v1.2.3