]> Cypherpunks.ru repositories - gostls13.git/commitdiff
test: explanatory comments [c-g]*
authorRob Pike <r@golang.org>
Sun, 19 Feb 2012 03:28:53 +0000 (14:28 +1100)
committerRob Pike <r@golang.org>
Sun, 19 Feb 2012 03:28:53 +0000 (14:28 +1100)
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5656103

33 files changed:
test/ddd.go
test/ddd1.go
test/ddd2.go
test/ddd3.go
test/decl.go
test/declbad.go
test/defer.go
test/deferprint.go
test/divide.go
test/empty.go
test/env.go
test/eof.go
test/eof1.go
test/escape.go
test/escape2.go
test/escape3.go
test/float_lit.go
test/floatcmp.go
test/for.go
test/func.go
test/func1.go
test/func2.go
test/func3.go
test/func4.go
test/func5.go
test/func6.go
test/func7.go
test/func8.go
test/gc.go
test/gc1.go
test/gc2.go
test/goprint.go
test/goto.go

index aa799be271c0beed9823551b5bdf99d72922a0a6..f35836331b21d7bf0b7e1edd50831e9fe4326dea 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 variadic functions and calls (dot-dot-dot).
+
 package main
 
 func sum(args ...int) int {
index 3eab78a567f7f2826bdc67b4ef3ecf65400607e9..1e070093c3fbd11af25f494c0ff4df628d26d6db 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 illegal uses of ... are detected.
+// Does not compile.
+
 package main
 
 import "unsafe"
index a06af0c06578725dc697cddefdf4c715a67202a9..2edae36b1ed193de95f129c938fe15303518f401 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.
 
+// This file is compiled and then imported by ddd3.go.
+
 package ddd
 
 func Sum(args ...int) int {
index 5d5ebdf0faea9741981d201bba8e5b7ef0b08186..82fce31499fe6efe32752d527e3e911c8fba8446 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 that variadic functions work across package boundaries.
+
 package main
 
 import "./ddd2"
index 4a7d86794d370fd3d99f9c05227a1e23290e9827..6f84245f1522de0e6602179f1e6eb9cf86dfb58c 100644 (file)
@@ -4,7 +4,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// Correct short declarations and redeclarations.
+// Test correct short declarations and redeclarations.
 
 package main
 
index 962a61c0f9b4bbf15d20a56905cc5025cd420787..32d68e7ea231df5cd9354da6e3e2cc6dfe7bfae6 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.
 
-// Incorrect short declarations and redeclarations.
+// Test that incorrect short declarations and redeclarations are detected.
+// Does not compile.
 
 package main
 
index 30276649b35529d3e8cd564127b668eed9a558bf..2f67d356091fc650201e0a4b2f300d6b74d9bd15 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 defer.
+
 package main
 
 import "fmt"
index 0e0c618216809f40df15c9948550b6eaed7bee55..eab7ed465598165ac25cdd3739560bd46f536d46 100644 (file)
@@ -4,11 +4,14 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+// Test that we can defer the predeclared functions print and println.
+
 package main
 
 func main() {
        defer println(42, true, false, true, 1.5, "world", (chan int)(nil), []int(nil), (map[string]int)(nil), (func())(nil), byte(255))
        defer println(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20)
-//     defer panic("dead")
+       // Disabled so the test doesn't crash but left here for reference.
+       // defer panic("dead")
        defer print("printing: ")
 }
index 75597f5150cefd14f871c06a7c76b1ac0cba8fb7..c91a33e9db283829519ecf50315f04b9b8995582 100644 (file)
@@ -4,7 +4,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// divide corner cases
+// Test divide corner cases.
 
 package main
 
index 7f2bf1a04743add0b23242c0f837f415bde59c6a..92a79a4e0d802d184f1b066d0a142a455e805e2f 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 top-level parenthesized declarations can be empty.
+// Compiles but does not run.
+
 package P
 
 import ( )
index 721df55c0af9ccbb46bd88135256fdad49bd1326..4dcf4443a70ff5e8838256cf71db66bf4b3f99d8 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 the Go environment variables are present and accessible through
+// package os and package runtime.
+
 package main
 
 import (
index 71a9f85158ed0e7e8d0ef578f4e193cd6249d529..06c779046b668fc75ca21bbbdb7519e22b1aa4e7 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 a source file does not need a final newline.
+// Compiles but does not run.
+
 // No newline at the end of this file.
 
 package main
\ No newline at end of file
index af6b4c52f1c20491cc9decdabed368c544567cff..2105b89080bad9e03ae1d6c4e3d97f2873276ef7 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 a comment ending a source file does not need a final newline.
+// Compiles but does not run.
+
 package eof1
 
 // No newline at the end of this comment.
\ No newline at end of file
index 6c0cdc4632c11c296998c94b3c3777a0d26c6633..e487bb89565f3fd75af9229e1843b810b9f043d5 100644 (file)
@@ -6,8 +6,8 @@
 
 package main
 
-// check for correct heap-moving of escaped variables.
-// it is hard to check for the allocations, but it is easy
+// Test for correct heap-moving of escaped variables.
+// It is hard to check for the allocations, but it is easy
 // to check that if you call the function twice at the
 // same stack level, the pointers returned should be
 // different.
index 73b2a7e58973eb73377e19da9d1596cd56336680..dde96bcc1e27a3a55919d9403f2185c9b81c205f 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, using compiler diagnostic flags, that the escape analysis is working.
+// Compiles but does not run.
+
 package foo
 
 import (
index 0612ae2dd951ba252b27249b0a89a4ea65911e84..4c1989151465d0f69eefb41aa20a590e72715ab4 100644 (file)
@@ -4,7 +4,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// Test run-time behavior of escape analysis-related optimizations.
+// Test the run-time behavior of escape analysis-related optimizations.
 
 package main
 
index 3189cac2231714a0a7700ac41214afa4a005d8c4..2912c3749c24e66f87ae8abbdc180c6b988767ff 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 floating-point literal syntax.
+
 package main
 
 var bad bool
index 2a5bd75df2b4776c82f78c35b5c2b3b3adf5a060..f9f59a937f2d9f9c13d6f8b416ca266c72f94947 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 floating-point comparison involving NaN.
+
 package main
 
 import "math"
index a21213ff3fd2be77569126596c66e0637216d003..8a50090657fb51d36f78f499b2f49700b680d760 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 for loops.
+
 package main
 
 func assertequal(is, shouldbe int, msg string) {
index 15839c05fafd14ced50dfd2a234cd3beb611fd64..246cb56fd95c398ef2f973cee4599814dd19b1bb 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 simple functions.
 
 package main
 
index d5adea71ecc014676df60b221b5a652e23ebaabd..c89f7ff2eae777ffb99e594ab635284ee4bc4a07 100644 (file)
@@ -4,11 +4,12 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// does not compile and should not compile
+// Test that result parameters are in the same scope as regular parameters.
+// Does not compile.
 
 package main
 
-func f1(a int) (int, float32) { // BUG (not caught by compiler): multiple return values must have names
+func f1(a int) (int, float32) {
        return 7, 7.0
 }
 
index 87e78194ef9af93a7185c7095840237f72ec8b27..b5966a91f6065e58030908746c5b996615635a4f 100644 (file)
@@ -1,9 +1,12 @@
-// $G $F.go || echo BUG: should compile
+// compile
 
 // 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 function signatures.
+// Compiled but not run.
+
 package main
 
 type t1 int
index 587b7c4a144014db3afc162699053052a4fee65d..6be3bf0184d386f436fd3d7a1044b26da8084613 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 illegal function signatures are detected.
+// Does not compile.
+
 package main
 
 type t1 int
index c53e7a23ac23d6b20540fa0823bf0876340a5f8f..85f1e4b81e91fea4c9b3dee5851d5025140aab69 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 it is illegal to take the address of a function.
+// Does not compile.
+
 package main
 
 var notmain func()
index 68ab7a54b99b61118c3440d073adfaa84e51d701..2e058be7e6e19526fb24502964b5466d6e3fa86a 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 functions and goroutines.
+
 package main
 
 func caller(f func(int, int) int, a, b int, c chan int) {
index 39c15329ef821d4a8a5223f748462f6326fb7bc0..456cb49f0920ee5c93b5f7c3b70e0aaa3f57dcea 100644 (file)
@@ -1,9 +1,11 @@
-// compile
+// run
 
 // 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 closures in if conditions.
+
 package main
 
 func main() {
index 015b881fb0ef210bacda1787e3eca310f2ab622f..6f6766f29f6aad0814df79190910ca2aa3d8f3fb 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 evaluation order in if condition.
+
 package main
 
 var calledf = false
index a1ea9b7e4cdc07cd7c681ed4952aadf46050c238..7defe265b58f60846082c9b73691ccfc57c7b597 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 evaluation order.
+
 package main
 
 var calledf int
index e610d2bde810464bfb0fd2547b44bd6893d5da2d..6688f9fbddb9148c60ff0719e45cfc367cff35dc 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.
 
+// Simple test of the garbage collector.
+
 package main
 
 import "runtime"
index 190b29b005a8c5015190f4d6eefb603faded61e4..6049ea14e9bfa9a3a4ab26ccb4169c34968f1552 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.
 
+// A simple test of the garbage collector.
+
 package main
 
 func main() {
index 739183e59827558c5cbc24e33e5b61f6365b9899..de52a4fbf2eacd4f5469972cf6d1605f75b1f119 100644 (file)
@@ -4,7 +4,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// Check that buffered channels are garbage collected properly.
+// Test that buffered channels are garbage collected properly.
 // An interesting case because they have finalizers and used to
 // have self loops that kept them from being collected.
 // (Cyclic data with finalizers is never finalized, nor collected.)
index 53ed055a070abc94f8d386ba0201a5e5d1c4227d..3fe08f307791bde55f2ce29e45df9668d40ce1cf 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 that println can be the target of a go statement.
+
 package main
 
 import "time"
index 11417f86b79b0d5981f06a9b3e55a56b3fd2f6d4..ca477b3d0c3beb77025ac31326b661d7dec8b43f 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 goto semantics.
+// Does not compile.
+//
 // Each test is in a separate function just so that if the
 // compiler stops processing after one error, we don't
 // lose other ones.