mirror of
https://github.com/golang/go
synced 2024-11-11 17:51:49 -07:00
test: [a-c]: add introductory comments to tests
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
This commit is contained in:
parent
126d475a43
commit
fc0dc04095
@ -4,6 +4,9 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// 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
|
package main
|
||||||
|
|
||||||
type T chan uint64
|
type T chan uint64
|
||||||
|
@ -4,10 +4,11 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
// Test that error messages say what the source file says
|
// Test that error messages say what the source file says
|
||||||
// (uint8 vs byte, int32 vs. rune).
|
// (uint8 vs byte, int32 vs. rune).
|
||||||
|
// Does not compile.
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -4,11 +4,11 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
// Test that dynamic interface checks treat byte=uint8
|
// Test that dynamic interface checks treat byte=uint8
|
||||||
// and rune=int or rune=int32.
|
// and rune=int or rune=int32.
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var x interface{}
|
var x interface{}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// Semi-exhaustive test for append()
|
// Semi-exhaustive test for the append predeclared function.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Test os.Args.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "os"
|
import "os"
|
||||||
|
@ -4,6 +4,9 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Verify simple assignment errors are caught by the compiler.
|
||||||
|
// Does not compile.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "sync"
|
import "sync"
|
||||||
|
@ -4,6 +4,9 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Verify assignment rules are enforced by the compiler.
|
||||||
|
// Does not compile.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
type (
|
type (
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Test the internal "algorithms" for objects larger than a word: hashing, equality etc.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
type T struct {
|
type T struct {
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Test behavior of maps with large elements.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
func seq(x, y int) [1000]byte {
|
func seq(x, y int) [1000]byte {
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Test behavior of the blank identifier (_).
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import _ "fmt"
|
import _ "fmt"
|
||||||
|
@ -4,6 +4,9 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// 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 _"
|
package _ // ERROR "invalid package name _"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Test the cap predeclared function applied to channels.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
// $G $F.go && $L $F.$A &&./$A.out
|
// run
|
||||||
|
|
||||||
// Copyright 2009 The Go Authors. All rights reserved.
|
// Copyright 2009 The Go Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Test character literal syntax.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "os"
|
import "os"
|
||||||
|
@ -4,6 +4,9 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Verify that illegal character literals are detected.
|
||||||
|
// Does not compile.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Test the behavior of closures.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "runtime"
|
import "runtime"
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Test equality and inequality operations.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "unsafe"
|
import "unsafe"
|
||||||
|
@ -4,6 +4,9 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Verify that incorrect comparisons are detected.
|
||||||
|
// Does not compile.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
func use(bool) {}
|
func use(bool) {}
|
||||||
|
@ -4,6 +4,9 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// 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
|
package main
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Test composite literals.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
type T struct {
|
type T struct {
|
||||||
|
@ -4,6 +4,9 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Verify that illegal composite literals are detected.
|
||||||
|
// Does not compile.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
var m map[int][3]int
|
var m map[int][3]int
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Test that returning &T{} from a function causes an allocation.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
type T struct {
|
type T struct {
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Test simple boolean and numeric constants.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -4,6 +4,9 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Verify overflow is detected when using numeric constants.
|
||||||
|
// Does not compile.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
type I interface{}
|
type I interface{}
|
||||||
|
@ -4,6 +4,9 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Verify that large integer constant expressions cause overflow.
|
||||||
|
// Does not compile.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Test typed integer constants.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Test types of constant expressions, using reflect.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "reflect"
|
import "reflect"
|
||||||
|
@ -4,6 +4,9 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Verify that illegal conversions involving strings are detected.
|
||||||
|
// Does not compile.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
type Tbyte []byte
|
type Tbyte []byte
|
||||||
|
@ -4,6 +4,9 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Verify allowed and disallowed conversions.
|
||||||
|
// Does not compile.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
// everything here is legal except the ERROR line
|
// everything here is legal except the ERROR line
|
||||||
|
@ -4,11 +4,12 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// 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
|
package main
|
||||||
|
|
||||||
// explicit conversion of constants is work in progress.
|
// explicit conversion of constants
|
||||||
// the ERRORs in this block are debatable, but they're what
|
|
||||||
// the language spec says for now.
|
|
||||||
var x1 = string(1)
|
var x1 = string(1)
|
||||||
var x2 string = string(1)
|
var x2 string = string(1)
|
||||||
var x3 = int(1.5) // ERROR "convert|truncate"
|
var x3 = int(1.5) // ERROR "convert|truncate"
|
||||||
|
@ -4,6 +4,9 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Verify that illegal uses of composite literals are detected.
|
||||||
|
// Does not compile.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
var a = []int { "a" }; // ERROR "conver|incompatible|cannot"
|
var a = []int { "a" }; // ERROR "conver|incompatible|cannot"
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// Semi-exhaustive test for copy()
|
// Semi-exhaustive test for the copy predeclared function.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Test that zero division causes a panic.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
Loading…
Reference in New Issue
Block a user