mirror of
https://github.com/golang/go
synced 2024-11-21 19:14:44 -07:00
fix up some irregular indentation
R=rsc OCL=33382 CL=33391
This commit is contained in:
parent
3e804ba7a7
commit
74dd0ab670
@ -1,4 +1,4 @@
|
|||||||
// errchk $G $D/$F.go
|
// ! $G $D/$F.go || echo BUG: compilation succeeds incorrectly
|
||||||
|
|
||||||
// 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
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
// Copyright 2009 The Go Authors. All rights reserved.
|
// $G $D/$F.go && $L $F.$A && ./$A.out
|
||||||
|
|
||||||
|
// 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.
|
||||||
|
|
||||||
// $G $D/$F.go && $L $F.$A && ./$A.out
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "os"
|
import "os"
|
||||||
|
@ -10,42 +10,43 @@ var counter uint
|
|||||||
var shift uint
|
var shift uint
|
||||||
|
|
||||||
func GetValue() uint {
|
func GetValue() uint {
|
||||||
counter++;
|
counter++;
|
||||||
return 1 << shift
|
return 1 << shift
|
||||||
}
|
}
|
||||||
|
|
||||||
func Send(a, b chan uint) int {
|
func Send(a, b chan uint) int {
|
||||||
var i int;
|
var i int;
|
||||||
LOOP:
|
|
||||||
for {
|
LOOP:
|
||||||
select {
|
for {
|
||||||
case a <- GetValue():
|
select {
|
||||||
i++;
|
case a <- GetValue():
|
||||||
a = nil;
|
i++;
|
||||||
case b <- GetValue():
|
a = nil;
|
||||||
i++;
|
case b <- GetValue():
|
||||||
b = nil;
|
i++;
|
||||||
default:
|
b = nil;
|
||||||
break LOOP;
|
default:
|
||||||
}
|
break LOOP;
|
||||||
shift++;
|
}
|
||||||
}
|
shift++;
|
||||||
return i;
|
}
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
a := make(chan uint, 1);
|
a := make(chan uint, 1);
|
||||||
b := make(chan uint, 1);
|
b := make(chan uint, 1);
|
||||||
if v := Send(a, b); v != 2 {
|
if v := Send(a, b); v != 2 {
|
||||||
panicln("Send returned", v, "!= 2");
|
panicln("Send returned", v, "!= 2");
|
||||||
}
|
}
|
||||||
if av, bv := <- a, <- b; av | bv != 3 {
|
if av, bv := <- a, <- b; av | bv != 3 {
|
||||||
panicln("bad values", av, bv);
|
panicln("bad values", av, bv);
|
||||||
}
|
}
|
||||||
if v := Send(a, nil); v != 1 {
|
if v := Send(a, nil); v != 1 {
|
||||||
panicln("Send returned", v, "!= 1");
|
panicln("Send returned", v, "!= 1");
|
||||||
}
|
}
|
||||||
if counter != 10 {
|
if counter != 10 {
|
||||||
panicln("counter is", counter, "!= 10");
|
panicln("counter is", counter, "!= 10");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,36 +9,36 @@ package main
|
|||||||
import "os"
|
import "os"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var i uint64 =
|
var i uint64 =
|
||||||
' ' +
|
' ' +
|
||||||
'a' +
|
'a' +
|
||||||
'ä' +
|
'ä' +
|
||||||
'本' +
|
'本' +
|
||||||
'\a' +
|
'\a' +
|
||||||
'\b' +
|
'\b' +
|
||||||
'\f' +
|
'\f' +
|
||||||
'\n' +
|
'\n' +
|
||||||
'\r' +
|
'\r' +
|
||||||
'\t' +
|
'\t' +
|
||||||
'\v' +
|
'\v' +
|
||||||
'\\' +
|
'\\' +
|
||||||
'\'' +
|
'\'' +
|
||||||
'\000' +
|
'\000' +
|
||||||
'\123' +
|
'\123' +
|
||||||
'\x00' +
|
'\x00' +
|
||||||
'\xca' +
|
'\xca' +
|
||||||
'\xFE' +
|
'\xFE' +
|
||||||
'\u0123' +
|
'\u0123' +
|
||||||
'\ubabe' +
|
'\ubabe' +
|
||||||
'\U0123ABCD' +
|
'\U0123ABCD' +
|
||||||
'\Ucafebabe'
|
'\Ucafebabe'
|
||||||
;
|
;
|
||||||
if '\Ucafebabe' != 0xcafebabe {
|
if '\Ucafebabe' != 0xcafebabe {
|
||||||
print("cafebabe wrong\n");
|
print("cafebabe wrong\n");
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
if i != 0xcc238de1 {
|
if i != 0xcc238de1 {
|
||||||
print("number is ", i, " should be ", 0xcc238de1, "\n");
|
print("number is ", i, " should be ", 0xcc238de1, "\n");
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,11 +7,11 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var i int;
|
var i int;
|
||||||
i = '\'';
|
i = '\'';
|
||||||
i = '\\';
|
i = '\\';
|
||||||
var s string;
|
var s string;
|
||||||
s = "\"";
|
s = "\"";
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
bug.go:5: unknown escape sequence: '
|
bug.go:5: unknown escape sequence: '
|
||||||
|
@ -7,6 +7,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var x int;
|
var x int;
|
||||||
x := 0; // ERROR "declar|:="
|
x := 0; // ERROR "declar|:="
|
||||||
}
|
}
|
||||||
|
@ -7,5 +7,5 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
func main (x int) { // GCCGO_ERROR "previous"
|
func main (x int) { // GCCGO_ERROR "previous"
|
||||||
var x int; // ERROR "redecl|redefinition"
|
var x int; // ERROR "redecl|redefinition"
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
func f() int {
|
func f() int {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
const n = f(); // ERROR "const"
|
const n = f(); // ERROR "const"
|
||||||
}
|
}
|
||||||
|
@ -7,14 +7,14 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
c := 10;
|
c := 10;
|
||||||
d := 7;
|
d := 7;
|
||||||
var x [10]int;
|
var x [10]int;
|
||||||
i := 0;
|
i := 0;
|
||||||
/* this works:
|
/* this works:
|
||||||
q := c/d;
|
q := c/d;
|
||||||
x[i] = q;
|
x[i] = q;
|
||||||
*/
|
*/
|
||||||
// this doesn't:
|
// this doesn't:
|
||||||
x[i] = c/d; // BUG segmentation fault
|
x[i] = c/d; // BUG segmentation fault
|
||||||
}
|
}
|
||||||
|
@ -7,5 +7,5 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var len int; // len should not be a keyword - this doesn't compile
|
var len int; // len should not be a keyword - this doesn't compile
|
||||||
}
|
}
|
||||||
|
@ -7,15 +7,15 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
type T struct {
|
type T struct {
|
||||||
s string;
|
s string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
s := "";
|
s := "";
|
||||||
l1 := len(s);
|
l1 := len(s);
|
||||||
var t T;
|
var t T;
|
||||||
l2 := len(t.s); // BUG: cannot take len() of a string field
|
l2 := len(t.s); // BUG: cannot take len() of a string field
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -10,10 +10,10 @@ type Box struct {};
|
|||||||
var m map[string] *Box;
|
var m map[string] *Box;
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
m := make(map[string] *Box);
|
m := make(map[string] *Box);
|
||||||
s := "foo";
|
s := "foo";
|
||||||
var x *Box = nil;
|
var x *Box = nil;
|
||||||
m[s] = x;
|
m[s] = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -7,5 +7,5 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var s string = nil; // ERROR "illegal|invalid|incompatible|cannot"
|
var s string = nil; // ERROR "illegal|invalid|incompatible|cannot"
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ pc: 0x4558
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* An array composite literal needs to be created freshly every time.
|
/* An array composite literal needs to be created freshly every time.
|
||||||
It is a "construction" of an array after all. If I pass the address
|
It is a "construction" of an array after all. If I pass the address
|
||||||
of the array to some function, it may store it globally. Same applies
|
of the array to some function, it may store it globally. Same applies
|
||||||
to struct literals.
|
to struct literals.
|
||||||
*/
|
*/
|
||||||
|
@ -3,4 +3,5 @@
|
|||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package bug0
|
package bug0
|
||||||
|
|
||||||
const A = -1
|
const A = -1
|
||||||
|
@ -3,5 +3,6 @@
|
|||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package bug1
|
package bug1
|
||||||
|
|
||||||
import "./bug0"
|
import "./bug0"
|
||||||
|
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
package main
|
package main
|
||||||
import os "os"
|
import os "os"
|
||||||
func f() (os int) {
|
func f() (os int) {
|
||||||
// In the next line "os" should refer to the result variable, not
|
// In the next line "os" should refer to the result variable, not
|
||||||
// to the package.
|
// to the package.
|
||||||
v := os.Open("", 0, 0); // ERROR "undefined"
|
v := os.Open("", 0, 0); // ERROR "undefined"
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
@ -14,11 +14,11 @@ func f(a float) float {
|
|||||||
/*
|
/*
|
||||||
6g bugs/bug109.go
|
6g bugs/bug109.go
|
||||||
bugs/bug109.go:5: illegal types for operand: MUL
|
bugs/bug109.go:5: illegal types for operand: MUL
|
||||||
(<float64>FLOAT64)
|
(<float64>FLOAT64)
|
||||||
(<float32>FLOAT32)
|
(<float32>FLOAT32)
|
||||||
bugs/bug109.go:5: illegal types for operand: AS
|
bugs/bug109.go:5: illegal types for operand: AS
|
||||||
(<float64>FLOAT64)
|
(<float64>FLOAT64)
|
||||||
bugs/bug109.go:6: illegal types for operand: RETURN
|
bugs/bug109.go:6: illegal types for operand: RETURN
|
||||||
(<float32>FLOAT32)
|
(<float32>FLOAT32)
|
||||||
(<float64>FLOAT64)
|
(<float64>FLOAT64)
|
||||||
*/
|
*/
|
||||||
|
@ -9,12 +9,12 @@ type I interface { };
|
|||||||
func foo1(i int) int { return i }
|
func foo1(i int) int { return i }
|
||||||
func foo2(i int32) int32 { return i }
|
func foo2(i int32) int32 { return i }
|
||||||
func main() {
|
func main() {
|
||||||
var i I;
|
var i I;
|
||||||
i = 1;
|
i = 1;
|
||||||
var v1 = i.(int);
|
var v1 = i.(int);
|
||||||
if foo1(v1) != 1 { panicln(1) }
|
if foo1(v1) != 1 { panicln(1) }
|
||||||
var v2 = int32(i.(int));
|
var v2 = int32(i.(int));
|
||||||
if foo2(v2) != 1 { panicln(2) }
|
if foo2(v2) != 1 { panicln(2) }
|
||||||
var v3 = i.(int32); // This type conversion should fail at runtime.
|
var v3 = i.(int32); // This type conversion should fail at runtime.
|
||||||
if foo2(v3) != 1 { panicln(3) }
|
if foo2(v3) != 1 { panicln(3) }
|
||||||
}
|
}
|
||||||
|
@ -8,18 +8,18 @@ package main
|
|||||||
type S struct { a int }
|
type S struct { a int }
|
||||||
type PS *S
|
type PS *S
|
||||||
func (p *S) get() int {
|
func (p *S) get() int {
|
||||||
return p.a
|
return p.a
|
||||||
}
|
}
|
||||||
|
|
||||||
func fn(p PS) int {
|
func fn(p PS) int {
|
||||||
// p has type PS, and PS has no methods.
|
// p has type PS, and PS has no methods.
|
||||||
// (a compiler might see that p is a pointer
|
// (a compiler might see that p is a pointer
|
||||||
// and go looking in S without noticing PS.)
|
// and go looking in S without noticing PS.)
|
||||||
return p.get() // ERROR "undefined"
|
return p.get() // ERROR "undefined"
|
||||||
}
|
}
|
||||||
func main() {
|
func main() {
|
||||||
s := S{1};
|
s := S{1};
|
||||||
if s.get() != 1 {
|
if s.get() != 1 {
|
||||||
panic()
|
panic()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
func Send(c chan int) int {
|
func Send(c chan int) int {
|
||||||
select {
|
select {
|
||||||
default:
|
default:
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
package main
|
package main
|
||||||
const ( F = 1 )
|
const ( F = 1 )
|
||||||
func fn(i int) int {
|
func fn(i int) int {
|
||||||
if i == F() { // ERROR "func"
|
if i == F() { // ERROR "func"
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
package main
|
package main
|
||||||
func main() {
|
func main() {
|
||||||
var x int64 = 0;
|
var x int64 = 0;
|
||||||
println(x != nil); // ERROR "illegal|incompatible|nil"
|
println(x != nil); // ERROR "illegal|incompatible|nil"
|
||||||
println(0 != nil); // ERROR "illegal|incompatible|nil"
|
println(0 != nil); // ERROR "illegal|incompatible|nil"
|
||||||
}
|
}
|
||||||
|
@ -14,9 +14,9 @@ type S struct { v int }
|
|||||||
func (p *S) send(c chan <- int) { c <- p.v }
|
func (p *S) send(c chan <- int) { c <- p.v }
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
s := S{0};
|
s := S{0};
|
||||||
var i I = &s;
|
var i I = &s;
|
||||||
c := make(chan int);
|
c := make(chan int);
|
||||||
go i.send(c);
|
go i.send(c);
|
||||||
os.Exit(<-c);
|
os.Exit(<-c);
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
const a uint64 = 10;
|
const a uint64 = 10;
|
||||||
var b int64 = a; // ERROR "convert|cannot|incompatible"
|
var b int64 = a; // ERROR "convert|cannot|incompatible"
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ type T struct {}
|
|||||||
func (t *T) foo() {}
|
func (t *T) foo() {}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
t := new(T);
|
t := new(T);
|
||||||
var i interface {};
|
var i interface {};
|
||||||
f, ok := i.(Foo);
|
f, ok := i.(Foo);
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ panic PC=xxx
|
|||||||
== fixedbugs/
|
== fixedbugs/
|
||||||
|
|
||||||
=========== fixedbugs/bug016.go
|
=========== fixedbugs/bug016.go
|
||||||
fixedbugs/bug016.go:7: constant -3 overflows uint
|
fixedbugs/bug016.go:11: constant -3 overflows uint
|
||||||
|
|
||||||
=========== fixedbugs/bug027.go
|
=========== fixedbugs/bug027.go
|
||||||
hi
|
hi
|
||||||
@ -121,7 +121,7 @@ do break
|
|||||||
broke
|
broke
|
||||||
|
|
||||||
=========== fixedbugs/bug081.go
|
=========== fixedbugs/bug081.go
|
||||||
fixedbugs/bug081.go:5: fatal error: typecheck loop
|
fixedbugs/bug081.go:9: fatal error: typecheck loop
|
||||||
|
|
||||||
=========== fixedbugs/bug093.go
|
=========== fixedbugs/bug093.go
|
||||||
M
|
M
|
||||||
|
@ -9,17 +9,16 @@ package main
|
|||||||
import "os"
|
import "os"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
s :=
|
s := 0 +
|
||||||
0 +
|
123 +
|
||||||
123 +
|
0123 +
|
||||||
0123 +
|
0000 +
|
||||||
0000 +
|
0x0 +
|
||||||
0x0 +
|
0x123 +
|
||||||
0x123 +
|
0X0 +
|
||||||
0X0 +
|
0X123;
|
||||||
0X123;
|
if s != 788 {
|
||||||
if s != 788 {
|
print("s is ", s, "; should be 788\n");
|
||||||
print("s is ", s, "; should be 788\n");
|
os.Exit(1);
|
||||||
os.Exit(1);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -13,10 +13,10 @@ import "os"
|
|||||||
var fail int
|
var fail int
|
||||||
|
|
||||||
func check(b bool, msg string) {
|
func check(b bool, msg string) {
|
||||||
if (!b) {
|
if (!b) {
|
||||||
println("failure in", msg);
|
println("failure in", msg);
|
||||||
fail++;
|
fail++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type I1 interface { Get() int; Put(int); }
|
type I1 interface { Get() int; Put(int); }
|
||||||
@ -26,27 +26,27 @@ func (p S1) Get() int { return p.i }
|
|||||||
func (p S1) Put(i int) { p.i = i }
|
func (p S1) Put(i int) { p.i = i }
|
||||||
|
|
||||||
func f1() {
|
func f1() {
|
||||||
s := S1{1};
|
s := S1{1};
|
||||||
var i I1 = s;
|
var i I1 = s;
|
||||||
i.Put(2);
|
i.Put(2);
|
||||||
check(i.Get() == 1, "f1 i");
|
check(i.Get() == 1, "f1 i");
|
||||||
check(s.i == 1, "f1 s");
|
check(s.i == 1, "f1 s");
|
||||||
}
|
}
|
||||||
|
|
||||||
func f2() {
|
func f2() {
|
||||||
s := S1{1};
|
s := S1{1};
|
||||||
var i I1 = &s;
|
var i I1 = &s;
|
||||||
i.Put(2);
|
i.Put(2);
|
||||||
check(i.Get() == 1, "f2 i");
|
check(i.Get() == 1, "f2 i");
|
||||||
check(s.i == 1, "f2 s");
|
check(s.i == 1, "f2 s");
|
||||||
}
|
}
|
||||||
|
|
||||||
func f3() {
|
func f3() {
|
||||||
s := &S1{1};
|
s := &S1{1};
|
||||||
var i I1 = s;
|
var i I1 = s;
|
||||||
i.Put(2);
|
i.Put(2);
|
||||||
check(i.Get() == 1, "f3 i");
|
check(i.Get() == 1, "f3 i");
|
||||||
check(s.i == 1, "f3 s");
|
check(s.i == 1, "f3 s");
|
||||||
}
|
}
|
||||||
|
|
||||||
type S2 struct { i int }
|
type S2 struct { i int }
|
||||||
@ -54,27 +54,27 @@ func (p *S2) Get() int { return p.i }
|
|||||||
func (p *S2) Put(i int) { p.i = i }
|
func (p *S2) Put(i int) { p.i = i }
|
||||||
|
|
||||||
// func f4() {
|
// func f4() {
|
||||||
// s := S2{1};
|
// s := S2{1};
|
||||||
// var i I1 = s;
|
// var i I1 = s;
|
||||||
// i.Put(2);
|
// i.Put(2);
|
||||||
// check(i.Get() == 2, "f4 i");
|
// check(i.Get() == 2, "f4 i");
|
||||||
// check(s.i == 1, "f4 s");
|
// check(s.i == 1, "f4 s");
|
||||||
// }
|
// }
|
||||||
|
|
||||||
func f5() {
|
func f5() {
|
||||||
s := S2{1};
|
s := S2{1};
|
||||||
var i I1 = &s;
|
var i I1 = &s;
|
||||||
i.Put(2);
|
i.Put(2);
|
||||||
check(i.Get() == 2, "f5 i");
|
check(i.Get() == 2, "f5 i");
|
||||||
check(s.i == 2, "f5 s");
|
check(s.i == 2, "f5 s");
|
||||||
}
|
}
|
||||||
|
|
||||||
func f6() {
|
func f6() {
|
||||||
s := &S2{1};
|
s := &S2{1};
|
||||||
var i I1 = s;
|
var i I1 = s;
|
||||||
i.Put(2);
|
i.Put(2);
|
||||||
check(i.Get() == 2, "f6 i");
|
check(i.Get() == 2, "f6 i");
|
||||||
check(s.i == 2, "f6 s");
|
check(s.i == 2, "f6 s");
|
||||||
}
|
}
|
||||||
|
|
||||||
type I2 interface { Get() int64; Put(int64); }
|
type I2 interface { Get() int64; Put(int64); }
|
||||||
@ -84,27 +84,27 @@ func (p S3) Get() int64 { return p.l }
|
|||||||
func (p S3) Put(i int64) { p.l = i }
|
func (p S3) Put(i int64) { p.l = i }
|
||||||
|
|
||||||
func f7() {
|
func f7() {
|
||||||
s := S3{1, 2, 3, 4};
|
s := S3{1, 2, 3, 4};
|
||||||
var i I2 = s;
|
var i I2 = s;
|
||||||
i.Put(5);
|
i.Put(5);
|
||||||
check(i.Get() == 4, "f7 i");
|
check(i.Get() == 4, "f7 i");
|
||||||
check(s.l == 4, "f7 s");
|
check(s.l == 4, "f7 s");
|
||||||
}
|
}
|
||||||
|
|
||||||
func f8() {
|
func f8() {
|
||||||
s := S3{1, 2, 3, 4};
|
s := S3{1, 2, 3, 4};
|
||||||
var i I2 = &s;
|
var i I2 = &s;
|
||||||
i.Put(5);
|
i.Put(5);
|
||||||
check(i.Get() == 4, "f8 i");
|
check(i.Get() == 4, "f8 i");
|
||||||
check(s.l == 4, "f8 s");
|
check(s.l == 4, "f8 s");
|
||||||
}
|
}
|
||||||
|
|
||||||
func f9() {
|
func f9() {
|
||||||
s := &S3{1, 2, 3, 4};
|
s := &S3{1, 2, 3, 4};
|
||||||
var i I2 = s;
|
var i I2 = s;
|
||||||
i.Put(5);
|
i.Put(5);
|
||||||
check(i.Get() == 4, "f9 i");
|
check(i.Get() == 4, "f9 i");
|
||||||
check(s.l == 4, "f9 s");
|
check(s.l == 4, "f9 s");
|
||||||
}
|
}
|
||||||
|
|
||||||
type S4 struct { i, j, k, l int64 }
|
type S4 struct { i, j, k, l int64 }
|
||||||
@ -112,43 +112,43 @@ func (p *S4) Get() int64 { return p.l }
|
|||||||
func (p *S4) Put(i int64) { p.l = i }
|
func (p *S4) Put(i int64) { p.l = i }
|
||||||
|
|
||||||
// func f10() {
|
// func f10() {
|
||||||
// s := S4{1, 2, 3, 4};
|
// s := S4{1, 2, 3, 4};
|
||||||
// var i I2 = s;
|
// var i I2 = s;
|
||||||
// i.Put(5);
|
// i.Put(5);
|
||||||
// check(i.Get() == 5, "f10 i");
|
// check(i.Get() == 5, "f10 i");
|
||||||
// check(s.l == 4, "f10 s");
|
// check(s.l == 4, "f10 s");
|
||||||
// }
|
// }
|
||||||
|
|
||||||
func f11() {
|
func f11() {
|
||||||
s := S4{1, 2, 3, 4};
|
s := S4{1, 2, 3, 4};
|
||||||
var i I2 = &s;
|
var i I2 = &s;
|
||||||
i.Put(5);
|
i.Put(5);
|
||||||
check(i.Get() == 5, "f11 i");
|
check(i.Get() == 5, "f11 i");
|
||||||
check(s.l == 5, "f11 s");
|
check(s.l == 5, "f11 s");
|
||||||
}
|
}
|
||||||
|
|
||||||
func f12() {
|
func f12() {
|
||||||
s := &S4{1, 2, 3, 4};
|
s := &S4{1, 2, 3, 4};
|
||||||
var i I2 = s;
|
var i I2 = s;
|
||||||
i.Put(5);
|
i.Put(5);
|
||||||
check(i.Get() == 5, "f12 i");
|
check(i.Get() == 5, "f12 i");
|
||||||
check(s.l == 5, "f12 s");
|
check(s.l == 5, "f12 s");
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
f1();
|
f1();
|
||||||
f2();
|
f2();
|
||||||
f3();
|
f3();
|
||||||
// f4();
|
// f4();
|
||||||
f5();
|
f5();
|
||||||
f6();
|
f6();
|
||||||
f7();
|
f7();
|
||||||
f8();
|
f8();
|
||||||
f9();
|
f9();
|
||||||
// f10();
|
// f10();
|
||||||
f11();
|
f11();
|
||||||
f12();
|
f12();
|
||||||
if fail > 0 {
|
if fail > 0 {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ func
|
|||||||
r(c chan int, m int)
|
r(c chan int, m int)
|
||||||
{
|
{
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case r := <- c:
|
case r := <- c:
|
||||||
if h[r] != 1 {
|
if h[r] != 1 {
|
||||||
panicln("r",
|
panicln("r",
|
||||||
@ -28,7 +28,7 @@ r(c chan int, m int)
|
|||||||
}
|
}
|
||||||
h[r] = 2;
|
h[r] = 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func
|
func
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
// 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
|
package main
|
||||||
|
|
||||||
import "rand"
|
import "rand"
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
// 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
|
package main
|
||||||
|
|
||||||
import "rand"
|
import "rand"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// errchk $G $D/$F.go
|
// # errchk $G $D/$F.go
|
||||||
|
|
||||||
// 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
|
||||||
|
3
test/run
3
test/run
@ -1,8 +1,9 @@
|
|||||||
#!/bin/sh
|
|
||||||
# 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.
|
||||||
|
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
case X"$GOARCH" in
|
case X"$GOARCH" in
|
||||||
Xamd64)
|
Xamd64)
|
||||||
export A=6
|
export A=6
|
||||||
|
@ -38,5 +38,5 @@ func Sieve() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
Sieve()
|
Sieve()
|
||||||
}
|
}
|
||||||
|
@ -68,14 +68,14 @@ func main() {
|
|||||||
"\a\b\f\n\r\t\v\\\"",
|
"\a\b\f\n\r\t\v\\\"",
|
||||||
"backslashes");
|
"backslashes");
|
||||||
assert("\\a\\b\\f\\n\\r\\t\\v\\\\\\\"",
|
assert("\\a\\b\\f\\n\\r\\t\\v\\\\\\\"",
|
||||||
`\a\b\f\n\r\t\v\\\"`,
|
`\a\b\f\n\r\t\v\\\"`,
|
||||||
"backslashes (backquote)");
|
"backslashes (backquote)");
|
||||||
assert("\x00\x53\000\xca\376S몾몾",
|
assert("\x00\x53\000\xca\376S몾몾",
|
||||||
"\000\123\x00\312\xFE\u0053\ubabe\U0000babe",
|
"\000\123\x00\312\xFE\u0053\ubabe\U0000babe",
|
||||||
"backslashes 2");
|
"backslashes 2");
|
||||||
assert("\\000\\123\\x00\\312\\xFE\\u0123\\ubabe\\U0000babe",
|
assert("\\000\\123\\x00\\312\\xFE\\u0123\\ubabe\\U0000babe",
|
||||||
`\000\123\x00\312\xFE\u0123\ubabe\U0000babe`,
|
`\000\123\x00\312\xFE\u0123\ubabe\U0000babe`,
|
||||||
"backslashes 2 (backquote)");
|
"backslashes 2 (backquote)");
|
||||||
assert("\\x\\u\\U\\", `\x\u\U\`, "backslash 3 (backquote)");
|
assert("\\x\\u\\U\\", `\x\u\U\`, "backslash 3 (backquote)");
|
||||||
|
|
||||||
// test large runes. perhaps not the most logical place for this test.
|
// test large runes. perhaps not the most logical place for this test.
|
||||||
|
@ -6,10 +6,10 @@
|
|||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import(
|
import (
|
||||||
"fmt";
|
"fmt";
|
||||||
"os";
|
"os";
|
||||||
"utf8";
|
"utf8";
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -7,77 +7,77 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
const
|
const
|
||||||
a_const = 0
|
a_const = 0
|
||||||
|
|
||||||
const (
|
const (
|
||||||
pi = /* the usual */ 3.14159265358979323;
|
pi = /* the usual */ 3.14159265358979323;
|
||||||
e = 2.718281828;
|
e = 2.718281828;
|
||||||
mask1 int = 1 << iota;
|
mask1 int = 1 << iota;
|
||||||
mask2 = 1 << iota;
|
mask2 = 1 << iota;
|
||||||
mask3 = 1 << iota;
|
mask3 = 1 << iota;
|
||||||
mask4 = 1 << iota;
|
mask4 = 1 << iota;
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
Empty interface {};
|
Empty interface {};
|
||||||
Point struct {
|
Point struct {
|
||||||
x, y int;
|
x, y int;
|
||||||
};
|
};
|
||||||
Point2 Point
|
Point2 Point
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p *Point) Initialize(x, y int) *Point {
|
func (p *Point) Initialize(x, y int) *Point {
|
||||||
p.x, p.y = x, y;
|
p.x, p.y = x, y;
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Point) Distance() int {
|
func (p *Point) Distance() int {
|
||||||
return p.x * p.x + p.y * p.y;
|
return p.x * p.x + p.y * p.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
x1 int;
|
x1 int;
|
||||||
x2 int;
|
x2 int;
|
||||||
u, v, w float
|
u, v, w float
|
||||||
)
|
)
|
||||||
|
|
||||||
func foo() {}
|
func foo() {}
|
||||||
|
|
||||||
func min(x, y int) int {
|
func min(x, y int) int {
|
||||||
if x < y { return x; }
|
if x < y { return x; }
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
func swap(x, y int) (u, v int) {
|
func swap(x, y int) (u, v int) {
|
||||||
u = y;
|
u = y;
|
||||||
v = x;
|
v = x;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
func control_structs() {
|
func control_structs() {
|
||||||
var p *Point = new(Point).Initialize(2, 3);
|
var p *Point = new(Point).Initialize(2, 3);
|
||||||
i := p.Distance();
|
i := p.Distance();
|
||||||
var f float = 0.3;
|
var f float = 0.3;
|
||||||
for {}
|
for {}
|
||||||
for {};
|
for {};
|
||||||
for j := 0; j < i; j++ {
|
for j := 0; j < i; j++ {
|
||||||
if i == 0 {
|
if i == 0 {
|
||||||
} else i = 0;
|
} else i = 0;
|
||||||
var x float;
|
var x float;
|
||||||
}
|
}
|
||||||
foo: // a label
|
foo: // a label
|
||||||
var j int;
|
var j int;
|
||||||
switch y := 0; true {
|
switch y := 0; true {
|
||||||
case i < y:
|
case i < y:
|
||||||
fallthrough;
|
fallthrough;
|
||||||
case i < j:
|
case i < j:
|
||||||
case i == 0, i == 1, i == j:
|
case i == 0, i == 1, i == j:
|
||||||
i++; i++;
|
i++; i++;
|
||||||
goto foo;
|
goto foo;
|
||||||
default:
|
default:
|
||||||
i = -+-+i;
|
i = -+-+i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -7,14 +7,14 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var x int = 1;
|
var x int = 1;
|
||||||
if x != 1 { panic("found ", x, ", expected 1\n"); }
|
if x != 1 { panic("found ", x, ", expected 1\n"); }
|
||||||
{
|
{
|
||||||
var x int = x + 1;
|
var x int = x + 1;
|
||||||
if x != 2 { panic("found ", x, ", expected 2\n"); }
|
if x != 2 { panic("found ", x, ", expected 2\n"); }
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
x := x + 1;
|
x := x + 1;
|
||||||
if x != 2 { panic("found ", x, ", expected 2\n"); }
|
if x != 2 { panic("found ", x, ", expected 2\n"); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user