diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/bench/Makefile | 14 | ||||
-rwxr-xr-x | test/bench/clean.bash | 4 | ||||
-rw-r--r-- | test/bench/timing.log | 82 | ||||
-rwxr-xr-x | test/bench/timing.sh | 3 | ||||
-rw-r--r-- | test/bugs/bug324.dir/main.go | 48 | ||||
-rw-r--r-- | test/bugs/bug324.dir/p.go | 15 | ||||
-rw-r--r-- | test/bugs/bug324.go | 8 | ||||
-rw-r--r-- | test/fixedbugs/bug001.go | 11 | ||||
-rw-r--r-- | test/fixedbugs/bug140.go | 4 | ||||
-rw-r--r-- | test/fixedbugs/bug1515.go | 20 | ||||
-rw-r--r-- | test/fixedbugs/bug219.go | 12 | ||||
-rw-r--r-- | test/fixedbugs/bug323.go (renamed from test/fixedbugs/bug322.go) | 0 | ||||
-rw-r--r-- | test/fixedbugs/bug325.go | 14 | ||||
-rw-r--r-- | test/golden.out | 3 | ||||
-rw-r--r-- | test/if.go | 12 | ||||
-rw-r--r-- | test/if1.go | 20 | ||||
-rw-r--r-- | test/init.go | 18 | ||||
-rw-r--r-- | test/ken/robif.go | 97 | ||||
-rw-r--r-- | test/syntax/if.go | 15 |
19 files changed, 247 insertions, 153 deletions
diff --git a/test/bench/Makefile b/test/bench/Makefile new file mode 100644 index 000000000..145fe0cea --- /dev/null +++ b/test/bench/Makefile @@ -0,0 +1,14 @@ +# 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. + +include ../../src/Make.inc + +all: + @echo "make clean or timing" + +timing: + ./timing.sh + +clean: + rm -f [568].out *.[568] diff --git a/test/bench/clean.bash b/test/bench/clean.bash deleted file mode 100755 index d56c0e394..000000000 --- a/test/bench/clean.bash +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -OS=568 -rm -f [$OS].out *.[$OS] diff --git a/test/bench/timing.log b/test/bench/timing.log index f2b6a1f40..a967f27d2 100644 --- a/test/bench/timing.log +++ b/test/bench/timing.log @@ -592,3 +592,85 @@ regex-dna 100000 gc regex-dna 6.80u 0.00s 6.81r gc regex-dna-parallel 6.82u 0.01s 2.75r gc_B regex-dna 6.69u 0.02s 6.70r + +Feb 15, 2011 + +# Improved GC, still single-threaded but more efficient + +fasta -n 25000000 + gcc -O2 fasta.c 3.40u 0.00s 3.40r + gccgo -O2 fasta.go 3.51u 0.00s 3.50r + gc fasta 3.66u 0.01s 3.66r + gc_B fasta 3.66u 0.00s 3.66r + +reverse-complement < output-of-fasta-25000000 + gcc -O2 reverse-complement.c 1.86u 1.29s 4.93r + gccgo -O2 reverse-complement.go 2.18u 0.41s 2.60r + gc reverse-complement 1.67u 0.48s 2.15r + gc_B reverse-complement 1.71u 0.45s 2.15r + +nbody -n 50000000 + gcc -O2 -lm nbody.c 21.64u 0.00s 21.64r + gccgo -O2 nbody.go 21.46u 0.00s 21.45r + gc nbody 29.07u 0.00s 29.06r + gc_B nbody 31.61u 0.00s 31.61r + +binary-tree 15 # too slow to use 20 + gcc -O2 binary-tree.c -lm 0.88u 0.00s 0.87r + gccgo -O2 binary-tree.go 2.74u 0.07s 2.81r + gccgo -O2 binary-tree-freelist.go 0.01u 0.00s 0.00r + gc binary-tree 4.22u 0.02s 4.24r + gc binary-tree-freelist 0.54u 0.02s 0.55r + +fannkuch 12 + gcc -O2 fannkuch.c 57.64u 0.00s 57.64r + gccgo -O2 fannkuch.go 65.79u 0.00s 65.82r + gccgo -O2 fannkuch-parallel.go 160.91u 0.02s 43.90r + gc fannkuch 126.36u 0.03s 126.53r + gc fannkuch-parallel 175.23u 0.04s 45.49r + gc_B fannkuch 89.23u 0.00s 89.24r + +regex-dna 100000 + gcc -O2 regex-dna.c -lpcre 0.77u 0.01s 0.80r + gccgo -O2 regex-dna.go 12.38u 0.10s 12.52r + gccgo -O2 regex-dna-parallel.go 43.96u 4.64s 15.11r + gc regex-dna 7.03u 0.01s 7.05r + gc regex-dna-parallel 6.85u 0.05s 2.70r + gc_B regex-dna 6.87u 0.02s 6.89r + +spectral-norm 5500 + gcc -O2 spectral-norm.c -lm 12.29u 0.00s 12.28r + gccgo -O2 spectral-norm.go 11.79u 0.00s 11.79r + gc spectral-norm 24.00u 0.02s 24.05r + gc_B spectral-norm 24.59u 0.01s 24.59r + +k-nucleotide 1000000 + gcc -O2 k-nucleotide.c 9.75u 0.07s 9.82r + gccgo -O2 k-nucleotide.go 8.92u 0.06s 8.98r + gccgo -O2 k-nucleotide-parallel.go 8.40u 0.04s 2.76r + gc k-nucleotide 17.01u 0.03s 17.04r + gc k-nucleotide-parallel 16.51u 0.08s 6.21r + gc_B k-nucleotide 16.94u 0.08s 17.02r + +mandelbrot 16000 + gcc -O2 mandelbrot.c 54.60u 0.00s 54.66r + gccgo -O2 mandelbrot.go 59.38u 0.00s 59.41r + gc mandelbrot 64.93u 0.04s 65.08r + gc_B mandelbrot 64.85u 0.03s 64.92r + +meteor 2098 + gcc -O2 meteor-contest.c 0.10u 0.01s 0.10r + gccgo -O2 meteor-contest.go 0.11u 0.00s 0.11r + gc meteor-contest 0.18u 0.00s 0.17r + gc_B meteor-contest 0.17u 0.00s 0.16r + +pidigits 10000 + gcc -O2 pidigits.c -lgmp 2.24u 0.00s 2.23r + gccgo -O2 pidigits.go 14.05u 0.00s 14.06r + gc pidigits 6.34u 0.05s 6.38r + gc_B pidigits 6.37u 0.02s 6.38r + +threadring 50000000 + gcc -O2 threadring.c 30.50u 258.05s 325.72r + gccgo -O2 threadring.go 92.87u 748.39s 728.46r + gc threadring 38.03u 0.01s 38.04r diff --git a/test/bench/timing.sh b/test/bench/timing.sh index fec39182c..473c9b312 100755 --- a/test/bench/timing.sh +++ b/test/bench/timing.sh @@ -123,7 +123,8 @@ regexdna() { runonly a.out 100000 > x runonly echo 'regex-dna 100000' run 'gcc -O2 regex-dna.c -lpcre' a.out <x -# run 'gccgo -O2 regex-dna.go' a.out <x # restore after regexp.FindIndex is in library + run 'gccgo -O2 regex-dna.go' a.out <x + run 'gccgo -O2 regex-dna-parallel.go' a.out <x run 'gc regex-dna' $O.out <x run 'gc regex-dna-parallel' $O.out <x run 'gc_B regex-dna' $O.out <x diff --git a/test/bugs/bug324.dir/main.go b/test/bugs/bug324.dir/main.go new file mode 100644 index 000000000..37f2a59e4 --- /dev/null +++ b/test/bugs/bug324.dir/main.go @@ -0,0 +1,48 @@ +// 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 ( + "./p" +) + +type Exported interface { + private() +} + +type Implementation struct{} + +func (p *Implementation) private() { println("main.Implementation.private()") } + + +func main() { + // nothing unusual here + var x Exported + x = new(Implementation) + x.private() // main.Implementation.private() + + // same here - should be and is legal + var px p.Exported + px = p.X + + // this assignment is correctly illegal: + // px.private undefined (cannot refer to unexported field or method private) + // px.private() + + // this assignment is correctly illegal: + // *Implementation does not implement p.Exported (missing p.private method) + // px = new(Implementation) + + // this assignment is correctly illegal: + // p.Exported does not implement Exported (missing private method) + // x = px + + // this assignment unexpectedly compiles and then executes + x = px.(Exported) // ERROR "does not implement" + + // this is a legitimate call, but because of the previous assignment, + // it invokes the method private in p! + x.private() // p.Implementation.private() +} diff --git a/test/bugs/bug324.dir/p.go b/test/bugs/bug324.dir/p.go new file mode 100644 index 000000000..d1e3b991a --- /dev/null +++ b/test/bugs/bug324.dir/p.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 p + +type Exported interface { + private() +} + +type Implementation struct{} + +func (p *Implementation) private() { println("p.Implementation.private()") } + +var X = new(Implementation) diff --git a/test/bugs/bug324.go b/test/bugs/bug324.go new file mode 100644 index 000000000..8b4e29200 --- /dev/null +++ b/test/bugs/bug324.go @@ -0,0 +1,8 @@ +// $G $D/$F.dir/p.go && errchk $G $D/$F.dir/main.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. + +// Test case for issue 1550 +ignored diff --git a/test/fixedbugs/bug001.go b/test/fixedbugs/bug001.go deleted file mode 100644 index 2df8791ff..000000000 --- a/test/fixedbugs/bug001.go +++ /dev/null @@ -1,11 +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 main() { - if {} // compiles; should be an error (must be an expression) -} diff --git a/test/fixedbugs/bug140.go b/test/fixedbugs/bug140.go index 33d1deb8a..298081663 100644 --- a/test/fixedbugs/bug140.go +++ b/test/fixedbugs/bug140.go @@ -7,8 +7,8 @@ package main func main() { - if {} else L1: ; - if {} else L2: main() ; + if true {} else L1: ; + if true {} else L2: main() ; } /* diff --git a/test/fixedbugs/bug1515.go b/test/fixedbugs/bug1515.go new file mode 100644 index 000000000..740252516 --- /dev/null +++ b/test/fixedbugs/bug1515.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. + +package main + +const ( + joao = "João" + jose = "José" +) + +func main() { + s1 := joao + s2 := jose + if (s1 < s2) != (joao < jose) { + panic("unequal") + } +} diff --git a/test/fixedbugs/bug219.go b/test/fixedbugs/bug219.go index 21361a2aa..966d3fcf3 100644 --- a/test/fixedbugs/bug219.go +++ b/test/fixedbugs/bug219.go @@ -12,8 +12,8 @@ func f(func()) int { return 0 } // bug219.go:16: syntax error near if func g1() { if x := f(func() { - if {} - }); { + if true {} + }); true { _ = x; } } @@ -21,8 +21,8 @@ func g1() { // this works func g2() { if x := f(func() { - //if {} - }); { + //if true {} + }); true { _ = x; } } @@ -30,9 +30,9 @@ func g2() { // this works func g3() { x := f(func() { - if {} + if true {} }); - if { + if true { _ = x; } } diff --git a/test/fixedbugs/bug322.go b/test/fixedbugs/bug323.go index bfb528318..bfb528318 100644 --- a/test/fixedbugs/bug322.go +++ b/test/fixedbugs/bug323.go diff --git a/test/fixedbugs/bug325.go b/test/fixedbugs/bug325.go new file mode 100644 index 000000000..23dbc8b3c --- /dev/null +++ b/test/fixedbugs/bug325.go @@ -0,0 +1,14 @@ +// 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 + +import "unsafe" + +func main() { + var x unsafe.Pointer + println(*x) // ERROR "invalid indirect.*unsafe.Pointer" +} diff --git a/test/golden.out b/test/golden.out index 7883973e0..cc699d450 100644 --- a/test/golden.out +++ b/test/golden.out @@ -164,3 +164,6 @@ bugs/bug322.dir/main.go:19: implicit assignment of unexported field 'x' of lib.T 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 + +=========== bugs/bug324.go +BUG: errchk: command succeeded unexpectedly diff --git a/test/if.go b/test/if.go index db1fe8b79..c1bb69d27 100644 --- a/test/if.go +++ b/test/if.go @@ -45,18 +45,6 @@ func main() { assertequal(count, 0, "if false one") count = 0 - if { - count = count + 1 - } - assertequal(count, 1, "if empty") - - count = 0 - if one := 1; true { - count = count + one - } - assertequal(count, 1, "if empty one") - - count = 0 if i5 < i7 { count = count + 1 } diff --git a/test/if1.go b/test/if1.go deleted file mode 100644 index 061c36411..000000000 --- a/test/if1.go +++ /dev/null @@ -1,20 +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 "os" - -func main() { - count := 7 - if one := 1; { - count = count + one - } - if count != 8 { - print(count, " should be 8\n") - os.Exit(1) - } -} diff --git a/test/init.go b/test/init.go new file mode 100644 index 000000000..b6c8c9706 --- /dev/null +++ b/test/init.go @@ -0,0 +1,18 @@ +// 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. + +package main + +import "runtime" + +func init() { +} + +func main() { + init() // ERROR "undefined: init" + runtime.init() // ERROR "unexported.*runtime\.init" + var _ = init // ERROR "undefined: init" +} diff --git a/test/ken/robif.go b/test/ken/robif.go deleted file mode 100644 index b6fe4e433..000000000 --- a/test/ken/robif.go +++ /dev/null @@ -1,97 +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 assertequal(is, shouldbe int, msg string) { - if is != shouldbe { - print("assertion fail" + msg + "\n"); - panic(1); - } -} - -func main() { - i5 := 5; - i7 := 7; - - var count int; - - count = 0; - if true { - count = count + 1; - } - assertequal(count, 1, "if true"); - - count = 0; - if false { - count = count + 1; - } - assertequal(count, 0, "if false"); - - count = 0; - if one := 1; true { - count = count + one; - } - assertequal(count, 1, "if true one"); - - count = 0; - if one := 1; false { - _ = one; - count = count + 1; - } - assertequal(count, 0, "if false one"); - - count = 0; - if { - count = count + 1; - } - assertequal(count, 1, "if empty"); - - count = 0; - if one := 1; { - count = count + one; - } - assertequal(count, 1, "if empty one"); - - count = 0; - if i5 < i7 { - count = count + 1; - } - assertequal(count, 1, "if cond"); - - count = 0; - if true { - count = count + 1; - } else - count = count - 1; - assertequal(count, 1, "if else true"); - - count = 0; - if false { - count = count + 1; - } else - count = count - 1; - assertequal(count, -1, "if else false"); - - count = 0; - if t:=1; false { - count = count + 1; - t := 7; - _ = t; - } else - count = count - t; - assertequal(count, -1, "if else false var"); - - count = 0; - t := 1; - if false { - count = count + 1; - t := 7; - _ = t; - } else - count = count - t; - assertequal(count, -1, "if else false var outside"); -} diff --git a/test/syntax/if.go b/test/syntax/if.go new file mode 100644 index 000000000..913d41885 --- /dev/null +++ b/test/syntax/if.go @@ -0,0 +1,15 @@ +// 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 + +func main() { + if { // ERROR "missing condition" + } + + if x(); { // ERROR "missing condition" + } +} |