Commit 581530e4 authored by Robert Griesemer's avatar Robert Griesemer

make test/ken safe for optional semis

R=rsc, ken2, ken3
https://golang.org/cl/174042
parent d08d33f3
...@@ -7,8 +7,7 @@ ...@@ -7,8 +7,7 @@
package main package main
func func
setpd(a []int) setpd(a []int) {
{
// print("setpd a=", a, " len=", len(a), " cap=", cap(a), "\n"); // print("setpd a=", a, " len=", len(a), " cap=", cap(a), "\n");
for i:=0; i<len(a); i++ { for i:=0; i<len(a); i++ {
a[i] = i; a[i] = i;
...@@ -16,8 +15,7 @@ setpd(a []int) ...@@ -16,8 +15,7 @@ setpd(a []int)
} }
func func
sumpd(a []int) int sumpd(a []int) int {
{
// print("sumpd a=", a, " len=", len(a), " cap=", cap(a), "\n"); // print("sumpd a=", a, " len=", len(a), " cap=", cap(a), "\n");
t := 0; t := 0;
for i:=0; i<len(a); i++ { for i:=0; i<len(a); i++ {
...@@ -28,8 +26,7 @@ sumpd(a []int) int ...@@ -28,8 +26,7 @@ sumpd(a []int) int
} }
func func
setpf(a *[20]int) setpf(a *[20]int) {
{
// print("setpf a=", a, " len=", len(a), " cap=", cap(a), "\n"); // print("setpf a=", a, " len=", len(a), " cap=", cap(a), "\n");
for i:=0; i<len(a); i++ { for i:=0; i<len(a); i++ {
a[i] = i; a[i] = i;
...@@ -37,8 +34,7 @@ setpf(a *[20]int) ...@@ -37,8 +34,7 @@ setpf(a *[20]int)
} }
func func
sumpf(a *[20]int) int sumpf(a *[20]int) int {
{
// print("sumpf a=", a, " len=", len(a), " cap=", cap(a), "\n"); // print("sumpf a=", a, " len=", len(a), " cap=", cap(a), "\n");
t := 0; t := 0;
for i:=0; i<len(a); i++ { for i:=0; i<len(a); i++ {
...@@ -49,8 +45,7 @@ sumpf(a *[20]int) int ...@@ -49,8 +45,7 @@ sumpf(a *[20]int) int
} }
func func
res(t int, lb, hb int) res(t int, lb, hb int) {
{
sb := (hb-lb)*(hb+lb-1)/2; sb := (hb-lb)*(hb+lb-1)/2;
if t != sb { if t != sb {
print( "lb=", lb, print( "lb=", lb,
...@@ -64,8 +59,7 @@ res(t int, lb, hb int) ...@@ -64,8 +59,7 @@ res(t int, lb, hb int)
// call ptr dynamic with ptr dynamic // call ptr dynamic with ptr dynamic
func func
testpdpd() testpdpd() {
{
a := make([]int, 10, 100); a := make([]int, 10, 100);
if len(a) != 10 && cap(a) != 100 { if len(a) != 10 && cap(a) != 100 {
panic("len and cap from new: ", len(a), " ", cap(a), "\n"); panic("len and cap from new: ", len(a), " ", cap(a), "\n");
...@@ -83,8 +77,7 @@ testpdpd() ...@@ -83,8 +77,7 @@ testpdpd()
// call ptr fixed with ptr fixed // call ptr fixed with ptr fixed
func func
testpfpf() testpfpf() {
{
var a [20]int; var a [20]int;
setpf(&a); setpf(&a);
...@@ -93,8 +86,7 @@ testpfpf() ...@@ -93,8 +86,7 @@ testpfpf()
// call ptr dynamic with ptr fixed from new // call ptr dynamic with ptr fixed from new
func func
testpdpf1() testpdpf1() {
{
a := new([40]int); a := new([40]int);
setpd(a); setpd(a);
res(sumpd(a), 0, 40); res(sumpd(a), 0, 40);
...@@ -105,8 +97,7 @@ testpdpf1() ...@@ -105,8 +97,7 @@ testpdpf1()
// call ptr dynamic with ptr fixed from var // call ptr dynamic with ptr fixed from var
func func
testpdpf2() testpdpf2() {
{
var a [80]int; var a [80]int;
setpd(&a); setpd(&a);
...@@ -115,8 +106,7 @@ testpdpf2() ...@@ -115,8 +106,7 @@ testpdpf2()
// generate bounds error with ptr dynamic // generate bounds error with ptr dynamic
func func
testpdfault() testpdfault() {
{
a := make([]int, 100); a := make([]int, 100);
print("good\n"); print("good\n");
...@@ -130,8 +120,7 @@ testpdfault() ...@@ -130,8 +120,7 @@ testpdfault()
// generate bounds error with ptr fixed // generate bounds error with ptr fixed
func func
testfdfault() testfdfault() {
{
var a [80]int; var a [80]int;
print("good\n"); print("good\n");
...@@ -145,8 +134,7 @@ testfdfault() ...@@ -145,8 +134,7 @@ testfdfault()
} }
func func
main() main() {
{
testpdpd(); testpdpd();
testpfpf(); testpfpf();
testpdpf1(); testpdpf1();
......
...@@ -12,8 +12,7 @@ import "runtime" ...@@ -12,8 +12,7 @@ import "runtime"
var randx int; var randx int;
func func
nrand(n int) int nrand(n int) int {
{
randx += 10007; randx += 10007;
if randx >= 1000000 { if randx >= 1000000 {
randx -= 1000000; randx -= 1000000;
...@@ -21,9 +20,7 @@ nrand(n int) int ...@@ -21,9 +20,7 @@ nrand(n int) int
return randx%n; return randx%n;
} }
type Chan type Chan struct {
struct
{
sc,rc chan int; // send and recv chan sc,rc chan int; // send and recv chan
sv,rv int; // send and recv seq sv,rv int; // send and recv seq
} }
...@@ -38,14 +35,12 @@ var ...@@ -38,14 +35,12 @@ var
) )
func func
init() init() {
{
nc = new(Chan); nc = new(Chan);
} }
func func
mkchan(c,n int) []*Chan mkchan(c,n int) []*Chan {
{
ca := make([]*Chan, n); ca := make([]*Chan, n);
for i:=0; i<n; i++ { for i:=0; i<n; i++ {
cval = cval+100; cval = cval+100;
...@@ -60,8 +55,7 @@ mkchan(c,n int) []*Chan ...@@ -60,8 +55,7 @@ mkchan(c,n int) []*Chan
} }
func func
expect(v, v0 int) (newv int) expect(v, v0 int) (newv int) {
{
if v == v0 { if v == v0 {
if v%100 == 75 { if v%100 == 75 {
return end; return end;
...@@ -71,9 +65,7 @@ expect(v, v0 int) (newv int) ...@@ -71,9 +65,7 @@ expect(v, v0 int) (newv int)
panic("got ", v, " expected ", v0+1, "\n"); panic("got ", v, " expected ", v0+1, "\n");
} }
func (c *Chan) func (c *Chan) send() bool {
send() bool
{
// print("send ", c.sv, "\n"); // print("send ", c.sv, "\n");
tots++; tots++;
c.sv = expect(c.sv, c.sv); c.sv = expect(c.sv, c.sv);
...@@ -85,8 +77,7 @@ send() bool ...@@ -85,8 +77,7 @@ send() bool
} }
func func
send(c *Chan) send(c *Chan) {
{
nproc++; // total goroutines running nproc++; // total goroutines running
for { for {
for r:=nrand(10); r>=0; r-- { for r:=nrand(10); r>=0; r-- {
...@@ -100,9 +91,7 @@ send(c *Chan) ...@@ -100,9 +91,7 @@ send(c *Chan)
nproc--; nproc--;
} }
func (c *Chan) func (c *Chan) recv(v int) bool {
recv(v int) bool
{
// print("recv ", v, "\n"); // print("recv ", v, "\n");
totr++; totr++;
c.rv = expect(c.rv, v); c.rv = expect(c.rv, v);
...@@ -114,8 +103,7 @@ recv(v int) bool ...@@ -114,8 +103,7 @@ recv(v int) bool
} }
func func
recv(c *Chan) recv(c *Chan) {
{
var v int; var v int;
nproc++; // total goroutines running nproc++; // total goroutines running
...@@ -132,8 +120,7 @@ recv(c *Chan) ...@@ -132,8 +120,7 @@ recv(c *Chan)
} }
func func
sel(r0,r1,r2,r3, s0,s1,s2,s3 *Chan) sel(r0,r1,r2,r3, s0,s1,s2,s3 *Chan) {
{
var v int; var v int;
nproc++; // total goroutines running nproc++; // total goroutines running
...@@ -196,16 +183,14 @@ sel(r0,r1,r2,r3, s0,s1,s2,s3 *Chan) ...@@ -196,16 +183,14 @@ sel(r0,r1,r2,r3, s0,s1,s2,s3 *Chan)
// direct send to direct recv // direct send to direct recv
func func
test1(c *Chan) test1(c *Chan) {
{
go send(c); go send(c);
go recv(c); go recv(c);
} }
// direct send to select recv // direct send to select recv
func func
test2(c int) test2(c int) {
{
ca := mkchan(c,4); ca := mkchan(c,4);
go send(ca[0]); go send(ca[0]);
...@@ -218,8 +203,7 @@ test2(c int) ...@@ -218,8 +203,7 @@ test2(c int)
// select send to direct recv // select send to direct recv
func func
test3(c int) test3(c int) {
{
ca := mkchan(c,4); ca := mkchan(c,4);
go recv(ca[0]); go recv(ca[0]);
...@@ -232,8 +216,7 @@ test3(c int) ...@@ -232,8 +216,7 @@ test3(c int)
// select send to select recv // select send to select recv
func func
test4(c int) test4(c int) {
{
ca := mkchan(c,4); ca := mkchan(c,4);
go sel(nc,nc,nc,nc, ca[0],ca[1],ca[2],ca[3]); go sel(nc,nc,nc,nc, ca[0],ca[1],ca[2],ca[3]);
...@@ -241,8 +224,7 @@ test4(c int) ...@@ -241,8 +224,7 @@ test4(c int)
} }
func func
test5(c int) test5(c int) {
{
ca := mkchan(c,8); ca := mkchan(c,8);
go sel(ca[4],ca[5],ca[6],ca[7], ca[0],ca[1],ca[2],ca[3]); go sel(ca[4],ca[5],ca[6],ca[7], ca[0],ca[1],ca[2],ca[3]);
...@@ -250,8 +232,7 @@ test5(c int) ...@@ -250,8 +232,7 @@ test5(c int)
} }
func func
test6(c int) test6(c int) {
{
ca := mkchan(c,12); ca := mkchan(c,12);
go send(ca[4]); go send(ca[4]);
...@@ -270,8 +251,7 @@ test6(c int) ...@@ -270,8 +251,7 @@ test6(c int)
// wait for outstanding tests to finish // wait for outstanding tests to finish
func func
wait() wait() {
{
runtime.Gosched(); runtime.Gosched();
for nproc != 0 { for nproc != 0 {
runtime.Gosched(); runtime.Gosched();
...@@ -280,8 +260,7 @@ wait() ...@@ -280,8 +260,7 @@ wait()
// run all tests with specified buffer size // run all tests with specified buffer size
func func
tests(c int) tests(c int) {
{
ca := mkchan(c,4); ca := mkchan(c,4);
test1(ca[0]); test1(ca[0]);
test1(ca[1]); test1(ca[1]);
...@@ -307,19 +286,18 @@ tests(c int) ...@@ -307,19 +286,18 @@ tests(c int)
// run all test with 4 buffser sizes // run all test with 4 buffser sizes
func func
main() main() {
{
tests(0); tests(0);
tests(1); tests(1);
tests(10); tests(10);
tests(100); tests(100);
t := 4 // buffer sizes t := 4 * // buffer sizes
* ( 4*4 // tests 1,2,3,4 channels ( 4*4 + // tests 1,2,3,4 channels
+ 8 // test 5 channels 8 + // test 5 channels
+ 12 // test 6 channels 12 ) * // test 6 channels
) * 76; // sends/recvs on a channel 76; // sends/recvs on a channel
if tots != t || totr != t { if tots != t || totr != t {
print("tots=", tots, " totr=", totr, " sb=", t, "\n"); print("tots=", tots, " totr=", totr, " sb=", t, "\n");
......
...@@ -14,8 +14,7 @@ const W = 2; // channel buffering ...@@ -14,8 +14,7 @@ const W = 2; // channel buffering
var h [N]int; // marking of send/recv var h [N]int; // marking of send/recv
func func
r(c chan int, m int) r(c chan int, m int) {
{
for { for {
select { select {
case r := <- c: case r := <- c:
...@@ -23,7 +22,7 @@ r(c chan int, m int) ...@@ -23,7 +22,7 @@ r(c chan int, m int)
panicln("r", panicln("r",
"m=", m, "m=", m,
"r=", r, "r=", r,
"h=", h[r] "h=", h[r],
); );
} }
h[r] = 2; h[r] = 2;
...@@ -32,8 +31,7 @@ r(c chan int, m int) ...@@ -32,8 +31,7 @@ r(c chan int, m int)
} }
func func
s(c chan int) s(c chan int) {
{
for n:=0; n<N; n++ { for n:=0; n<N; n++ {
r := n; r := n;
if h[r] != 0 { if h[r] != 0 {
...@@ -45,8 +43,7 @@ s(c chan int) ...@@ -45,8 +43,7 @@ s(c chan int)
} }
func func
main() main() {
{
c := make(chan int, W); c := make(chan int, W);
for m:=0; m<M; m++ { for m:=0; m<M; m++ {
go r(c, m); go r(c, m);
......
...@@ -14,8 +14,7 @@ type SC struct{ a,b,c []int }; ...@@ -14,8 +14,7 @@ type SC struct{ a,b,c []int };
type SM struct{ a,b,c M }; type SM struct{ a,b,c M };
func func
main() main() {
{
test("s.a", s.a); test("s.a", s.a);
test("s.b", s.b); test("s.b", s.b);
test("s.c", s.c); test("s.c", s.c);
...@@ -79,8 +78,7 @@ main() ...@@ -79,8 +78,7 @@ main()
var ref = 0; var ref = 0;
func func
test(xs string, x int) test(xs string, x int) {
{
if ref >= len(answers) { if ref >= len(answers) {
println(xs, x); println(xs, x);
...@@ -119,8 +117,7 @@ var ms = map[int]S{0:S{5101,5102,5103},1:S{5104,5105,5106},2:S{5107,5108,5109}} ...@@ -119,8 +117,7 @@ var ms = map[int]S{0:S{5101,5102,5103},1:S{5104,5105,5106},2:S{5107,5108,5109}}
var mc = map[int][]int{0:[]int{5201,5202,5203}, 1:[]int{5204,5205,5206}, 2:[]int{5207,5208,5209}} var mc = map[int][]int{0:[]int{5201,5202,5203}, 1:[]int{5204,5205,5206}, 2:[]int{5207,5208,5209}}
var mm = map[int]M{0:M{0:5301,1:5302,2:5303}, 1:M{0:5304,1:5305,2:5306}, 2:M{0:5307,1:5308,2:5309}} var mm = map[int]M{0:M{0:5301,1:5302,2:5303}, 1:M{0:5304,1:5305,2:5306}, 2:M{0:5307,1:5308,2:5309}}
var answers = [...]int var answers = [...]int {
{
// s // s
1101, 1102, 1103, 1101, 1102, 1103,
......
...@@ -11,8 +11,7 @@ import "rand" ...@@ -11,8 +11,7 @@ import "rand"
const Count = 1e5 const Count = 1e5
func func
i64rand() int64 i64rand() int64 {
{
for { for {
a := int64(rand.Uint32()); a := int64(rand.Uint32());
a = (a<<32) | int64(rand.Uint32()); a = (a<<32) | int64(rand.Uint32());
...@@ -25,8 +24,7 @@ i64rand() int64 ...@@ -25,8 +24,7 @@ i64rand() int64
} }
func func
i64test(a,b,c int64) i64test(a,b,c int64) {
{
d := a/c; d := a/c;
if d != b { if d != b {
panicln("i64", a, b, c, d); panicln("i64", a, b, c, d);
...@@ -34,8 +32,7 @@ i64test(a,b,c int64) ...@@ -34,8 +32,7 @@ i64test(a,b,c int64)
} }
func func
i64run() i64run() {
{
var a, b int64; var a, b int64;
for i:=0; i<Count; i++ { for i:=0; i<Count; i++ {
...@@ -80,8 +77,7 @@ i64run() ...@@ -80,8 +77,7 @@ i64run()
} }
func func
u64rand() uint64 u64rand() uint64 {
{
a := uint64(rand.Uint32()); a := uint64(rand.Uint32());
a = (a<<32) | uint64(rand.Uint32()); a = (a<<32) | uint64(rand.Uint32());
a >>= uint(rand.Intn(64)); a >>= uint(rand.Intn(64));
...@@ -89,8 +85,7 @@ u64rand() uint64 ...@@ -89,8 +85,7 @@ u64rand() uint64
} }
func func
u64test(a,b,c uint64) u64test(a,b,c uint64) {
{
d := a/c; d := a/c;
if d != b { if d != b {
panicln("u64", a, b, c, d); panicln("u64", a, b, c, d);
...@@ -98,8 +93,7 @@ u64test(a,b,c uint64) ...@@ -98,8 +93,7 @@ u64test(a,b,c uint64)
} }
func func
u64run() u64run() {
{
var a, b uint64; var a, b uint64;
for i:=0; i<Count; i++ { for i:=0; i<Count; i++ {
...@@ -126,8 +120,7 @@ u64run() ...@@ -126,8 +120,7 @@ u64run()
} }
func func
i32rand() int32 i32rand() int32 {
{
for { for {
a := int32(rand.Uint32()); a := int32(rand.Uint32());
a >>= uint(rand.Intn(32)); a >>= uint(rand.Intn(32));
...@@ -139,8 +132,7 @@ i32rand() int32 ...@@ -139,8 +132,7 @@ i32rand() int32
} }
func func
i32test(a,b,c int32) i32test(a,b,c int32) {
{
d := a/c; d := a/c;
if d != b { if d != b {
panicln("i32", a, b, c, d); panicln("i32", a, b, c, d);
...@@ -148,8 +140,7 @@ i32test(a,b,c int32) ...@@ -148,8 +140,7 @@ i32test(a,b,c int32)
} }
func func
i32run() i32run() {
{
var a, b int32; var a, b int32;
for i:=0; i<Count; i++ { for i:=0; i<Count; i++ {
...@@ -193,16 +184,14 @@ i32run() ...@@ -193,16 +184,14 @@ i32run()
} }
func func
u32rand() uint32 u32rand() uint32 {
{
a := uint32(rand.Uint32()); a := uint32(rand.Uint32());
a >>= uint(rand.Intn(32)); a >>= uint(rand.Intn(32));
return a; return a;
} }
func func
u32test(a,b,c uint32) u32test(a,b,c uint32) {
{
d := a/c; d := a/c;
if d != b { if d != b {
panicln("u32", a, b, c, d); panicln("u32", a, b, c, d);
...@@ -210,8 +199,7 @@ u32test(a,b,c uint32) ...@@ -210,8 +199,7 @@ u32test(a,b,c uint32)
} }
func func
u32run() u32run() {
{
var a, b uint32; var a, b uint32;
for i:=0; i<Count; i++ { for i:=0; i<Count; i++ {
...@@ -238,8 +226,7 @@ u32run() ...@@ -238,8 +226,7 @@ u32run()
} }
func func
i16rand() int16 i16rand() int16 {
{
for { for {
a := int16(rand.Uint32()); a := int16(rand.Uint32());
a >>= uint(rand.Intn(16)); a >>= uint(rand.Intn(16));
...@@ -251,8 +238,7 @@ i16rand() int16 ...@@ -251,8 +238,7 @@ i16rand() int16
} }
func func
i16test(a,b,c int16) i16test(a,b,c int16) {
{
d := a/c; d := a/c;
if d != b { if d != b {
panicln("i16", a, b, c, d); panicln("i16", a, b, c, d);
...@@ -260,8 +246,7 @@ i16test(a,b,c int16) ...@@ -260,8 +246,7 @@ i16test(a,b,c int16)
} }
func func
i16run() i16run() {
{
var a, b int16; var a, b int16;
for i:=0; i<Count; i++ { for i:=0; i<Count; i++ {
...@@ -306,16 +291,14 @@ i16run() ...@@ -306,16 +291,14 @@ i16run()
} }
func func
u16rand() uint16 u16rand() uint16 {
{
a := uint16(rand.Uint32()); a := uint16(rand.Uint32());
a >>= uint(rand.Intn(16)); a >>= uint(rand.Intn(16));
return a; return a;
} }
func func
u16test(a,b,c uint16) u16test(a,b,c uint16) {
{
d := a/c; d := a/c;
if d != b { if d != b {
panicln("u16", a, b, c, d); panicln("u16", a, b, c, d);
...@@ -323,8 +306,7 @@ u16test(a,b,c uint16) ...@@ -323,8 +306,7 @@ u16test(a,b,c uint16)
} }
func func
u16run() u16run() {
{
var a, b uint16; var a, b uint16;
for i:=0; i<Count; i++ { for i:=0; i<Count; i++ {
...@@ -351,8 +333,7 @@ u16run() ...@@ -351,8 +333,7 @@ u16run()
} }
func func
i8rand() int8 i8rand() int8 {
{
for { for {
a := int8(rand.Uint32()); a := int8(rand.Uint32());
a >>= uint(rand.Intn(8)); a >>= uint(rand.Intn(8));
...@@ -364,8 +345,7 @@ i8rand() int8 ...@@ -364,8 +345,7 @@ i8rand() int8
} }
func func
i8test(a,b,c int8) i8test(a,b,c int8) {
{
d := a/c; d := a/c;
if d != b { if d != b {
panicln("i8", a, b, c, d); panicln("i8", a, b, c, d);
...@@ -373,8 +353,7 @@ i8test(a,b,c int8) ...@@ -373,8 +353,7 @@ i8test(a,b,c int8)
} }
func func
i8run() i8run() {
{
var a, b int8; var a, b int8;
for i:=0; i<Count; i++ { for i:=0; i<Count; i++ {
...@@ -415,16 +394,14 @@ i8run() ...@@ -415,16 +394,14 @@ i8run()
} }
func func
u8rand() uint8 u8rand() uint8 {
{
a := uint8(rand.Uint32()); a := uint8(rand.Uint32());
a >>= uint(rand.Intn(8)); a >>= uint(rand.Intn(8));
return a; return a;
} }
func func
u8test(a,b,c uint8) u8test(a,b,c uint8) {
{
d := a/c; d := a/c;
if d != b { if d != b {
panicln("u8", a, b, c, d); panicln("u8", a, b, c, d);
...@@ -432,8 +409,7 @@ u8test(a,b,c uint8) ...@@ -432,8 +409,7 @@ u8test(a,b,c uint8)
} }
func func
u8run() u8run() {
{
var a, b uint8; var a, b uint8;
for i:=0; i<Count; i++ { for i:=0; i<Count; i++ {
...@@ -459,8 +435,7 @@ u8run() ...@@ -459,8 +435,7 @@ u8run()
} }
func func
main() main() {
{
xtest(); xtest();
i64run(); i64run();
u64run(); u64run();
...@@ -473,6 +448,5 @@ main() ...@@ -473,6 +448,5 @@ main()
} }
func func
xtest() xtest() {
{
} }
...@@ -26,8 +26,7 @@ const ...@@ -26,8 +26,7 @@ const
) )
func func
main() main() {
{
/* ideals */ /* ideals */
if n1/d1 != q1 || n1%d1 != r1 { if n1/d1 != q1 || n1%d1 != r1 {
panicln("ideal-1", n1, d1, n1/d1, n1%d1); panicln("ideal-1", n1, d1, n1/d1, n1%d1);
......
...@@ -8,8 +8,7 @@ package main ...@@ -8,8 +8,7 @@ package main
type type
I interface I interface {
{
test1() int; test1() int;
test2() int; test2() int;
test3() int; test3() int;
...@@ -24,20 +23,15 @@ I interface ...@@ -24,20 +23,15 @@ I interface
******/ ******/
type type
SubpSubp struct SubpSubp struct {
{
a7 int; a7 int;
a int; a int;
} }
func (p *SubpSubp) func (p *SubpSubp) test7() int {
test7() int
{
if p.a != p.a7 { panicln("SubpSubp", p, p.a7) } if p.a != p.a7 { panicln("SubpSubp", p, p.a7) }
return p.a return p.a
} }
func (p *SubpSubp) func (p *SubpSubp) testx() {
testx()
{
println("SubpSubp", p, p.a7); println("SubpSubp", p, p.a7);
} }
...@@ -46,21 +40,16 @@ testx() ...@@ -46,21 +40,16 @@ testx()
******/ ******/
type type
SubpSub struct SubpSub struct {
{
a6 int; a6 int;
SubpSubp; SubpSubp;
a int; a int;
} }
func (p *SubpSub) func (p *SubpSub) test6() int {
test6() int
{
if p.a != p.a6 { panicln("SubpSub", p, p.a6) } if p.a != p.a6 { panicln("SubpSub", p, p.a6) }
return p.a return p.a
} }
func (p *SubpSub) func (p *SubpSub) testx() {
testx()
{
println("SubpSub", p, p.a6); println("SubpSub", p, p.a6);
} }
...@@ -69,14 +58,11 @@ testx() ...@@ -69,14 +58,11 @@ testx()
******/ ******/
type type
SubSubp struct SubSubp struct {
{
a5 int; a5 int;
a int; a int;
} }
func (p *SubSubp) func (p *SubSubp) test5() int {
test5() int
{
if p.a != p.a5 { panicln("SubpSub", p, p.a5) } if p.a != p.a5 { panicln("SubpSub", p, p.a5) }
return p.a return p.a
} }
...@@ -86,14 +72,11 @@ test5() int ...@@ -86,14 +72,11 @@ test5() int
******/ ******/
type type
SubSub struct SubSub struct {
{
a4 int; a4 int;
a int; a int;
} }
func (p *SubSub) func (p *SubSub) test4() int {
test4() int
{
if p.a != p.a4 { panicln("SubpSub", p, p.a4) } if p.a != p.a4 { panicln("SubpSub", p, p.a4) }
return p.a return p.a
} }
...@@ -103,16 +86,13 @@ test4() int ...@@ -103,16 +86,13 @@ test4() int
******/ ******/
type type
Subp struct Subp struct {
{
a3 int; a3 int;
*SubpSubp; *SubpSubp;
SubpSub; SubpSub;
a int; a int;
} }
func (p *Subp) func (p *Subp) test3() int {
test3() int
{
if p.a != p.a3 { panicln("SubpSub", p, p.a3) } if p.a != p.a3 { panicln("SubpSub", p, p.a3) }
return p.a return p.a
} }
...@@ -129,9 +109,7 @@ Sub struct ...@@ -129,9 +109,7 @@ Sub struct
SubSub; SubSub;
a int; a int;
} }
func (p *Sub) func (p *Sub) test2() int {
test2() int
{
if p.a != p.a2 { panicln("SubpSub", p, p.a2) } if p.a != p.a2 { panicln("SubpSub", p, p.a2) }
return p.a return p.a
} }
...@@ -141,16 +119,13 @@ test2() int ...@@ -141,16 +119,13 @@ test2() int
******/ ******/
type type
S struct S struct {
{
a1 int; a1 int;
Sub; Sub;
*Subp; *Subp;
a int; a int;
} }
func (p *S) func (p *S) test1() int {
test1() int
{
if p.a != p.a1 { panicln("SubpSub", p, p.a1) } if p.a != p.a1 { panicln("SubpSub", p, p.a1) }
return p.a return p.a
} }
...@@ -160,8 +135,7 @@ test1() int ...@@ -160,8 +135,7 @@ test1() int
******/ ******/
func func
main() main() {
{
var i I; var i I;
var s *S; var s *S;
......
...@@ -8,8 +8,7 @@ ...@@ -8,8 +8,7 @@
package main package main
func func
main() main() {
{
var t,i int; var t,i int;
for i=0; i<100; i=i+1 { for i=0; i<100; i=i+1 {
......
...@@ -11,8 +11,7 @@ type mystring string; ...@@ -11,8 +11,7 @@ type mystring string;
type I0 interface {}; type I0 interface {};
func func
f() f() {
{
var ia, ib I0; var ia, ib I0;
var i myint; var i myint;
var s mystring; var s mystring;
...@@ -52,8 +51,7 @@ f() ...@@ -52,8 +51,7 @@ f()
} }
func func
main() main() {
{
var ia [20]I0; var ia [20]I0;
var b bool; var b bool;
var s string; var s string;
......
...@@ -6,37 +6,29 @@ ...@@ -6,37 +6,29 @@
package main package main
type S struct type S struct {
{
a,b int; a,b int;
} }
type I1 interface type I1 interface {
{
f ()int; f ()int;
} }
type I2 interface type I2 interface {
{
g() int; g() int;
f() int; f() int;
} }
func func (this *S) f()int {
(this *S) f()int
{
return this.a; return this.a;
} }
func func (this *S) g()int {
(this *S) g()int
{
return this.b; return this.b;
} }
func func
main() main() {
{
var i1 I1; var i1 I1;
var i2 I2; var i2 I2;
var g *S; var g *S;
......
...@@ -6,58 +6,47 @@ ...@@ -6,58 +6,47 @@
package main package main
type Iputs interface type Iputs interface {
{
puts (s string); puts (s string);
} }
// --------- // ---------
type Print struct type Print struct {
{
whoami int; whoami int;
put Iputs; put Iputs;
} }
func (p *Print) func (p *Print) dop() {
dop()
{
print(" print ", p.whoami); print(" print ", p.whoami);
p.put.puts("abc"); p.put.puts("abc");
} }
// --------- // ---------
type Bio struct type Bio struct {
{
whoami int; whoami int;
put Iputs; put Iputs;
} }
func (b *Bio) func (b *Bio) puts(s string) {
puts(s string)
{
print(" bio ", b.whoami); print(" bio ", b.whoami);
b.put.puts(s); b.put.puts(s);
} }
// --------- // ---------
type File struct type File struct {
{
whoami int; whoami int;
put Iputs; put Iputs;
} }
func (f *File) func (f *File) puts(s string) {
puts(s string)
{
print(" file ", f.whoami, " -- ", s); print(" file ", f.whoami, " -- ", s);
} }
func func
main() main() {
{
p := new(Print); p := new(Print);
b := new(Bio); b := new(Bio);
f := new(File); f := new(File);
......
...@@ -8,8 +8,7 @@ ...@@ -8,8 +8,7 @@
package main package main
func func
main() main() {
{
i := 0; i := 0;
if false { if false {
goto gogoloop; goto gogoloop;
......
...@@ -8,8 +8,7 @@ ...@@ -8,8 +8,7 @@
package main package main
func func
main() main() {
{
x := func(a int)int { x := func(a int)int {
x := func(a int)int { x := func(a int)int {
x := func(a int)int { x := func(a int)int {
......
...@@ -7,8 +7,7 @@ ...@@ -7,8 +7,7 @@
package main package main
func func
main() main() {
{
var x,y int; var x,y int;
x,y = simple(10,20,30); x,y = simple(10,20,30);
...@@ -16,7 +15,6 @@ main() ...@@ -16,7 +15,6 @@ main()
} }
func func
simple(ia,ib,ic int) (oa,ob int) simple(ia,ib,ic int) (oa,ob int) {
{
return ia+5, ib+ic; return ia+5, ib+ic;
} }
...@@ -11,8 +11,7 @@ import "rand" ...@@ -11,8 +11,7 @@ import "rand"
const Count = 1e5 const Count = 1e5
func func
i64rand() int64 i64rand() int64 {
{
for { for {
a := int64(rand.Uint32()); a := int64(rand.Uint32());
a = (a<<32) | int64(rand.Uint32()); a = (a<<32) | int64(rand.Uint32());
...@@ -25,8 +24,7 @@ i64rand() int64 ...@@ -25,8 +24,7 @@ i64rand() int64
} }
func func
i64test(a,b,c int64) i64test(a,b,c int64) {
{
d := a%c; d := a%c;
if d != b { if d != b {
panicln("i64", a, b, c, d); panicln("i64", a, b, c, d);
...@@ -34,8 +32,7 @@ i64test(a,b,c int64) ...@@ -34,8 +32,7 @@ i64test(a,b,c int64)
} }
func func
i64run() i64run() {
{
var a, b int64; var a, b int64;
for i:=0; i<Count; i++ { for i:=0; i<Count; i++ {
...@@ -80,8 +77,7 @@ i64run() ...@@ -80,8 +77,7 @@ i64run()
} }
func func
u64rand() uint64 u64rand() uint64 {
{
a := uint64(rand.Uint32()); a := uint64(rand.Uint32());
a = (a<<32) | uint64(rand.Uint32()); a = (a<<32) | uint64(rand.Uint32());
a >>= uint(rand.Intn(64)); a >>= uint(rand.Intn(64));
...@@ -89,8 +85,7 @@ u64rand() uint64 ...@@ -89,8 +85,7 @@ u64rand() uint64
} }
func func
u64test(a,b,c uint64) u64test(a,b,c uint64) {
{
d := a%c; d := a%c;
if d != b { if d != b {
panicln("u64", a, b, c, d); panicln("u64", a, b, c, d);
...@@ -98,8 +93,7 @@ u64test(a,b,c uint64) ...@@ -98,8 +93,7 @@ u64test(a,b,c uint64)
} }
func func
u64run() u64run() {
{
var a, b uint64; var a, b uint64;
for i:=0; i<Count; i++ { for i:=0; i<Count; i++ {
...@@ -126,8 +120,7 @@ u64run() ...@@ -126,8 +120,7 @@ u64run()
} }
func func
i32rand() int32 i32rand() int32 {
{
for { for {
a := int32(rand.Uint32()); a := int32(rand.Uint32());
a >>= uint(rand.Intn(32)); a >>= uint(rand.Intn(32));
...@@ -139,8 +132,7 @@ i32rand() int32 ...@@ -139,8 +132,7 @@ i32rand() int32
} }
func func
i32test(a,b,c int32) i32test(a,b,c int32) {
{
d := a%c; d := a%c;
if d != b { if d != b {
panicln("i32", a, b, c, d); panicln("i32", a, b, c, d);
...@@ -148,8 +140,7 @@ i32test(a,b,c int32) ...@@ -148,8 +140,7 @@ i32test(a,b,c int32)
} }
func func
i32run() i32run() {
{
var a, b int32; var a, b int32;
for i:=0; i<Count; i++ { for i:=0; i<Count; i++ {
...@@ -193,16 +184,14 @@ i32run() ...@@ -193,16 +184,14 @@ i32run()
} }
func func
u32rand() uint32 u32rand() uint32 {
{
a := uint32(rand.Uint32()); a := uint32(rand.Uint32());
a >>= uint(rand.Intn(32)); a >>= uint(rand.Intn(32));
return a; return a;
} }
func func
u32test(a,b,c uint32) u32test(a,b,c uint32) {
{
d := a%c; d := a%c;
if d != b { if d != b {
panicln("u32", a, b, c, d); panicln("u32", a, b, c, d);
...@@ -210,8 +199,7 @@ u32test(a,b,c uint32) ...@@ -210,8 +199,7 @@ u32test(a,b,c uint32)
} }
func func
u32run() u32run() {
{
var a, b uint32; var a, b uint32;
for i:=0; i<Count; i++ { for i:=0; i<Count; i++ {
...@@ -238,8 +226,7 @@ u32run() ...@@ -238,8 +226,7 @@ u32run()
} }
func func
i16rand() int16 i16rand() int16 {
{
for { for {
a := int16(rand.Uint32()); a := int16(rand.Uint32());
a >>= uint(rand.Intn(16)); a >>= uint(rand.Intn(16));
...@@ -251,8 +238,7 @@ i16rand() int16 ...@@ -251,8 +238,7 @@ i16rand() int16
} }
func func
i16test(a,b,c int16) i16test(a,b,c int16) {
{
d := a%c; d := a%c;
if d != b { if d != b {
panicln("i16", a, b, c, d); panicln("i16", a, b, c, d);
...@@ -260,8 +246,7 @@ i16test(a,b,c int16) ...@@ -260,8 +246,7 @@ i16test(a,b,c int16)
} }
func func
i16run() i16run() {
{
var a, b int16; var a, b int16;
for i:=0; i<Count; i++ { for i:=0; i<Count; i++ {
...@@ -306,16 +291,14 @@ i16run() ...@@ -306,16 +291,14 @@ i16run()
} }
func func
u16rand() uint16 u16rand() uint16 {
{
a := uint16(rand.Uint32()); a := uint16(rand.Uint32());
a >>= uint(rand.Intn(16)); a >>= uint(rand.Intn(16));
return a; return a;
} }
func func
u16test(a,b,c uint16) u16test(a,b,c uint16) {
{
d := a%c; d := a%c;
if d != b { if d != b {
panicln("u16", a, b, c, d); panicln("u16", a, b, c, d);
...@@ -323,8 +306,7 @@ u16test(a,b,c uint16) ...@@ -323,8 +306,7 @@ u16test(a,b,c uint16)
} }
func func
u16run() u16run() {
{
var a, b uint16; var a, b uint16;
for i:=0; i<Count; i++ { for i:=0; i<Count; i++ {
...@@ -351,8 +333,7 @@ u16run() ...@@ -351,8 +333,7 @@ u16run()
} }
func func
i8rand() int8 i8rand() int8 {
{
for { for {
a := int8(rand.Uint32()); a := int8(rand.Uint32());
a >>= uint(rand.Intn(8)); a >>= uint(rand.Intn(8));
...@@ -364,8 +345,7 @@ i8rand() int8 ...@@ -364,8 +345,7 @@ i8rand() int8
} }
func func
i8test(a,b,c int8) i8test(a,b,c int8) {
{
d := a%c; d := a%c;
if d != b { if d != b {
panicln("i8", a, b, c, d); panicln("i8", a, b, c, d);
...@@ -373,8 +353,7 @@ i8test(a,b,c int8) ...@@ -373,8 +353,7 @@ i8test(a,b,c int8)
} }
func func
i8run() i8run() {
{
var a, b int8; var a, b int8;
for i:=0; i<Count; i++ { for i:=0; i<Count; i++ {
...@@ -416,16 +395,14 @@ i8run() ...@@ -416,16 +395,14 @@ i8run()
} }
func func
u8rand() uint8 u8rand() uint8 {
{
a := uint8(rand.Uint32()); a := uint8(rand.Uint32());
a >>= uint(rand.Intn(8)); a >>= uint(rand.Intn(8));
return a; return a;
} }
func func
u8test(a,b,c uint8) u8test(a,b,c uint8) {
{
d := a%c; d := a%c;
if d != b { if d != b {
panicln("u8", a, b, c, d); panicln("u8", a, b, c, d);
...@@ -433,8 +410,7 @@ u8test(a,b,c uint8) ...@@ -433,8 +410,7 @@ u8test(a,b,c uint8)
} }
func func
u8run() u8run() {
{
var a, b uint8; var a, b uint8;
for i:=0; i<Count; i++ { for i:=0; i<Count; i++ {
...@@ -459,8 +435,7 @@ u8run() ...@@ -459,8 +435,7 @@ u8run()
} }
func func
main() main() {
{
xtest(); xtest();
i64run(); i64run();
u64run(); u64run();
...@@ -473,6 +448,5 @@ main() ...@@ -473,6 +448,5 @@ main()
} }
func func
xtest() xtest() {
{
} }
...@@ -7,21 +7,17 @@ ...@@ -7,21 +7,17 @@
package main package main
type C struct type C struct {
{
a int; a int;
x func(p *C)int; x func(p *C)int;
} }
func func (this *C) f()int {
(this *C) f()int
{
return this.a; return this.a;
} }
func func
main() main() {
{
var v int; var v int;
var c *C; var c *C;
...@@ -39,9 +35,7 @@ main() ...@@ -39,9 +35,7 @@ main()
if v != 6 { panic(v); } if v != 6 { panic(v); }
} }
func func g(p *C)int {
g(p *C)int
{
var v int; var v int;
v = p.a; v = p.a;
......
...@@ -12,8 +12,7 @@ var g1 x2; ...@@ -12,8 +12,7 @@ var g1 x2;
var g2 struct { a,b,c int; d x2; }; var g2 struct { a,b,c int; d x2; };
func func
main() main() {
{
var x int; var x int;
var s1 *x2; var s1 *x2;
var s2 *struct { a,b,c int; d x2; }; var s2 *struct { a,b,c int; d x2; };
......
...@@ -13,14 +13,12 @@ var p []byte; ...@@ -13,14 +13,12 @@ var p []byte;
var m map[int]byte; var m map[int]byte;
func func
f(k int) byte f(k int) byte {
{
return byte(k*10007 % size); return byte(k*10007 % size);
} }
func func
init() init() {
{
p = make([]byte, size); p = make([]byte, size);
m = make(map[int]byte); m = make(map[int]byte);
for k:=0; k<size; k++ { for k:=0; k<size; k++ {
...@@ -32,8 +30,7 @@ init() ...@@ -32,8 +30,7 @@ init()
} }
func func
main() main() {
{
var i int; var i int;
/* /*
......
...@@ -6,40 +6,31 @@ ...@@ -6,40 +6,31 @@
package main package main
type Item interface type Item interface {
{
Print(); Print();
} }
type ListItem struct type ListItem struct {
{
item Item; item Item;
next *ListItem; next *ListItem;
} }
type List struct type List struct {
{
head *ListItem; head *ListItem;
} }
func (list *List) func (list *List) Init() {
Init()
{
list.head = nil; list.head = nil;
} }
func (list *List) func (list *List) Insert(i Item) {
Insert(i Item)
{
item := new(ListItem); item := new(ListItem);
item.item = i; item.item = i;
item.next = list.head; item.next = list.head;
list.head = item; list.head = item;
} }
func (list *List) func (list *List) Print() {
Print()
{
i := list.head; i := list.head;
for i != nil { for i != nil {
i.item.Print(); i.item.Print();
...@@ -48,27 +39,21 @@ Print() ...@@ -48,27 +39,21 @@ Print()
} }
// Something to put in a list // Something to put in a list
type Integer struct type Integer struct {
{
val int; val int;
} }
func (this *Integer) func (this *Integer) Init(i int) *Integer {
Init(i int) *Integer
{
this.val = i; this.val = i;
return this; return this;
} }
func (this *Integer) func (this *Integer) Print() {
Print()
{
print(this.val); print(this.val);
} }
func func
main() main() {
{
list := new(List); list := new(List);
list.Init(); list.Init();
for i := 0; i < 10; i = i + 1 { for i := 0; i < 10; i = i + 1 {
......
...@@ -72,8 +72,7 @@ var tokenlen int = 0; ...@@ -72,8 +72,7 @@ var tokenlen int = 0;
const EOF int = -1; const EOF int = -1;
func main() func main() {
{
var list *Slist; var list *Slist;
OpenFile(); OpenFile();
...@@ -88,8 +87,7 @@ func main() ...@@ -88,8 +87,7 @@ func main()
} }
} }
func (slist *Slist) PrintOne(doparen bool) func (slist *Slist) PrintOne(doparen bool) {
{
if slist == nil { if slist == nil {
return; return;
} }
...@@ -114,14 +112,12 @@ func (slist *Slist) PrintOne(doparen bool) ...@@ -114,14 +112,12 @@ func (slist *Slist) PrintOne(doparen bool)
} }
} }
func (slist *Slist) Print() func (slist *Slist) Print() {
{
slist.PrintOne(true); slist.PrintOne(true);
print("\n"); print("\n");
} }
func Get() int func Get() int {
{
var c int; var c int;
if peekc >= 0 { if peekc >= 0 {
...@@ -141,13 +137,11 @@ func Get() int ...@@ -141,13 +137,11 @@ func Get() int
return c; return c;
} }
func WhiteSpace(c int) bool func WhiteSpace(c int) bool {
{
return c == ' ' || c == '\t' || c == '\r' || c == '\n'; return c == ' ' || c == '\t' || c == '\r' || c == '\n';
} }
func NextToken() func NextToken() {
{
var i, c int; var i, c int;
tokenbuf[0] = nilchar; // clear previous token tokenbuf[0] = nilchar; // clear previous token
...@@ -187,8 +181,7 @@ func NextToken() ...@@ -187,8 +181,7 @@ func NextToken()
} }
} }
func Expect(c int) func Expect(c int) {
{
if token != c { if token != c {
print("parse error: expected ", c, "\n"); print("parse error: expected ", c, "\n");
panic("parse"); panic("parse");
...@@ -197,8 +190,7 @@ func Expect(c int) ...@@ -197,8 +190,7 @@ func Expect(c int)
} }
// Parse a non-parenthesized list up to a closing paren or EOF // Parse a non-parenthesized list up to a closing paren or EOF
func ParseList() *Slist func ParseList() *Slist {
{
var slist, retval *Slist; var slist, retval *Slist;
slist = new(Slist); slist = new(Slist);
...@@ -219,8 +211,7 @@ func ParseList() *Slist ...@@ -219,8 +211,7 @@ func ParseList() *Slist
return retval; return retval;
} }
func atom(i int) *Slist // BUG: uses tokenbuf; should take argument func atom(i int) *Slist { // BUG: uses tokenbuf; should take argument)
{
var slist *Slist; var slist *Slist;
slist = new(Slist); slist = new(Slist);
...@@ -235,8 +226,7 @@ func atom(i int) *Slist // BUG: uses tokenbuf; should take argument ...@@ -235,8 +226,7 @@ func atom(i int) *Slist // BUG: uses tokenbuf; should take argument
return slist; return slist;
} }
func atoi() int // BUG: uses tokenbuf; should take argument func atoi() int { // BUG: uses tokenbuf; should take argument)
{
var v int = 0; var v int = 0;
for i := 0; i < tokenlen && '0' <= tokenbuf[i] && tokenbuf[i] <= '9'; i = i + 1 { for i := 0; i < tokenlen && '0' <= tokenbuf[i] && tokenbuf[i] <= '9'; i = i + 1 {
v = 10 * v + int(tokenbuf[i] - '0'); v = 10 * v + int(tokenbuf[i] - '0');
...@@ -244,8 +234,7 @@ func atoi() int // BUG: uses tokenbuf; should take argument ...@@ -244,8 +234,7 @@ func atoi() int // BUG: uses tokenbuf; should take argument
return v; return v;
} }
func Parse() *Slist func Parse() *Slist {
{
var slist *Slist; var slist *Slist;
if token == EOF || token == ')' { if token == EOF || token == ')' {
...@@ -275,8 +264,7 @@ func Parse() *Slist ...@@ -275,8 +264,7 @@ func Parse() *Slist
return nil; return nil;
} }
func OpenFile() func OpenFile() {
{
input = "(defn foo (add 12 34))\n\x00"; input = "(defn foo (add 12 34))\n\x00";
inputindex = 0; inputindex = 0;
peekc = -1; // BUG peekc = -1; // BUG
......
...@@ -11,8 +11,7 @@ var uans [18]uint; ...@@ -11,8 +11,7 @@ var uans [18]uint;
var pass string; var pass string;
func func
testi(i int, t1,t2,t3 int) testi(i int, t1,t2,t3 int) {
{
n := ((t1*3) + t2)*2 + t3; n := ((t1*3) + t2)*2 + t3;
if i != ians[n] { if i != ians[n] {
print("itest ", t1,t2,t3,pass, print("itest ", t1,t2,t3,pass,
...@@ -21,14 +20,12 @@ testi(i int, t1,t2,t3 int) ...@@ -21,14 +20,12 @@ testi(i int, t1,t2,t3 int)
} }
func func
index(t1,t2,t3 int) int index(t1,t2,t3 int) int {
{
return ((t1*3) + t2)*2 + t3; return ((t1*3) + t2)*2 + t3;
} }
func func
testu(u uint, t1,t2,t3 int) testu(u uint, t1,t2,t3 int) {
{
n := index(t1,t2,t3); n := index(t1,t2,t3);
if u != uans[n] { if u != uans[n] {
print("utest ", t1,t2,t3,pass, print("utest ", t1,t2,t3,pass,
...@@ -37,8 +34,7 @@ testu(u uint, t1,t2,t3 int) ...@@ -37,8 +34,7 @@ testu(u uint, t1,t2,t3 int)
} }
func func
main() main() {
{
var i int; var i int;
var u,c uint; var u,c uint;
...@@ -95,8 +91,7 @@ main() ...@@ -95,8 +91,7 @@ main()
} }
func func
init() init() {
{
/* /*
* set the 'correct' answer * set the 'correct' answer
*/ */
......
...@@ -9,8 +9,7 @@ package main ...@@ -9,8 +9,7 @@ package main
var b[10] float32; var b[10] float32;
func func
main() main() {
{
var a[10] float32; var a[10] float32;
for i:=int16(5); i<10; i=i+1 { for i:=int16(5); i<10; i=i+1 {
......
...@@ -6,15 +6,13 @@ ...@@ -6,15 +6,13 @@
package main package main
type s struct type s struct {
{
a bool; a bool;
b bool; b bool;
} }
func func
main() main() {
{
var a,b bool; var a,b bool;
a = true; a = true;
......
...@@ -10,8 +10,7 @@ type vlong int64; ...@@ -10,8 +10,7 @@ type vlong int64;
type short int16; type short int16;
func func
main() main() {
{
s1 := vlong(0); s1 := vlong(0);
for i:=short(0); i<10; i=i+1 { for i:=short(0); i<10; i=i+1 {
s1 = s1 + vlong(i); s1 = s1 + vlong(i);
......
...@@ -8,8 +8,7 @@ ...@@ -8,8 +8,7 @@
package main package main
func func
main() main() {
{
var x int; var x int;
x = fun(10,20,30); x = fun(10,20,30);
...@@ -17,8 +16,7 @@ main() ...@@ -17,8 +16,7 @@ main()
} }
func func
fun(ia,ib,ic int)int fun(ia,ib,ic int)int {
{
var o int; var o int;
o = ia+ib+ic; o = ia+ib+ic;
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
package main package main
func func
main() main() {
{
print("hello world\n"); print("hello world\n");
} }
...@@ -7,8 +7,7 @@ ...@@ -7,8 +7,7 @@
package main package main
func func
main() main() {
{
a := 3; a := 3;
for i:=0; i<10; i=i+1 { for i:=0; i<10; i=i+1 {
switch(i) { switch(i) {
......
...@@ -10,8 +10,7 @@ package main ...@@ -10,8 +10,7 @@ package main
var x,y int; var x,y int;
func func
main() main() {
{
x = 15; x = 15;
y = 20; y = 20;
......
...@@ -14,8 +14,7 @@ var lb,hb int ...@@ -14,8 +14,7 @@ var lb,hb int
var t int var t int
func func
main() main() {
{
lb = 0; hb = 10; lb = 0; hb = 10;
by = &bx; tstb(); by = &bx; tstb();
...@@ -82,8 +81,7 @@ main() ...@@ -82,8 +81,7 @@ main()
} }
func func
tstb() tstb() {
{
t++; t++;
if len(by) != hb-lb { if len(by) != hb-lb {
panicln("t=", t, "lb=", lb, "hb=", hb, panicln("t=", t, "lb=", lb, "hb=", hb,
...@@ -104,8 +102,7 @@ tstb() ...@@ -104,8 +102,7 @@ tstb()
} }
func func
tstf() tstf() {
{
t++; t++;
if len(fy) != hb-lb { if len(fy) != hb-lb {
panicln("t=", t, "lb=", lb, "hb=", hb, panicln("t=", t, "lb=", lb, "hb=", hb,
...@@ -126,8 +123,7 @@ tstf() ...@@ -126,8 +123,7 @@ tstf()
} }
func func
init() init() {
{
for i:=0; i<len(bx); i++ { for i:=0; i<len(bx); i++ {
bx[i] = byte(i+20); bx[i] = byte(i+20);
} }
......
...@@ -14,8 +14,7 @@ var lb,hb int ...@@ -14,8 +14,7 @@ var lb,hb int
var t int var t int
func func
main() main() {
{
// width 1 (byte) // width 1 (byte)
lb = 0; hb = 10; lb = 0; hb = 10;
...@@ -77,8 +76,7 @@ main() ...@@ -77,8 +76,7 @@ main()
} }
func func
tstb() tstb() {
{
t++; t++;
if len(by) != hb-lb { if len(by) != hb-lb {
panicln("t=", t, "lb=", lb, "hb=", hb, panicln("t=", t, "lb=", lb, "hb=", hb,
...@@ -99,8 +97,7 @@ tstb() ...@@ -99,8 +97,7 @@ tstb()
} }
func func
tstf() tstf() {
{
t++; t++;
if len(fy) != hb-lb { if len(fy) != hb-lb {
panicln("t=", t, "lb=", lb, "hb=", hb, panicln("t=", t, "lb=", lb, "hb=", hb,
...@@ -121,8 +118,7 @@ tstf() ...@@ -121,8 +118,7 @@ tstf()
} }
func func
init() init() {
{
bx = make([]byte, 10); bx = make([]byte, 10);
for i:=0; i<len(bx); i++ { for i:=0; i<len(bx); i++ {
bx[i] = byte(i+20); bx[i] = byte(i+20);
......
...@@ -8,8 +8,7 @@ ...@@ -8,8 +8,7 @@
package main package main
func func
main() main() {
{
var c string; var c string;
a := `abc`; a := `abc`;
......
...@@ -12,8 +12,7 @@ var g1 x2; ...@@ -12,8 +12,7 @@ var g1 x2;
var g2 struct { a,b,c int; d x2; }; var g2 struct { a,b,c int; d x2; };
func func
main() main() {
{
var x int; var x int;
var s1 *x2; var s1 *x2;
var s2 *struct { a,b,c int; d x2; }; var s2 *struct { a,b,c int; d x2; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment