Skip to content

Commit

Permalink
test: [a-c]: add introductory comments to tests
Browse files Browse the repository at this point in the history
Very few of the compiler regression tests include a comment
saying waht they do. Many are obvious, some are anything but.
I've started with a-c in the top directory. More will follow once
we agree on the approach, correctness, and thoroughness here.
zerodivide.go sneaked in too.

R=rsc, r
CC=golang-dev
https://golang.org/cl/5656100
  • Loading branch information
robpike committed Feb 19, 2012
1 parent 126d475 commit fc0dc04
Show file tree
Hide file tree
Showing 32 changed files with 79 additions and 10 deletions.
3 changes: 3 additions & 0 deletions test/235.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.

// Solve the 2,3,5 problem (print all numbers with 2, 3, or 5 as factor) using channels.
// Test the solution, silently.

package main

type T chan uint64
Expand Down
5 changes: 3 additions & 2 deletions test/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package main

// Test that error messages say what the source file says
// (uint8 vs byte, int32 vs. rune).
// Does not compile.

package main

import (
"fmt"
Expand Down
4 changes: 2 additions & 2 deletions test/alias1.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package main

// Test that dynamic interface checks treat byte=uint8
// and rune=int or rune=int32.

package main

func main() {
var x interface{}

Expand Down
2 changes: 1 addition & 1 deletion test/append.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.

// Semi-exhaustive test for append()
// Semi-exhaustive test for the append predeclared function.

package main

Expand Down
2 changes: 2 additions & 0 deletions test/args.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 os.Args.

package main

import "os"
Expand Down
3 changes: 3 additions & 0 deletions test/assign.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 simple assignment errors are caught by the compiler.
// Does not compile.

package main

import "sync"
Expand Down
3 changes: 3 additions & 0 deletions test/assign1.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 assignment rules are enforced by the compiler.
// Does not compile.

package main

type (
Expand Down
2 changes: 2 additions & 0 deletions test/bigalg.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 the internal "algorithms" for objects larger than a word: hashing, equality etc.

package main

type T struct {
Expand Down
2 changes: 2 additions & 0 deletions test/bigmap.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 behavior of maps with large elements.

package main

func seq(x, y int) [1000]byte {
Expand Down
2 changes: 2 additions & 0 deletions test/blank.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 behavior of the blank identifier (_).

package main

import _ "fmt"
Expand Down
3 changes: 3 additions & 0 deletions test/blank1.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 incorrect uses of the blank identifer are caught.
// Does not compile.

package _ // ERROR "invalid package name _"

func main() {
Expand Down
2 changes: 2 additions & 0 deletions test/chancap.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 the cap predeclared function applied to channels.

package main

func main() {
Expand Down
4 changes: 3 additions & 1 deletion test/char_lit.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// $G $F.go && $L $F.$A &&./$A.out
// 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.

// Test character literal syntax.

package main

import "os"
Expand Down
3 changes: 3 additions & 0 deletions test/char_lit1.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 character literals are detected.
// Does not compile.

package main

const (
Expand Down
2 changes: 2 additions & 0 deletions test/closure.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 the behavior of closures.

package main

import "runtime"
Expand Down
2 changes: 2 additions & 0 deletions test/cmp.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 equality and inequality operations.

package main

import "unsafe"
Expand Down
3 changes: 3 additions & 0 deletions test/cmp6.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 incorrect comparisons are detected.
// Does not compile.

package main

func use(bool) {}
Expand Down
3 changes: 3 additions & 0 deletions test/cmplx.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 incorrect invocations of the complex predeclared function are detected.
// Does not compile.

package main

var (
Expand Down
2 changes: 2 additions & 0 deletions test/complit.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 composite literals.

package main

type T struct {
Expand Down
3 changes: 3 additions & 0 deletions test/complit1.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 composite literals are detected.
// Does not compile.

package main

var m map[int][3]int
Expand Down
2 changes: 2 additions & 0 deletions test/compos.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 returning &T{} from a function causes an allocation.

package main

type T struct {
Expand Down
2 changes: 2 additions & 0 deletions test/const.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 simple boolean and numeric constants.

package main

const (
Expand Down
3 changes: 3 additions & 0 deletions test/const1.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 overflow is detected when using numeric constants.
// Does not compile.

package main

type I interface{}
Expand Down
3 changes: 3 additions & 0 deletions test/const2.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 large integer constant expressions cause overflow.
// Does not compile.

package main

const (
Expand Down
2 changes: 2 additions & 0 deletions test/const3.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 typed integer constants.

package main

import "fmt"
Expand Down
2 changes: 2 additions & 0 deletions test/convert.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 types of constant expressions, using reflect.

package main

import "reflect"
Expand Down
3 changes: 3 additions & 0 deletions test/convert1.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 conversions involving strings are detected.
// Does not compile.

package main

type Tbyte []byte
Expand Down
3 changes: 3 additions & 0 deletions test/convert3.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 allowed and disallowed conversions.
// Does not compile.

package main

// everything here is legal except the ERROR line
Expand Down
7 changes: 4 additions & 3 deletions test/convlit.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.

// Verify that illegal assignments with both explicit and implicit conversions of literals are detected.
// Does not compile.

package main

// explicit conversion of constants is work in progress.
// the ERRORs in this block are debatable, but they're what
// the language spec says for now.
// explicit conversion of constants
var x1 = string(1)
var x2 string = string(1)
var x3 = int(1.5) // ERROR "convert|truncate"
Expand Down
3 changes: 3 additions & 0 deletions test/convlit1.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 composite literals are detected.
// Does not compile.

package main

var a = []int { "a" }; // ERROR "conver|incompatible|cannot"
Expand Down
2 changes: 1 addition & 1 deletion test/copy.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.

// Semi-exhaustive test for copy()
// Semi-exhaustive test for the copy predeclared function.

package main

Expand Down
2 changes: 2 additions & 0 deletions test/zerodivide.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 zero division causes a panic.

package main

import (
Expand Down

0 comments on commit fc0dc04

Please sign in to comment.