mirror of
https://github.com/golang/go
synced 2024-11-21 16:44:43 -07:00
test/[n-r]*.go: add documentation
The rename ones needed redoing. R=golang-dev, bradfitz, rsc CC=golang-dev https://golang.org/cl/5698054
This commit is contained in:
parent
5b30306fa8
commit
19bab1dc78
@ -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 nil.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -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 the implementation catches nil ptr indirection
|
||||||
|
// in a large address space.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "unsafe"
|
import "unsafe"
|
||||||
|
@ -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 types can be parenthesized.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
func f(interface{})
|
func f(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.
|
||||||
|
|
||||||
|
// Test that heavy recursion works. Simple torture test for
|
||||||
|
// segmented stacks: do math in unary by recursion.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
type Number *Number
|
type Number *Number
|
||||||
|
@ -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 big numbers work as constants and print can print them.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
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 'for range' construct.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
// test range over channels
|
// test range over channels
|
||||||
|
@ -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 recovering from runtime errors.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
109
test/rename.go
109
test/rename.go
@ -4,70 +4,95 @@
|
|||||||
// 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 predeclared names can be redeclared by the user.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
n :=
|
n :=
|
||||||
bool +
|
append +
|
||||||
|
bool +
|
||||||
byte +
|
byte +
|
||||||
float +
|
complex +
|
||||||
|
complex64 +
|
||||||
|
complex128 +
|
||||||
|
cap +
|
||||||
|
close +
|
||||||
|
delete +
|
||||||
|
error +
|
||||||
|
false +
|
||||||
float32 +
|
float32 +
|
||||||
float64 +
|
float64 +
|
||||||
|
imag +
|
||||||
int +
|
int +
|
||||||
int8 +
|
int8 +
|
||||||
int16 +
|
int16 +
|
||||||
int32 +
|
int32 +
|
||||||
int64 +
|
int64 +
|
||||||
|
len +
|
||||||
|
make +
|
||||||
|
new +
|
||||||
|
nil +
|
||||||
|
panic +
|
||||||
|
print +
|
||||||
|
println +
|
||||||
|
real +
|
||||||
|
recover +
|
||||||
|
rune +
|
||||||
|
string +
|
||||||
|
true +
|
||||||
uint +
|
uint +
|
||||||
uint8 +
|
uint8 +
|
||||||
uint16 +
|
uint16 +
|
||||||
uint32 +
|
uint32 +
|
||||||
uint64 +
|
uint64 +
|
||||||
uintptr +
|
uintptr +
|
||||||
true +
|
iota
|
||||||
false +
|
if n != NUM*(NUM-1)/2 {
|
||||||
iota +
|
fmt.Println("BUG: wrong n", n, NUM*(NUM-1)/2)
|
||||||
nil +
|
|
||||||
cap +
|
|
||||||
len +
|
|
||||||
make +
|
|
||||||
new +
|
|
||||||
panic +
|
|
||||||
print +
|
|
||||||
println
|
|
||||||
if n != 27*28/2 {
|
|
||||||
fmt.Println("BUG: wrong n", n, 27*28/2)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
bool = 1
|
append = iota
|
||||||
byte = 2
|
bool
|
||||||
float = 3
|
byte
|
||||||
float32 = 4
|
complex
|
||||||
float64 = 5
|
complex64
|
||||||
int = 6
|
complex128
|
||||||
int8 = 7
|
cap
|
||||||
int16 = 8
|
close
|
||||||
int32 = 9
|
delete
|
||||||
int64 = 10
|
error
|
||||||
uint = 11
|
false
|
||||||
uint8 = 12
|
float32
|
||||||
uint16 = 13
|
float64
|
||||||
uint32 = 14
|
imag
|
||||||
uint64 = 15
|
int
|
||||||
uintptr = 16
|
int8
|
||||||
true = 17
|
int16
|
||||||
false = 18
|
int32
|
||||||
iota = 19
|
int64
|
||||||
nil = 20
|
len
|
||||||
cap = 21
|
make
|
||||||
len = 22
|
new
|
||||||
make = 23
|
nil
|
||||||
new = 24
|
panic
|
||||||
panic = 25
|
print
|
||||||
print = 26
|
println
|
||||||
println = 27
|
real
|
||||||
|
recover
|
||||||
|
rune
|
||||||
|
string
|
||||||
|
true
|
||||||
|
uint
|
||||||
|
uint8
|
||||||
|
uint16
|
||||||
|
uint32
|
||||||
|
uint64
|
||||||
|
uintptr
|
||||||
|
NUM
|
||||||
|
iota = 0
|
||||||
)
|
)
|
||||||
|
@ -4,11 +4,14 @@
|
|||||||
// 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 renamed identifiers no longer have their old meaning.
|
||||||
|
// Does not compile.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var n byte // ERROR "not a type|expected type"
|
var n byte // ERROR "not a type|expected type"
|
||||||
var y = float(0) // ERROR "cannot call|expected function"
|
var y = float32(0) // ERROR "cannot call|expected function"
|
||||||
const (
|
const (
|
||||||
a = 1 + iota // ERROR "string|incompatible types" "convert iota"
|
a = 1 + iota // ERROR "string|incompatible types" "convert iota"
|
||||||
)
|
)
|
||||||
@ -16,31 +19,43 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
bool = 1
|
append = iota
|
||||||
byte = 2
|
bool
|
||||||
float = 3
|
byte
|
||||||
float32 = 4
|
complex
|
||||||
float64 = 5
|
complex64
|
||||||
int = 6
|
complex128
|
||||||
int8 = 7
|
cap
|
||||||
int16 = 8
|
close
|
||||||
int32 = 9
|
delete
|
||||||
int64 = 10
|
error
|
||||||
uint = 11
|
false
|
||||||
uint8 = 12
|
float32
|
||||||
uint16 = 13
|
float64
|
||||||
uint32 = 14
|
imag
|
||||||
uint64 = 15
|
int
|
||||||
uintptr = 16
|
int8
|
||||||
true = 17
|
int16
|
||||||
false = 18
|
int32
|
||||||
iota = "abc"
|
int64
|
||||||
nil = 20
|
len
|
||||||
cap = 21
|
make
|
||||||
len = 22
|
new
|
||||||
make = 23
|
nil
|
||||||
new = 24
|
panic
|
||||||
panic = 25
|
print
|
||||||
print = 26
|
println
|
||||||
println = 27
|
real
|
||||||
|
recover
|
||||||
|
rune
|
||||||
|
string
|
||||||
|
true
|
||||||
|
uint
|
||||||
|
uint8
|
||||||
|
uint16
|
||||||
|
uint32
|
||||||
|
uint64
|
||||||
|
uintptr
|
||||||
|
NUM
|
||||||
|
iota = "123"
|
||||||
)
|
)
|
||||||
|
@ -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.
|
||||||
|
|
||||||
// Check reordering of assignments.
|
// Test reordering of assignments.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
@ -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.
|
||||||
|
|
||||||
// derived from fixedbugs/bug294.go
|
// Test reorderings; derived from fixedbugs/bug294.go.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
@ -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 rune constants, expressions and types.
|
||||||
|
// Compiles but does not run.
|
||||||
|
|
||||||
package rune
|
package rune
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -4,12 +4,13 @@
|
|||||||
// 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.
|
||||||
|
|
||||||
// make sure that even if a file imports runtime,
|
// Test that even if a file imports runtime,
|
||||||
// it cannot get at the low-level runtime definitions
|
// it cannot get at the low-level runtime definitions
|
||||||
// known to the compiler. for normal packages
|
// known to the compiler. For normal packages
|
||||||
// the compiler doesn't even record the lower case
|
// the compiler doesn't even record the lower case
|
||||||
// functions in its symbol table, but some functions
|
// functions in its symbol table, but some functions
|
||||||
// in runtime are hard-coded into the compiler.
|
// in runtime are hard-coded into the compiler.
|
||||||
|
// Does not compile.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user