Skip to content

Commit

Permalink
test: explanatory comments [c-g]*
Browse files Browse the repository at this point in the history
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5656103
  • Loading branch information
robpike committed Feb 19, 2012
1 parent c3ef198 commit 83976e3
Show file tree
Hide file tree
Showing 33 changed files with 76 additions and 12 deletions.
2 changes: 2 additions & 0 deletions test/ddd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions test/ddd1.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions test/ddd2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions test/ddd3.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion test/decl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion test/declbad.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions test/defer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 4 additions & 1 deletion test/deferprint.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: ")
}
2 changes: 1 addition & 1 deletion test/divide.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions test/empty.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 ( )
Expand Down
3 changes: 3 additions & 0 deletions test/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
3 changes: 3 additions & 0 deletions test/eof.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions test/eof1.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
4 changes: 2 additions & 2 deletions test/escape.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions test/escape2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion test/escape3.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions test/float_lit.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions test/floatcmp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions test/for.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions test/func.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 3 additions & 2 deletions test/func1.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
5 changes: 4 additions & 1 deletion test/func2.go
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 3 additions & 0 deletions test/func3.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions test/func4.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions test/func5.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 3 additions & 1 deletion test/func6.go
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
2 changes: 2 additions & 0 deletions test/func7.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions test/func8.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions test/gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions test/gc1.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion test/gc2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.)
Expand Down
2 changes: 2 additions & 0 deletions test/goprint.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions test/goto.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 83976e3

Please sign in to comment.