Commit 80a9783f authored by Rob Pike's avatar Rob Pike

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

R=golang-dev, bradfitz, r
CC=golang-dev
https://golang.org/cl/5700056
parent c05c3a9d
......@@ -6,6 +6,7 @@
// Test that basic operations on named types are valid
// and preserve the type.
// Does not compile.
package main
......
......@@ -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
......
......@@ -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
......
// 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'.
......
......@@ -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"
......
......@@ -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
......
......@@ -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.
......
......@@ -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"
......
// 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
......
......@@ -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.
......
......@@ -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"
......
......@@ -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 (
......
......@@ -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
......
......@@ -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)
}
}
// 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)
}
}
......@@ -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 {
......
// 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() {
}
......@@ -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
......
......@@ -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"
......
......@@ -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"
......
......@@ -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"
......
......@@ -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 (
......
......@@ -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
......
......@@ -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"
......
......@@ -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() {
......
......@@ -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() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment