aboutsummaryrefslogtreecommitdiff
path: root/test/zerodivide.go
diff options
context:
space:
mode:
authorEmmanuel Odeke <emm.odeke@gmail.com>2016-12-23 03:23:10 -0800
committerKeith Randall <khr@golang.org>2016-12-23 17:35:24 +0000
commitc8f1436948ca267dc904cf04c67bab7367503107 (patch)
tree50a021888cd09fbeb8339c792ba728e46a4a1f98 /test/zerodivide.go
parentdb07c9ecb617117a86364e9e03acd6f7937e1732 (diff)
downloadgo-c8f1436948ca267dc904cf04c67bab7367503107.tar.gz
go-c8f1436948ca267dc904cf04c67bab7367503107.zip
test: lock in test for _ assignment evaluation/zerodivide panic
Fixes #5790. Fixes #18421. * Lock in _ = x1/x2 divide by zero runtime panics since it is actually evaluated and not discarded as in previous versions before Go1.8. * Update a test that was skipping over zerodivide tests that expected runtime panics, enabling us to check for the expected panics. Change-Id: I0af0a6ecc19345fa9763ab2e35b275fb2d9d0194 Reviewed-on: https://go-review.googlesource.com/34712 Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'test/zerodivide.go')
-rw-r--r--test/zerodivide.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/test/zerodivide.go b/test/zerodivide.go
index 9ab2713535..214d481164 100644
--- a/test/zerodivide.go
+++ b/test/zerodivide.go
@@ -28,6 +28,8 @@ var (
i32, j32, k32 int32 = 0, 0, 1
i64, j64, k64 int64 = 0, 0, 1
+ bb = []int16{2, 0}
+
u, v, w uint = 0, 0, 1
u8, v8, w8 uint8 = 0, 0, 1
u16, v16, w16 uint16 = 0, 0, 1
@@ -124,6 +126,10 @@ var errorTests = []ErrorTest{
ErrorTest{"int32 1/0", func() { use(k32 / j32) }, "divide"},
ErrorTest{"int64 1/0", func() { use(k64 / j64) }, "divide"},
+ // From issue 5790, we should ensure that _ assignments
+ // still evaluate and generate zerodivide panics.
+ ErrorTest{"int16 _ = bb[0]/bb[1]", func() { _ = bb[0] / bb[1] }, "divide"},
+
ErrorTest{"uint 0/0", func() { use(u / v) }, "divide"},
ErrorTest{"uint8 0/0", func() { use(u8 / v8) }, "divide"},
ErrorTest{"uint16 0/0", func() { use(u16 / v16) }, "divide"},
@@ -195,9 +201,6 @@ func alike(a, b float64) bool {
func main() {
bad := false
for _, t := range errorTests {
- if t.err != "" {
- continue
- }
err := error_(t.fn)
switch {
case t.err == "" && err == "":