test/[n-z]*.go: add documentation

R=golang-dev, bradfitz, r
CC=golang-dev
https://golang.org/cl/5700056
This commit is contained in:
Rob Pike 2012-02-24 11:48:19 +11:00
parent c05c3a9d11
commit 80a9783f84
26 changed files with 67 additions and 120 deletions

View file

@ -6,6 +6,7 @@
// Test that basic operations on named types are valid
// and preserve the type.
// Does not compile.
package main

View file

@ -4,7 +4,9 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Test illegal shifts.
// Issue 1708, illegal cases.
// Does not compile.
package p

View file

@ -4,7 +4,9 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Test legal shifts.
// Issue 1708, legal cases.
// Compiles but does not run.
package p

View file

@ -1,11 +1,12 @@
// build
// don't run it - goes forever
// 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.
// Test basic concurrency: the classic prime sieve.
// Do not run - loops forever.
package main
// Send the sequence 2, 3, 4, ... to channel 'ch'.

View file

@ -5,6 +5,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Test that a program can survive SIGCHLD.
package main
import "syscall"

View file

@ -4,6 +4,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Test simultaneous assignment.
package main
var a, b, c, d, e, f, g, h, i int

View file

@ -4,6 +4,9 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Test that many initializations can be done at link time and
// generate no executable init functions.
package p
// Should be no init func in the assembly.

View file

@ -4,6 +4,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Test unsafe.Sizeof, unsafe.Alignof, and unsafe.Offsetof all return uintptr.
package main
import "unsafe"

View file

@ -1,11 +1,13 @@
// build
// don't run it - produces too much output
// Copyright 2010 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 general operation by solving a peg solitaire game.
// A version of this is in the Go playground.
// Don't run it - produces too much output.
// This program solves the (English) peg solitaire board game.
// See also: http://en.wikipedia.org/wiki/Peg_solitaire

View file

@ -4,6 +4,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Test stack splitting code.
// Try to tickle stack splitting bugs by doing
// go, defer, and closure calls at different stack depths.

View file

@ -4,6 +4,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Test string literal syntax.
package main
import "os"

View file

@ -4,6 +4,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Test range over strings.
package main
import (

View file

@ -4,9 +4,9 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// zero length structs.
// used to not be evaluated.
// issue 2232.
// Test zero length structs.
// Used to not be evaluated.
// Issue 2232.
package main

View file

@ -4,8 +4,12 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Test switch statements.
package main
import "os"
func assert(cond bool, msg string) {
if !cond {
print("assertion fail: ", msg, "\n")
@ -279,4 +283,13 @@ func main() {
assert(false, "m should not be nil")
default:
}
i := 0
switch x := 5; {
case i < x:
os.Exit(0)
case i == x:
case i > x:
os.Exit(1)
}
}

View file

@ -1,20 +0,0 @@
// run
// 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() {
i := 0
switch x := 5; {
case i < x:
os.Exit(0)
case i == x:
case i > x:
os.Exit(1)
}
}

View file

@ -4,6 +4,9 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Verify that erroneous switch statements are detected by the compiler.
// Does not compile.
package main
type I interface {

View file

@ -1,92 +0,0 @@
// run
// 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
const a_const = 0
const (
pi = /* the usual */ 3.14159265358979323
e = 2.718281828
mask1 int = 1 << iota
mask2 = 1 << iota
mask3 = 1 << iota
mask4 = 1 << iota
)
type (
Empty interface{}
Point struct {
x, y int
}
Point2 Point
)
func (p *Point) Initialize(x, y int) *Point {
p.x, p.y = x, y
return p
}
func (p *Point) Distance() int {
return p.x*p.x + p.y*p.y
}
var (
x1 int
x2 int
u, v, w float32
)
func foo() {}
func min(x, y int) int {
if x < y {
return x
}
return y
}
func swap(x, y int) (u, v int) {
u = y
v = x
return
}
func control_structs() {
var p *Point = new(Point).Initialize(2, 3)
i := p.Distance()
var f float32 = 0.3
_ = f
for {
}
for {
}
for j := 0; j < i; j++ {
if i == 0 {
} else {
i = 0
}
var x float32
_ = x
}
foo: // a label
var j int
switch y := 0; true {
case i < y:
fallthrough
case i < j:
case i == 0, i == 1, i == j:
i++
i++
goto foo
default:
i = -+-+i
break
}
}
func main() {
}

View file

@ -4,6 +4,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Test simulating a Turing machine, sort of.
package main
// brainfuck

View file

@ -4,6 +4,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Test simple type switches, including chans, maps etc.
package main
import "os"

View file

@ -4,6 +4,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Test simple type switches on basic types.
package main
import "fmt"

View file

@ -4,6 +4,9 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Verify that various erroneous type switches are caught be the compiler.
// Does not compile.
package main
import "io"

View file

@ -4,6 +4,10 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Verify that erroneous type switches are caught be the compiler.
// Issue 2700, among other things.
// Does not compile.
package main
import (

View file

@ -4,7 +4,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Check line numbers in error messages.
// Test line numbers in error messages.
// Does not compile.
package main

View file

@ -4,6 +4,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Test UTF-8 in strings and character constants.
package main
import "unicode/utf8"

View file

@ -4,6 +4,9 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Verify that a couple of illegal variable declarations are caught by the compiler.
// Does not compile.
package main
func main() {

View file

@ -4,6 +4,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Test var x = x + 1 works.
package main
func main() {