diff --git a/test/ddd.go b/test/ddd.go index aa799be271c0be..f35836331b21d7 100644 --- a/test/ddd.go +++ b/test/ddd.go @@ -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 { diff --git a/test/ddd1.go b/test/ddd1.go index 3eab78a567f7f2..1e070093c3fbd1 100644 --- a/test/ddd1.go +++ b/test/ddd1.go @@ -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" diff --git a/test/ddd2.go b/test/ddd2.go index a06af0c0657872..2edae36b1ed193 100644 --- a/test/ddd2.go +++ b/test/ddd2.go @@ -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 { diff --git a/test/ddd3.go b/test/ddd3.go index 5d5ebdf0faea97..82fce31499fe6e 100644 --- a/test/ddd3.go +++ b/test/ddd3.go @@ -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" diff --git a/test/decl.go b/test/decl.go index 4a7d86794d370f..6f84245f1522de 100644 --- a/test/decl.go +++ b/test/decl.go @@ -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 diff --git a/test/declbad.go b/test/declbad.go index 962a61c0f9b4bb..32d68e7ea231df 100644 --- a/test/declbad.go +++ b/test/declbad.go @@ -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 diff --git a/test/defer.go b/test/defer.go index 30276649b35529..2f67d356091fc6 100644 --- a/test/defer.go +++ b/test/defer.go @@ -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" diff --git a/test/deferprint.go b/test/deferprint.go index 0e0c618216809f..eab7ed46559816 100644 --- a/test/deferprint.go +++ b/test/deferprint.go @@ -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: ") } diff --git a/test/divide.go b/test/divide.go index 75597f5150cefd..c91a33e9db2838 100644 --- a/test/divide.go +++ b/test/divide.go @@ -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 diff --git a/test/empty.go b/test/empty.go index 7f2bf1a04743ad..92a79a4e0d802d 100644 --- a/test/empty.go +++ b/test/empty.go @@ -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 ( ) diff --git a/test/env.go b/test/env.go index 721df55c0af9cc..4dcf4443a70ff5 100644 --- a/test/env.go +++ b/test/env.go @@ -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 ( diff --git a/test/eof.go b/test/eof.go index 71a9f85158ed0e..06c779046b668f 100644 --- a/test/eof.go +++ b/test/eof.go @@ -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 diff --git a/test/eof1.go b/test/eof1.go index af6b4c52f1c204..2105b89080bad9 100644 --- a/test/eof1.go +++ b/test/eof1.go @@ -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 diff --git a/test/escape.go b/test/escape.go index 6c0cdc4632c11c..e487bb89565f3f 100644 --- a/test/escape.go +++ b/test/escape.go @@ -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. diff --git a/test/escape2.go b/test/escape2.go index 73b2a7e58973eb..dde96bcc1e27a3 100644 --- a/test/escape2.go +++ b/test/escape2.go @@ -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 ( diff --git a/test/escape3.go b/test/escape3.go index 0612ae2dd951ba..4c1989151465d0 100644 --- a/test/escape3.go +++ b/test/escape3.go @@ -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 diff --git a/test/float_lit.go b/test/float_lit.go index 3189cac2231714..2912c3749c24e6 100644 --- a/test/float_lit.go +++ b/test/float_lit.go @@ -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 diff --git a/test/floatcmp.go b/test/floatcmp.go index 2a5bd75df2b477..f9f59a937f2d9f 100644 --- a/test/floatcmp.go +++ b/test/floatcmp.go @@ -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" diff --git a/test/for.go b/test/for.go index a21213ff3fd2be..8a50090657fb51 100644 --- a/test/for.go +++ b/test/for.go @@ -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) { diff --git a/test/func.go b/test/func.go index 15839c05fafd14..246cb56fd95c39 100644 --- a/test/func.go +++ b/test/func.go @@ -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 diff --git a/test/func1.go b/test/func1.go index d5adea71ecc014..c89f7ff2eae777 100644 --- a/test/func1.go +++ b/test/func1.go @@ -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 } diff --git a/test/func2.go b/test/func2.go index 87e78194ef9af9..b5966a91f6065e 100644 --- a/test/func2.go +++ b/test/func2.go @@ -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 diff --git a/test/func3.go b/test/func3.go index 587b7c4a144014..6be3bf0184d386 100644 --- a/test/func3.go +++ b/test/func3.go @@ -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 diff --git a/test/func4.go b/test/func4.go index c53e7a23ac23d6..85f1e4b81e91fe 100644 --- a/test/func4.go +++ b/test/func4.go @@ -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() diff --git a/test/func5.go b/test/func5.go index 68ab7a54b99b61..2e058be7e6e195 100644 --- a/test/func5.go +++ b/test/func5.go @@ -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) { diff --git a/test/func6.go b/test/func6.go index 39c15329ef821d..456cb49f0920ee 100644 --- a/test/func6.go +++ b/test/func6.go @@ -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() { diff --git a/test/func7.go b/test/func7.go index 015b881fb0ef21..6f6766f29f6aad 100644 --- a/test/func7.go +++ b/test/func7.go @@ -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 diff --git a/test/func8.go b/test/func8.go index a1ea9b7e4cdc07..7defe265b58f60 100644 --- a/test/func8.go +++ b/test/func8.go @@ -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 diff --git a/test/gc.go b/test/gc.go index e610d2bde81046..6688f9fbddb914 100644 --- a/test/gc.go +++ b/test/gc.go @@ -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" diff --git a/test/gc1.go b/test/gc1.go index 190b29b005a8c5..6049ea14e9bfa9 100644 --- a/test/gc1.go +++ b/test/gc1.go @@ -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() { diff --git a/test/gc2.go b/test/gc2.go index 739183e5982755..de52a4fbf2eacd 100644 --- a/test/gc2.go +++ b/test/gc2.go @@ -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.) diff --git a/test/goprint.go b/test/goprint.go index 53ed055a070abc..3fe08f307791bd 100644 --- a/test/goprint.go +++ b/test/goprint.go @@ -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" diff --git a/test/goto.go b/test/goto.go index 11417f86b79b0d..ca477b3d0c3beb 100644 --- a/test/goto.go +++ b/test/goto.go @@ -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.