diff options
author | Rob Pike <r@golang.org> | 2010-03-24 16:46:53 -0700 |
---|---|---|
committer | Rob Pike <r@golang.org> | 2010-03-24 16:46:53 -0700 |
commit | 420d470e6ef507a6183e49c42f04051349803487 (patch) | |
tree | 19bab8994a6a628a1309f01d31a9809d6f6ac5be /test/ddd.go | |
parent | e2854b2f5f4789b20941f5b35082d9fa33c152e3 (diff) | |
download | golang-420d470e6ef507a6183e49c42f04051349803487.tar.gz |
delete all uses of panicln by rewriting them using panic or,
in the tests, println+panic.
gofmt some tests too.
R=rsc
CC=golang-dev
http://codereview.appspot.com/741041
Diffstat (limited to 'test/ddd.go')
-rw-r--r-- | test/ddd.go | 129 |
1 files changed, 80 insertions, 49 deletions
diff --git a/test/ddd.go b/test/ddd.go index e633842f5..c9949c36e 100644 --- a/test/ddd.go +++ b/test/ddd.go @@ -14,13 +14,11 @@ func sum(args ...int) int { return s } -func sumC(args ...int) int { - return func() int { return sum(args) } () -} +func sumC(args ...int) int { return func() int { return sum(args) }() } var sumD = func(args ...int) int { return sum(args) } -var sumE = func() func(...int) int { return func(args ...int) int { return sum(args) } } () +var sumE = func() func(...int) int { return func(args ...int) int { return sum(args) } }() var sumF = func(args ...int) func() int { return func() int { return sum(args) } } @@ -50,9 +48,7 @@ func ln(args ...T) int { return len(args) } func ln2(args ...T) int { return 2 * ln(args) } -func (*T) Sum(args ...int) int { - return sum(args) -} +func (*T) Sum(args ...int) int { return sum(args) } type U struct { *T @@ -60,108 +56,143 @@ type U struct { func main() { if x := sum(1, 2, 3); x != 6 { - panicln("sum 6", x) + println("sum 6", x) + panic("fail") } if x := sum(); x != 0 { - panicln("sum 0", x) + println("sum 0", x) + panic("fail") } if x := sum(10); x != 10 { - panicln("sum 10", x) + println("sum 10", x) + panic("fail") } if x := sum(1, 8); x != 9 { - panicln("sum 9", x) + println("sum 9", x) + panic("fail") } if x := sumC(4, 5, 6); x != 15 { - panicln("sumC 15", x) + println("sumC 15", x) + panic("fail") } if x := sumD(4, 5, 7); x != 16 { - panicln("sumD 16", x) + println("sumD 16", x) + panic("fail") } if x := sumE(4, 5, 8); x != 17 { - panicln("sumE 17", x) + println("sumE 17", x) + panic("fail") } if x := sumF(4, 5, 9)(); x != 18 { - panicln("sumF 18", x) + println("sumF 18", x) + panic("fail") } if x := sum2(1, 2, 3); x != 2*6 { - panicln("sum 6", x) + println("sum 6", x) + panic("fail") } if x := sum2(); x != 2*0 { - panicln("sum 0", x) + println("sum 0", x) + panic("fail") } if x := sum2(10); x != 2*10 { - panicln("sum 10", x) + println("sum 10", x) + panic("fail") } if x := sum2(1, 8); x != 2*9 { - panicln("sum 9", x) + println("sum 9", x) + panic("fail") } if x := sum3(1, 2, 3); x != 3*6 { - panicln("sum 6", x) + println("sum 6", x) + panic("fail") } if x := sum3(); x != 3*0 { - panicln("sum 0", x) + println("sum 0", x) + panic("fail") } if x := sum3(10); x != 3*10 { - panicln("sum 10", x) + println("sum 10", x) + panic("fail") } if x := sum3(1, 8); x != 3*9 { - panicln("sum 9", x) + println("sum 9", x) + panic("fail") } if x := intersum(1, 2, 3); x != 6 { - panicln("intersum 6", x) + println("intersum 6", x) + panic("fail") } if x := intersum(); x != 0 { - panicln("intersum 0", x) + println("intersum 0", x) + panic("fail") } if x := intersum(10); x != 10 { - panicln("intersum 10", x) + println("intersum 10", x) + panic("fail") } if x := intersum(1, 8); x != 9 { - panicln("intersum 9", x) + println("intersum 9", x) + panic("fail") } if x := ln(nil, nil, nil); x != 3 { - panicln("ln 3", x) + println("ln 3", x) + panic("fail") } if x := ln([]T{}); x != 1 { - panicln("ln 1", x) + println("ln 1", x) + panic("fail") } if x := ln2(nil, nil, nil); x != 2*3 { - panicln("ln2 3", x) + println("ln2 3", x) + panic("fail") } if x := ln2([]T{}); x != 2*1 { - panicln("ln2 1", x) + println("ln2 1", x) + panic("fail") } - if x := ((*T)(nil)).Sum(1,3,5,7); x != 16 { - panicln("(*T)(nil).Sum", x) + if x := ((*T)(nil)).Sum(1, 3, 5, 7); x != 16 { + println("(*T)(nil).Sum", x) + panic("fail") } if x := (*T).Sum(nil, 1, 3, 5, 6); x != 15 { - panicln("(*T).Sum", x) + println("(*T).Sum", x) + panic("fail") } - if x := (&U{}).Sum(1,3,5,5); x != 14 { - panicln("(&U{}).Sum", x) + if x := (&U{}).Sum(1, 3, 5, 5); x != 14 { + println("(&U{}).Sum", x) + panic("fail") } var u U - if x := u.Sum(1,3,5,4); x != 13 { - panicln("u.Sum", x) + if x := u.Sum(1, 3, 5, 4); x != 13 { + println("u.Sum", x) + panic("fail") } - if x := (&u).Sum(1,3,5,3); x != 12 { - panicln("(&u).Sum", x) + if x := (&u).Sum(1, 3, 5, 3); x != 12 { + println("(&u).Sum", x) + panic("fail") } - var i interface { Sum(...int) int } = &u - if x := i.Sum(2,3,5,7); x != 17 { - panicln("i(=&u).Sum", x) + var i interface { + Sum(...int) int + } = &u + if x := i.Sum(2, 3, 5, 7); x != 17 { + println("i(=&u).Sum", x) + panic("fail") } i = u - if x := i.Sum(2,3,5,6); x != 16 { - panicln("i(=u).Sum", x) + if x := i.Sum(2, 3, 5, 6); x != 16 { + println("i(=u).Sum", x) + panic("fail") } -/* TODO(rsc): Enable once nested method expressions work. + /* TODO(rsc): Enable once nested method expressions work. if x := (*U).Sum(&U{}, 1, 3, 5, 2); x != 11 { - panicln("(*U).Sum", x) + println("(*U).Sum", x) + panic("fail") } if x := U.Sum(U{}, 1, 3, 5, 1); x != 10 { - panicln("U.Sum", x) + println("U.Sum", x) + panic("fail") } -*/ + */ } |