diff options
Diffstat (limited to 'test/chan')
-rw-r--r-- | test/chan/fifo.go | 4 | ||||
-rw-r--r-- | test/chan/nonblock.go | 42 | ||||
-rw-r--r-- | test/chan/powser1.go | 42 | ||||
-rw-r--r-- | test/chan/sieve.go | 50 |
4 files changed, 69 insertions, 69 deletions
diff --git a/test/chan/fifo.go b/test/chan/fifo.go index d6d6d704a..01fc016cf 100644 --- a/test/chan/fifo.go +++ b/test/chan/fifo.go @@ -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); } } @@ -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 } diff --git a/test/chan/nonblock.go b/test/chan/nonblock.go index 89ec306af..61dd06a04 100644 --- a/test/chan/nonblock.go +++ b/test/chan/nonblock.go @@ -14,7 +14,7 @@ func pause() { } func i32receiver(c *chan int32) { - if <-c != 123 { panic "i32 value" } + if <-c != 123 { panic("i32 value") } } func i32sender(c *chan int32) { @@ -22,7 +22,7 @@ func i32sender(c *chan int32) { } func i64receiver(c *chan int64) { - if <-c != 123456 { panic "i64 value" } + if <-c != 123456 { panic("i64 value") } } func i64sender(c *chan int64) { @@ -30,7 +30,7 @@ func i64sender(c *chan int64) { } func breceiver(c *chan bool) { - if ! <-c { panic "b value" } + if ! <-c { panic("b value") } } func bsender(c *chan bool) { @@ -38,7 +38,7 @@ func bsender(c *chan bool) { } func sreceiver(c *chan string) { - if <-c != "hello" { panic "s value" } + if <-c != "hello" { panic("s value") } } func ssender(c *chan string) { @@ -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") } diff --git a/test/chan/powser1.go b/test/chan/powser1.go index 5358458de..3bf70fff7 100644 --- a/test/chan/powser1.go +++ b/test/chan/powser1.go @@ -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(" ") } @@ -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); @@ -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); } @@ -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 @@ -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){ @@ -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) } } } @@ -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 diff --git a/test/chan/sieve.go b/test/chan/sieve.go index 6fd28e513..2d55a2a99 100644 --- a/test/chan/sieve.go +++ b/test/chan/sieve.go @@ -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); } |