Skip to content

Commit

Permalink
fix bug depot:
Browse files Browse the repository at this point in the history
	1) fix print statements, panic statements (parentheses required)
	2) len is now allowed as a var name (bug053)

R=gri
OCL=14106
CL=14106
  • Loading branch information
robpike committed Aug 12, 2008
1 parent 7293dab commit bc2f5f1
Show file tree
Hide file tree
Showing 63 changed files with 310 additions and 314 deletions.
6 changes: 3 additions & 3 deletions test/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ package main

func main() {
if sys.argc() != 3 {
panic "argc"
panic("argc")
}
if sys.argv(1) != "arg1" {
panic "arg1"
panic("arg1")
}
if sys.argv(2) != "arg2" {
panic "arg2"
panic("arg2")
}
}
6 changes: 3 additions & 3 deletions test/bugs/bug027.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func main() {
i3 := new(I); i3.val = 3333;
i4 := new(I); i4.val = 44444;
v := New();
print "hi\n";
print("hi\n");
v.Insert(i4);
v.Insert(i3);
v.Insert(i2);
Expand All @@ -48,10 +48,10 @@ func main() {
for i := 0; i < v.nelem; i++ {
var x *I;
x = v.At(i);
print i, " ", x.val, "\n"; // prints correct list
print(i, " ", x.val, "\n"); // prints correct list
}
for i := 0; i < v.nelem; i++ {
print i, " ", I(v.At(i)).val, "\n"; // always prints 5 - bad code - should be *I()
print(i, " ", I(v.At(i)).val, "\n"); // always prints 5 - bad code - should be *I()
}
}
/*
Expand Down
2 changes: 1 addition & 1 deletion test/bugs/bug054.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ func main() {
s.name = "foo";
s.fields = v;
if s.field(0).name != "hi" {
panic "bad name"
panic("bad name")
}
}
2 changes: 1 addition & 1 deletion test/bugs/bug060.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func main() {
m[0] = 0;
m[0]++;
if m[0] != 1 {
print "map does not increment";
print("map does not increment");
sys.exit(1)
}
}
2 changes: 1 addition & 1 deletion test/bugs/bug064.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ main()
b := 2;
a, b = swap(swap(a, b));
if a != 2 || b != 1 {
panic "bad swap";
panic("bad swap");
}
}
12 changes: 6 additions & 6 deletions test/bugs/bug070.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ func main() {
var i, j, k int;
outer:
for k=0; k<2; k++ {
print "outer loop top k ", k, "\n";
if k != 0 { panic "k not zero" } // inner loop breaks this one every time
print("outer loop top k ", k, "\n");
if k != 0 { panic("k not zero") } // inner loop breaks this one every time
for i=0; i<2; i++ {
if i != 0 { panic "i not zero" } // loop breaks every time
print "inner loop top i ", i, "\n";
if i != 0 { panic("i not zero") } // loop breaks every time
print("inner loop top i ", i, "\n");
if true {
print "do break\n";
print("do break\n");
break outer;
}
}
}
print "broke\n";
print("broke\n");
}
2 changes: 1 addition & 1 deletion test/bugs/bug074.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ package main

func main() {
x := string('a', 'b', '\n');
print x;
print(x);
}
2 changes: 1 addition & 1 deletion test/bugs/bug085.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ package P
var x int

func foo() {
print P.x; // P should be defined between the outermost "universe" scope and the global scope
print(P.x); // P should be defined between the outermost "universe" scope and the global scope
}

/*
Expand Down
2 changes: 1 addition & 1 deletion test/bugs/bug086.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func f() int {
}

func main() {
print f(), "\n";
print(f(), "\n");
}

/*
Expand Down
4 changes: 2 additions & 2 deletions test/chan/fifo.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func AsynchFifo() {
}
for i := 0; i < N; i++ {
if <-ch != i {
print "bad receive\n";
print("bad receive\n");
sys.exit(1);
}
}
Expand All @@ -26,7 +26,7 @@ func AsynchFifo() {
func Chain(ch *chan<- int, val int, in *chan<- int, out *chan-< int) {
<-in;
if <-ch != val {
panic val
panic(val)
}
out -< 1
}
Expand Down
42 changes: 21 additions & 21 deletions test/chan/nonblock.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,31 @@ func pause() {
}

func i32receiver(c *chan int32) {
if <-c != 123 { panic "i32 value" }
if <-c != 123 { panic("i32 value") }
}

func i32sender(c *chan int32) {
c -< 234
}

func i64receiver(c *chan int64) {
if <-c != 123456 { panic "i64 value" }
if <-c != 123456 { panic("i64 value") }
}

func i64sender(c *chan int64) {
c -< 234567
}

func breceiver(c *chan bool) {
if ! <-c { panic "b value" }
if ! <-c { panic("b value") }
}

func bsender(c *chan bool) {
c -< true
}

func sreceiver(c *chan string) {
if <-c != "hello" { panic "s value" }
if <-c != "hello" { panic("s value") }
}

func ssender(c *chan string) {
Expand All @@ -58,55 +58,55 @@ func main() {
cs := new(chan string);

i32, ok = <-c32;
if ok { panic "blocked i32sender" }
if ok { panic("blocked i32sender") }

i64, ok = <-c64;
if ok { panic "blocked i64sender" }
if ok { panic("blocked i64sender") }

b, ok = <-cb;
if ok { panic "blocked bsender" }
if ok { panic("blocked bsender") }

s, ok = <-cs;
if ok { panic "blocked ssender" }
if ok { panic("blocked ssender") }

go i32receiver(c32);
pause();
ok = c32 -< 123;
if !ok { panic "i32receiver" }
if !ok { panic("i32receiver") }
go i32sender(c32);
pause();
i32, ok = <-c32;
if !ok { panic "i32sender" }
if i32 != 234 { panic "i32sender value" }
if !ok { panic("i32sender") }
if i32 != 234 { panic("i32sender value") }

go i64receiver(c64);
pause();
ok = c64 -< 123456;
if !ok { panic "i64receiver" }
if !ok { panic("i64receiver") }
go i64sender(c64);
pause();
i64, ok = <-c64;
if !ok { panic "i64sender" }
if i64 != 234567 { panic "i64sender value" }
if !ok { panic("i64sender") }
if i64 != 234567 { panic("i64sender value") }

go breceiver(cb);
pause();
ok = cb -< true;
if !ok { panic "breceiver" }
if !ok { panic("breceiver") }
go bsender(cb);
pause();
b, ok = <-cb;
if !ok { panic "bsender" }
if !b{ panic "bsender value" }
if !ok { panic("bsender") }
if !b{ panic("bsender value") }

go sreceiver(cs);
pause();
ok = cs -< "hello";
if !ok { panic "sreceiver" }
if !ok { panic("sreceiver") }
go ssender(cs);
pause();
s, ok = <-cs;
if !ok { panic "ssender" }
if s != "hello again" { panic "ssender value" }
print "PASS\n"
if !ok { panic("ssender") }
if s != "hello again" { panic("ssender value") }
print("PASS\n")
}
42 changes: 21 additions & 21 deletions test/chan/powser1.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ type rat struct {
}

func (u *rat) pr(){
if u.den==1 { print u.num }
else { print u.num, "/", u.den }
if u.den==1 { print(u.num) }
else { print(u.num, "/", u.den) }
print(" ")
}

Expand Down Expand Up @@ -126,7 +126,7 @@ func get(in *dch) item{

func getn(in *[]*dch, n int) *[]item {
// BUG n:=len(in);
if n != 2 { panic "bad n in getn" };
if n != 2 { panic("bad n in getn") };
req := new([2] *chan int);
dat := new([2] *chan item);
out := new([2] item);
Expand Down Expand Up @@ -264,7 +264,7 @@ func sub(u, v *rat) *rat{
}

func inv(u *rat) *rat{ // invert a rat
if u.num == 0 { panic "zero divide in inv" }
if u.num == 0 { panic("zero divide in inv") }
return i2tor(u.den, u.num);
}

Expand All @@ -283,7 +283,7 @@ Evaln(c *rat, U PS, n int)
val = val + x * float64(u.num)/float64(u.den);
xn = xn*x;
}
print val, "\n";
print(val, "\n");
}

// Print n terms of a power series
Expand All @@ -294,7 +294,7 @@ func Printn(U PS, n int){
if end(u) != 0 { done = true }
else { u.pr() }
}
print ("\n");
print(("\n"));
}

func Print(U PS){
Expand Down Expand Up @@ -614,12 +614,12 @@ func check(U PS, c *rat, count int, str string) {
for i := 0; i < count; i++ {
r := get(U)
if !r.eq(c) {
print "got: ";
print("got: ");
r.pr();
print "should get ";
print("should get ");
c.pr();
print "\n";
panic str
print("\n");
panic(str)
}
}
}
Expand All @@ -634,17 +634,17 @@ func checka(U PS, a *[]*rat, str string) {
func main() {
Init();
if sys.argc() > 1 { // print
print "Ones: "; Printn(Ones, 10);
print "Twos: "; Printn(Twos, 10);
print "Add: "; Printn(Add(Ones, Twos), 10);
print "Diff: "; Printn(Diff(Ones), 10);
print "Integ: "; Printn(Integ(zero, Ones), 10);
print "CMul: "; Printn(Cmul(neg(one), Ones), 10);
print "Sub: "; Printn(Sub(Ones, Twos), 10);
print "Mul: "; Printn(Mul(Ones, Ones), 10);
print "Exp: "; Printn(Exp(Ones), 15);
print "MonSubst: "; Printn(MonSubst(Ones, neg(one), 2), 10);
print "ATan: "; Printn(Integ(zero, MonSubst(Ones, neg(one), 2)), 10);
print("Ones: "); Printn(Ones, 10);
print("Twos: "); Printn(Twos, 10);
print("Add: "); Printn(Add(Ones, Twos), 10);
print("Diff: "); Printn(Diff(Ones), 10);
print("Integ: "); Printn(Integ(zero, Ones), 10);
print("CMul: "); Printn(Cmul(neg(one), Ones), 10);
print("Sub: "); Printn(Sub(Ones, Twos), 10);
print("Mul: "); Printn(Mul(Ones, Ones), 10);
print("Exp: "); Printn(Exp(Ones), 15);
print("MonSubst: "); Printn(MonSubst(Ones, neg(one), 2), 10);
print("ATan: "); Printn(Integ(zero, MonSubst(Ones, neg(one), 2)), 10);
} else { // test
check(Ones, one, 5, "Ones");
check(Add(Ones, Ones), itor(2), 0, "Add Ones Ones"); // 1 1 1 1 1
Expand Down
50 changes: 25 additions & 25 deletions test/chan/sieve.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,30 +43,30 @@ func Sieve(primes *chan-< int) {
func main() {
primes := new(chan int);
go Sieve(primes);
if <-primes != 2 { panic 2 }
if <-primes != 3 { panic 3 }
if <-primes != 5 { panic 5 }
if <-primes != 7 { panic 7 }
if <-primes != 11 { panic 11 }
if <-primes != 13 { panic 13 }
if <-primes != 17 { panic 17 }
if <-primes != 19 { panic 19 }
if <-primes != 23 { panic 23 }
if <-primes != 29 { panic 29 }
if <-primes != 31 { panic 31 }
if <-primes != 37 { panic 37 }
if <-primes != 41 { panic 41 }
if <-primes != 43 { panic 43 }
if <-primes != 47 { panic 47 }
if <-primes != 53 { panic 53 }
if <-primes != 59 { panic 59 }
if <-primes != 61 { panic 61 }
if <-primes != 67 { panic 67 }
if <-primes != 71 { panic 71 }
if <-primes != 73 { panic 73 }
if <-primes != 79 { panic 79 }
if <-primes != 83 { panic 83 }
if <-primes != 89 { panic 89 }
if <-primes != 97 { panic 97 }
if <-primes != 2 { panic(2) }
if <-primes != 3 { panic(3) }
if <-primes != 5 { panic(5) }
if <-primes != 7 { panic(7) }
if <-primes != 11 { panic(11) }
if <-primes != 13 { panic(13) }
if <-primes != 17 { panic(17) }
if <-primes != 19 { panic(19) }
if <-primes != 23 { panic(23) }
if <-primes != 29 { panic(29) }
if <-primes != 31 { panic(31) }
if <-primes != 37 { panic(37) }
if <-primes != 41 { panic(41) }
if <-primes != 43 { panic(43) }
if <-primes != 47 { panic(47) }
if <-primes != 53 { panic(53) }
if <-primes != 59 { panic(59) }
if <-primes != 61 { panic(61) }
if <-primes != 67 { panic(67) }
if <-primes != 71 { panic(71) }
if <-primes != 73 { panic(73) }
if <-primes != 79 { panic(79) }
if <-primes != 83 { panic(83) }
if <-primes != 89 { panic(89) }
if <-primes != 97 { panic(97) }
sys.exit(0);
}
Loading

0 comments on commit bc2f5f1

Please sign in to comment.