]> Cypherpunks.ru repositories - gostls13.git/commitdiff
test/[n-z]*.go: add documentation
authorRob Pike <r@golang.org>
Fri, 24 Feb 2012 00:48:19 +0000 (11:48 +1100)
committerRob Pike <r@golang.org>
Fri, 24 Feb 2012 00:48:19 +0000 (11:48 +1100)
R=golang-dev, bradfitz, r
CC=golang-dev
https://golang.org/cl/5700056

26 files changed:
test/named1.go
test/shift1.go
test/shift2.go
test/sieve.go
test/sigchld.go
test/simassign.go
test/sinit.go
test/sizeof.go
test/solitaire.go
test/stack.go
test/string_lit.go
test/stringrange.go
test/struct0.go
test/switch.go
test/switch1.go [deleted file]
test/switch3.go
test/test0.go [deleted file]
test/turing.go
test/typeswitch.go
test/typeswitch1.go
test/typeswitch2.go
test/typeswitch3.go
test/undef.go
test/utf.go
test/varerr.go
test/varinit.go

index 5ff6930f7d0757dddbd8b950924ded50a0242667..62b874c5cb9cbebf2bba8a4a87cf4ea544d38708 100644 (file)
@@ -6,6 +6,7 @@
 
 // Test that basic operations on named types are valid
 // and preserve the type.
+// Does not compile.
 
 package main
 
index 393e79ee222a45e70995abbc78d4662dc4ddef09..b33d22ff8effe595fa340974f38925e749430911 100644 (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
 
index cf0a45fdbfefebb93407d283f0b0a4388544256d..88ef3c40f529647ac7a299701e82d2ffb008194e 100644 (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
 
index 31c4ed5c05edfc96be23b5a50fccd11c7d4fe5ff..0cd120c548e368f3a8c741ad2aacbf459f768334 100644 (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'.
index e7c3d5abb48d4289f3454552a0d85583104f6e4d..25625a6f4142271d1afd0015b365cedcb40f6624 100644 (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"
index 349895152c5ff8e45aac2dbf3cfbbac67a8615e3..6ba5c783e96181503b589b246e01bf4ac3293d7c 100644 (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
index 5cd3a4567b8d41e0dd6a2ad9b81515e57e66ca98..1bc2810376440e797b59fbd6201c1184e0920b72 100644 (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.
index 292f73ae4d1d0e87dde40913bf4d15895b2edffd..a6abdd5c65727e5f5c03df72b5341df3aa099abe 100644 (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"
index 99c194f5bbac29b0b330633cf7738fb14c786b56..ac54cec0ac74442309535200457f5b00b0a6e71f 100644 (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
 
index 2a7ce21f33a8d1e07747792622752142094682d0..b62febd48ddc28b77fa37f6bfb2beca2a42141bb 100644 (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.
 
index 7f1ca35bc94371dd735061fe68e8b6447cd686b2..956330038eec183e88ce59c9ad39a7805e3bc8fd 100644 (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"
index a1534c49cbed90adc249a75c538984ba5680b9c0..daaba91c697dd02b941002f50cb8eeaf8c0fc2df 100644 (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 (
index 490d38973910eb25266668e92f95b841d0ddf3fb..e29eb30f544f8bf26e0f69c689dde750a5906cef 100644 (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
 
index 68bd117f0b46aa8c66b5f22dd6eeec60218d061c..09bf4341a00d9dce7822d744d8b71df6d9ba7a36 100644 (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)
+       }
 }
diff --git a/test/switch1.go b/test/switch1.go
deleted file mode 100644 (file)
index 484a5c3..0000000
+++ /dev/null
@@ -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)
-       }
-}
index 404b62e391a972f40dd29d64f9acf688b3a975ba..dcb6fff20846b675dc75df1ff390e7d9ed7ad3b3 100644 (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 {
diff --git a/test/test0.go b/test/test0.go
deleted file mode 100644 (file)
index ba88b1d..0000000
+++ /dev/null
@@ -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() {
-}
index f5a2be2321a7158e24bc31cd925d1e1175dc3768..acbe85b646ce7671dafc290afe39afb5aa5fe9e7 100644 (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
index 1f864db9f74c9f0a33e957717f82636bd871ed68..30a4b4975fbb3afeb7a54e19bcf7b57df4d130ff 100644 (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"
index 8b33d39bc0f716c7404e7a29272f77a4f0ff1238..a980ce4c070d4f2c08d698bb846406d39f4d18c7 100644 (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"
index 69088e0d4f32a45b9a2e505c9a67d8a36b2e85aa..6c703076a6f4908fb53cbe8446e6449bf20de8e2 100644 (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"
index 69a2fca8b160328e3c595dbe45472fcb2ca561aa..5475a8a6d37d03646a9ab06ffc89b55f6c5a54a1 100644 (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 (
index 461006d2cb3b4652dc283b0b6f8115c3166c37cf..0a77e59370bc4116c848295e807a5c6ba2744fb1 100644 (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
 
index 0a3a1c0d6b48079edbb28a9060701e8bb603b84f..3ac79447e635fcfcb43f819508b0f6bbf2558685 100644 (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"
index 4056c16d0316b593db9739593cbe494287544135..22aa9324f98e5d2eb4e3992c67a7ed0782eb3251 100644 (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() {
index 5614783e04ea1f867db0c8b88b149217f30813c6..84a4a1aa55cd58cf2169b1c2b83ec517d67f6a26 100644 (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() {