diff options
author | Rob Pike <r@golang.org> | 2008-08-11 22:07:49 -0700 |
---|---|---|
committer | Rob Pike <r@golang.org> | 2008-08-11 22:07:49 -0700 |
commit | d4f4656470e56d7d4dc35ecef1841f989745b24f (patch) | |
tree | 9d0faf1d96579f8c9fb0321586cab7c5149ccdf1 /test/ken | |
parent | df89d5ea8f7e8d7601dc176b6544206a68b1fe09 (diff) | |
download | go-d4f4656470e56d7d4dc35ecef1841f989745b24f.tar.gz |
fix bug depot:
1) fix print statements, panic statements (parentheses required)
2) len is now allowed as a var name (bug053)
R=gri
OCL=14106
CL=14106
Diffstat (limited to 'test/ken')
-rw-r--r-- | test/ken/for.go | 2 | ||||
-rw-r--r-- | test/ken/interfun.go | 14 | ||||
-rw-r--r-- | test/ken/intervar.go | 8 | ||||
-rw-r--r-- | test/ken/label.go | 4 | ||||
-rw-r--r-- | test/ken/litfun.go | 2 | ||||
-rw-r--r-- | test/ken/mfunc.go | 2 | ||||
-rw-r--r-- | test/ken/ptrfun.go | 8 | ||||
-rw-r--r-- | test/ken/ptrvar.go | 6 | ||||
-rw-r--r-- | test/ken/rob1.go | 4 | ||||
-rw-r--r-- | test/ken/rob2.go | 20 | ||||
-rw-r--r-- | test/ken/robfor.go | 4 | ||||
-rw-r--r-- | test/ken/robfunc.go | 4 | ||||
-rw-r--r-- | test/ken/robif.go | 4 | ||||
-rw-r--r-- | test/ken/robiota.go | 4 | ||||
-rw-r--r-- | test/ken/simparray.go | 6 | ||||
-rw-r--r-- | test/ken/simpbool.go | 88 | ||||
-rw-r--r-- | test/ken/simpconv.go | 4 | ||||
-rw-r--r-- | test/ken/simpfun.go | 4 | ||||
-rw-r--r-- | test/ken/simpprint.go | 2 | ||||
-rw-r--r-- | test/ken/simpswitch.go | 10 | ||||
-rw-r--r-- | test/ken/simpvar.go | 2 | ||||
-rw-r--r-- | test/ken/string.go | 34 | ||||
-rw-r--r-- | test/ken/strvar.go | 14 |
23 files changed, 125 insertions, 125 deletions
diff --git a/test/ken/for.go b/test/ken/for.go index 52ccbff08..74434b267 100644 --- a/test/ken/for.go +++ b/test/ken/for.go @@ -15,5 +15,5 @@ main() for i=0; i<100; i=i+1 { t = t+i; } - if t != 50*99 { panic t; } + if t != 50*99 { panic(t); } } diff --git a/test/ken/interfun.go b/test/ken/interfun.go index 8142b9bd2..97db89316 100644 --- a/test/ken/interfun.go +++ b/test/ken/interfun.go @@ -45,20 +45,20 @@ main() s.b = 6; // call structure - if s.f() != 5 { panic 11; } - if s.g() != 6 { panic 12; } + if s.f() != 5 { panic(11); } + if s.g() != 6 { panic(12); } i1 = s; // convert S to I1 i2 = i1; // convert I1 to I2 // call interface - if i1.f() != 5 { panic 21; } - if i2.f() != 5 { panic 22; } - if i2.g() != 6 { panic 23; } + if i1.f() != 5 { panic(21); } + if i2.f() != 5 { panic(22); } + if i2.g() != 6 { panic(23); } g = i1; // convert I1 to S - if g != s { panic 31; } + if g != s { panic(31); } g = i2; // convert I2 to S - if g != s { panic 32; } + if g != s { panic(32); } } diff --git a/test/ken/intervar.go b/test/ken/intervar.go index 1c0aefde6..baf03c5aa 100644 --- a/test/ken/intervar.go +++ b/test/ken/intervar.go @@ -22,7 +22,7 @@ type Print struct func (p *Print) dop() { - print " print ", p.whoami; + print(" print ", p.whoami); p.put.puts("abc"); } @@ -37,7 +37,7 @@ type Bio struct func (b *Bio) puts(s string) { - print " bio ", b.whoami; + print(" bio ", b.whoami); b.put.puts(s); } @@ -52,7 +52,7 @@ type File struct func (f *File) puts(s string) { - print " file ", f.whoami, " -- ", s; + print(" file ", f.whoami, " -- ", s); } func @@ -71,5 +71,5 @@ main() f.whoami = 3; p.dop(); - print "\n"; + print("\n"); } diff --git a/test/ken/label.go b/test/ken/label.go index 17c69cdad..17294ef86 100644 --- a/test/ken/label.go +++ b/test/ken/label.go @@ -28,8 +28,8 @@ loop: if i < 100 { goto loop; } - print i; - print "\n"; + print(i); + print("\n"); return; gogoloop: diff --git a/test/ken/litfun.go b/test/ken/litfun.go index 83c1916cd..85b4b0a6a 100644 --- a/test/ken/litfun.go +++ b/test/ken/litfun.go @@ -19,5 +19,5 @@ main() }; return x(a)+11; }; - if x(3) != 3+5+7+11 { panic x(3); } + if x(3) != 3+5+7+11 { panic(x(3)); } } diff --git a/test/ken/mfunc.go b/test/ken/mfunc.go index 032f75679..ab579e932 100644 --- a/test/ken/mfunc.go +++ b/test/ken/mfunc.go @@ -14,7 +14,7 @@ main() var x,y int; x,y = simple(10,20,30); - if x+y != 65 { panic x+y; } + if x+y != 65 { panic(x+y); } } func diff --git a/test/ken/ptrfun.go b/test/ken/ptrfun.go index 70f45dfc7..bfec64ff9 100644 --- a/test/ken/ptrfun.go +++ b/test/ken/ptrfun.go @@ -32,13 +32,13 @@ main() c.x = &g; v = g(c); - if v != 6 { panic v; } + if v != 6 { panic(v); } v = c.x(c); - if v != 6 { panic v; } + if v != 6 { panic(v); } v = c.f(); - if v != 6 { panic v; } + if v != 6 { panic(v); } } func @@ -47,6 +47,6 @@ g(p *C)int var v int; v = p.a; - if v != 6 { panic v; } + if v != 6 { panic(v); } return p.a; } diff --git a/test/ken/ptrvar.go b/test/ken/ptrvar.go index c2e2d611d..0e3452f0a 100644 --- a/test/ken/ptrvar.go +++ b/test/ken/ptrvar.go @@ -34,8 +34,8 @@ main() s2.d.c = 23; s2.d.d = 20; - if(s2.d.c != 23) { panic 1; } - if(g2.d.c != 23) { panic 2; } + if(s2.d.c != 23) { panic(1); } + if(g2.d.c != 23) { panic(2); } x = s1.a + s1.b + @@ -50,5 +50,5 @@ main() s2.d.c + s2.d.d; - if(x != 121) { panic x; } + if(x != 121) { panic(x); } } diff --git a/test/ken/rob1.go b/test/ken/rob1.go index ae56962a3..a75878b1f 100644 --- a/test/ken/rob1.go +++ b/test/ken/rob1.go @@ -63,7 +63,7 @@ Init(i int) *Integer func (this *Integer) Print() { - print this.val; + print(this.val); } func @@ -78,5 +78,5 @@ main() } list.Print(); - print "\n"; + print("\n"); } diff --git a/test/ken/rob2.go b/test/ken/rob2.go index 1b708400a..b18435dfc 100644 --- a/test/ken/rob2.go +++ b/test/ken/rob2.go @@ -100,21 +100,21 @@ func (slist *Slist) PrintOne(doparen bool) } if slist.isatom { if slist.isstring { - print slist.String(); + print(slist.String()); } else { - print slist.Integer(); + print(slist.Integer()); } } else { if doparen { - print "(" ; + print("(" ); } slist.Car().PrintOne(true); if slist.Cdr() != nil { - print " "; + print(" "); slist.Cdr().PrintOne(false); } if doparen { - print ")"; + print(")"); } } } @@ -122,7 +122,7 @@ func (slist *Slist) PrintOne(doparen bool) func (slist *Slist) Print() { slist.PrintOne(true); - print "\n"; + print("\n"); } func Get() int @@ -182,7 +182,7 @@ func NextToken() } } if i >= 100 - 1 { // sizeof tokenbuf - 1 - panic "atom too long\n"; + panic("atom too long\n"); } tokenlen = i; tokenbuf[i] = nilchar; @@ -197,8 +197,8 @@ func NextToken() func Expect(c int) { if token != c { - print "parse error: expected ", c, "\n"; - panic "parse"; + print("parse error: expected ", c, "\n"); + panic("parse"); } NextToken(); } @@ -276,7 +276,7 @@ func Parse() *Slist slist = atom(0); default: slist = nil; - print "unknown token"; //, token, tokenbuf; + print("unknown token"); // token, tokenbuf); } NextToken(); return slist; diff --git a/test/ken/robfor.go b/test/ken/robfor.go index 60e3f1fdd..05188a472 100644 --- a/test/ken/robfor.go +++ b/test/ken/robfor.go @@ -8,8 +8,8 @@ package main func assertequal(is, shouldbe int, msg string) { if is != shouldbe { - print "assertion fail" + msg + "\n"; - panic 1; + print("assertion fail" + msg + "\n"); + panic(1); } } diff --git a/test/ken/robfunc.go b/test/ken/robfunc.go index 703e65e2d..12b4b6d7b 100644 --- a/test/ken/robfunc.go +++ b/test/ken/robfunc.go @@ -8,8 +8,8 @@ package main func assertequal(is, shouldbe int, msg string) { if is != shouldbe { - print "assertion fail" + msg + "\n"; - panic 1; + print("assertion fail" + msg + "\n"); + panic(1); } } diff --git a/test/ken/robif.go b/test/ken/robif.go index 7a099769d..41d164cd5 100644 --- a/test/ken/robif.go +++ b/test/ken/robif.go @@ -8,8 +8,8 @@ package main func assertequal(is, shouldbe int, msg string) { if is != shouldbe { - print "assertion fail" + msg + "\n"; - panic 1; + print("assertion fail" + msg + "\n"); + panic(1); } } diff --git a/test/ken/robiota.go b/test/ken/robiota.go index 685d1290e..af97fa2a3 100644 --- a/test/ken/robiota.go +++ b/test/ken/robiota.go @@ -8,8 +8,8 @@ package main func assert(cond bool, msg string) { if !cond { - print "assertion fail: " + msg + "\n"; - panic 1; + print("assertion fail: " + msg + "\n"); + panic(1); } } diff --git a/test/ken/simparray.go b/test/ken/simparray.go index 1cbde1bd4..a670986bd 100644 --- a/test/ken/simparray.go +++ b/test/ken/simparray.go @@ -22,7 +22,7 @@ main() s1 = s1 + a[i]; } - if s1 != 35 { panic s1; } + if s1 != 35 { panic(s1); } for i:=short(5); i<10; i=i+1 { b[i] = float(i); @@ -33,7 +33,7 @@ main() s2 = s2 + b[i]; } - if s2 != 35 { panic s2; } + if s2 != 35 { panic(s2); } b := new([100]int); for i:=0; i<100; i=i+1 { @@ -45,5 +45,5 @@ main() s3 = s3+b[i]; } - if s3 != 4950 { panic s3; } + if s3 != 4950 { panic(s3); } } diff --git a/test/ken/simpbool.go b/test/ken/simpbool.go index 6a223e852..aad111dd5 100644 --- a/test/ken/simpbool.go +++ b/test/ken/simpbool.go @@ -20,88 +20,88 @@ main() a = true; b = false; - if !a { panic 1; } - if b { panic 2; } - if !!!a { panic 3; } - if !!b { panic 4; } + if !a { panic(1); } + if b { panic(2); } + if !!!a { panic(3); } + if !!b { panic(4); } a = !b; - if !a { panic 5; } - if !!!a { panic 6; } + if !a { panic(5); } + if !!!a { panic(6); } var x *s; x = new(s); x.a = true; x.b = false; - if !x.a { panic 7; } - if x.b { panic 8; } - if !!!x.a { panic 9; } - if !!x.b { panic 10; } + if !x.a { panic(7); } + if x.b { panic(8); } + if !!!x.a { panic(9); } + if !!x.b { panic(10); } x.a = !x.b; - if !x.a { panic 11; } - if !!!x.a { panic 12; } + if !x.a { panic(11); } + if !!!x.a { panic(12); } /* * test && */ a = true; b = true; - if !(a && b) { panic 21; } - if a && !b { panic 22; } - if !a && b { panic 23; } - if !a && !b { panic 24; } + if !(a && b) { panic(21); } + if a && !b { panic(22); } + if !a && b { panic(23); } + if !a && !b { panic(24); } a = false; b = true; - if !(!a && b) { panic 31; } - if !a && !b { panic 32; } - if a && b { panic 33; } - if a && !b { panic 34; } + if !(!a && b) { panic(31); } + if !a && !b { panic(32); } + if a && b { panic(33); } + if a && !b { panic(34); } a = true; b = false; - if !(a && !b) { panic 41; } - if a && b { panic 41; } - if !a && !b { panic 41; } - if !a && b { panic 44; } + if !(a && !b) { panic(41); } + if a && b { panic(41); } + if !a && !b { panic(41); } + if !a && b { panic(44); } a = false; b = false; - if !(!a && !b) { panic 51; } - if !a && b { panic 52; } - if a && !b { panic 53; } - if a && b { panic 54; } + if !(!a && !b) { panic(51); } + if !a && b { panic(52); } + if a && !b { panic(53); } + if a && b { panic(54); } /* * test || */ a = true; b = true; - if !(a || b) { panic 61; } - if !(a || !b) { panic 62; } - if !(!a || b) { panic 63; } - if !a || !b { panic 64; } + if !(a || b) { panic(61); } + if !(a || !b) { panic(62); } + if !(!a || b) { panic(63); } + if !a || !b { panic(64); } a = false; b = true; - if !(!a || b) { panic 71; } - if !(!a || !b) { panic 72; } - if !(a || b) { panic 73; } - if a || !b { panic 74; } + if !(!a || b) { panic(71); } + if !(!a || !b) { panic(72); } + if !(a || b) { panic(73); } + if a || !b { panic(74); } a = true; b = false; - if !(a || !b) { panic 81; } - if !(a || b) { panic 82; } - if !(!a || !b) { panic 83; } - if !a || b { panic 84; } + if !(a || !b) { panic(81); } + if !(a || b) { panic(82); } + if !(!a || !b) { panic(83); } + if !a || b { panic(84); } a = false; b = false; - if !(!a || !b) { panic 91; } - if !(!a || b) { panic 92; } - if !(a || !b) { panic 93; } - if a || b { panic 94; } + if !(!a || !b) { panic(91); } + if !(!a || b) { panic(92); } + if !(a || !b) { panic(93); } + if a || b { panic(94); } } diff --git a/test/ken/simpconv.go b/test/ken/simpconv.go index 401ae763d..7bb3896b2 100644 --- a/test/ken/simpconv.go +++ b/test/ken/simpconv.go @@ -15,11 +15,11 @@ main() for i:=short(0); i<10; i=i+1 { s1 = s1 + vlong(i); } - if s1 != 45 { panic s1; } + if s1 != 45 { panic(s1); } s2 := float(0); for i:=0; i<10; i=i+1 { s2 = s2 + float(i); } - if s2 != 45 { panic s2; } + if s2 != 45 { panic(s2); } } diff --git a/test/ken/simpfun.go b/test/ken/simpfun.go index 3605fa286..1e063bf0f 100644 --- a/test/ken/simpfun.go +++ b/test/ken/simpfun.go @@ -15,7 +15,7 @@ main() var x int; x = fun(10,20,30); - if x != 60 { panic x; } + if x != 60 { panic(x); } } func @@ -24,6 +24,6 @@ fun(ia,ib,ic int)int var o int; o = ia+ib+ic; - if o != 60 { panic o; } + if o != 60 { panic(o); } return o; } diff --git a/test/ken/simpprint.go b/test/ken/simpprint.go index 37ca08425..98393a457 100644 --- a/test/ken/simpprint.go +++ b/test/ken/simpprint.go @@ -10,5 +10,5 @@ package main func main() { - print "hello world\n"; + print("hello world\n"); } diff --git a/test/ken/simpswitch.go b/test/ken/simpswitch.go index 88c2a9981..e5f39e354 100644 --- a/test/ken/simpswitch.go +++ b/test/ken/simpswitch.go @@ -13,13 +13,13 @@ main() for i:=0; i<10; i=i+1 { switch(i) { case 5: - print "five"; + print("five"); case a,7: - print "a"; + print("a"); default: - print i; + print(i); } - print "out", i; + print("out", i); } - print "\n"; + print("\n"); } diff --git a/test/ken/simpvar.go b/test/ken/simpvar.go index 2dd4e73ac..396ea7b4c 100644 --- a/test/ken/simpvar.go +++ b/test/ken/simpvar.go @@ -21,5 +21,5 @@ main() y = 25; } x = x+y; - if(x != 40) { panic x; } + if(x != 40) { panic(x); } } diff --git a/test/ken/string.go b/test/ken/string.go index 51da6a230..3a15beeff 100644 --- a/test/ken/string.go +++ b/test/ken/string.go @@ -16,69 +16,69 @@ main() b := `xyz`; /* print a literal */ - print `abc`; + print(`abc`); /* print a variable */ - print b, "-"; + print(b, "-"); /* catenate literals */ - print `abc` + `xyz`, "-"; + print(`abc` + `xyz`, "-"); /* catenate variables */ - print a+b, "-"; + print(a+b, "-"); /* compare literals */ if `abc` == `xyz` || `abc` != "abc" || `abc` > `xyz` { - panic "compare literals"; + panic("compare literals"); } /* compare variables */ if a == b || a != a || a > b { - panic "compare variables"; + panic("compare variables"); } /* cat */ c = a+b; - print c, "-"; + print(c, "-"); /* catequal */ c = a; c += b; - print c, "-"; + print(c, "-"); /* clumsy evaluation */ c = b; c = a + c; - print c, "-"; + print(c, "-"); /* len */ if len(c) != 6 { - panic "len ", len(c); + panic("len ", len(c)); } /* index strings */ for i:=0; i<len(c); i=i+1 { if c[i] != (a+b)[i] { - panic "index ", i, " ", c[i], " ", (a+b)[i]; + panic("index ", i, " ", c[i], " ", (a+b)[i]); } } /* slice strings */ - print c[0:3], c[3:6]; + print(c[0:3], c[3:6]); - print "\n"; + print("\n"); /* create string with integer constant */ c = string('x'); if c != "x" { - panic "create int ", c; + panic("create int ", c); } /* create string with integer variable */ v := 'x'; c = string(v); if c != "x" { - panic "create int ", c; + panic("create int ", c); } /* create string with byte array */ @@ -88,7 +88,7 @@ main() z1[2] = 'c'; c = string(z1); if c != "abc" { - panic "create array ", c; + panic("create array ", c); } /* create string with byte array pointer */ @@ -98,6 +98,6 @@ main() z2[2] = 'c'; c = string(z2); if c != "abc" { - panic "create array pointer ", c; + panic("create array pointer ", c); } } diff --git a/test/ken/strvar.go b/test/ken/strvar.go index cf5b35d8d..4a2921795 100644 --- a/test/ken/strvar.go +++ b/test/ken/strvar.go @@ -27,8 +27,8 @@ main() s1.c = 3; s1.d = 5; - if(s1.c != 3) { panic s1.c; } - if(g1.c != 3) { panic g1.c; } + if(s1.c != 3) { panic(s1.c); } + if(g1.c != 3) { panic(g1.c); } s2.a = 7; s2.b = 11; @@ -38,8 +38,8 @@ main() s2.d.c = 23; s2.d.d = 29; - if(s2.d.c != 23) { panic s2.d.c; } - if(g2.d.c != 23) { panic g2.d.c; } + if(s2.d.c != 23) { panic(s2.d.c); } + if(g2.d.c != 23) { panic(g2.d.c); } x = s1.a + s1.b + @@ -54,7 +54,7 @@ main() s2.d.c + s2.d.d; - if(x != 130) { panic x; } + if(x != 130) { panic(x); } // test an automatic struct s3.a = 7; @@ -65,7 +65,7 @@ main() s3.d.c = 23; s3.d.d = 29; - if(s3.d.c != 23) { panic s3.d.c; } + if(s3.d.c != 23) { panic(s3.d.c); } x = s3.a + s3.b + @@ -75,5 +75,5 @@ main() s3.d.c + s3.d.d; - if(x != 119) { panic x; } + if(x != 119) { panic(x); } } |