Commit 707fd452 authored by Keith Randall's avatar Keith Randall Committed by Keith Randall

cmd/compile: enable two orphaned tests

These tests weren't being run.  Re-enable them.

R=go1.12

Change-Id: I8d3cd09b7f07e4c39f855ddb9be000718ec86494
Reviewed-on: https://go-review.googlesource.com/127117
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarDavid Chase <drchase@google.com>
parent dca709da
...@@ -5,9 +5,7 @@ ...@@ -5,9 +5,7 @@
// cmp_ssa.go tests compare simplification operations. // cmp_ssa.go tests compare simplification operations.
package main package main
import "fmt" import "testing"
var failed = false
//go:noinline //go:noinline
func eq_ssa(a int64) bool { func eq_ssa(a int64) bool {
...@@ -19,30 +17,21 @@ func neq_ssa(a int64) bool { ...@@ -19,30 +17,21 @@ func neq_ssa(a int64) bool {
return 10 != a+4 return 10 != a+4
} }
func testCmp() { func testCmp(t *testing.T) {
if wanted, got := true, eq_ssa(6); wanted != got { if wanted, got := true, eq_ssa(6); wanted != got {
fmt.Printf("eq_ssa: expected %v, got %v\n", wanted, got) t.Errorf("eq_ssa: expected %v, got %v\n", wanted, got)
failed = true
} }
if wanted, got := false, eq_ssa(7); wanted != got { if wanted, got := false, eq_ssa(7); wanted != got {
fmt.Printf("eq_ssa: expected %v, got %v\n", wanted, got) t.Errorf("eq_ssa: expected %v, got %v\n", wanted, got)
failed = true
} }
if wanted, got := false, neq_ssa(6); wanted != got { if wanted, got := false, neq_ssa(6); wanted != got {
fmt.Printf("neq_ssa: expected %v, got %v\n", wanted, got) t.Errorf("neq_ssa: expected %v, got %v\n", wanted, got)
failed = true
} }
if wanted, got := true, neq_ssa(7); wanted != got { if wanted, got := true, neq_ssa(7); wanted != got {
fmt.Printf("neq_ssa: expected %v, got %v\n", wanted, got) t.Errorf("neq_ssa: expected %v, got %v\n", wanted, got)
failed = true
} }
} }
func main() { func TestCmp(t *testing.T) {
testCmp() testCmp(t)
if failed {
panic("failed")
}
} }
package main package main
import ( import (
"fmt"
"runtime" "runtime"
"testing"
) )
var failed = false
func checkDivByZero(f func()) (divByZero bool) { func checkDivByZero(f func()) (divByZero bool) {
defer func() { defer func() {
if r := recover(); r != nil { if r := recover(); r != nil {
...@@ -20,39 +18,31 @@ func checkDivByZero(f func()) (divByZero bool) { ...@@ -20,39 +18,31 @@ func checkDivByZero(f func()) (divByZero bool) {
} }
//go:noinline //go:noinline
func a(i uint, s []int) int { func div_a(i uint, s []int) int {
return s[i%uint(len(s))] return s[i%uint(len(s))]
} }
//go:noinline //go:noinline
func b(i uint, j uint) uint { func div_b(i uint, j uint) uint {
return i / j return i / j
} }
//go:noinline //go:noinline
func c(i int) int { func div_c(i int) int {
return 7 / (i - i) return 7 / (i - i)
} }
func main() { func TestDivByZero(t *testing.T) {
if got := checkDivByZero(func() { b(7, 0) }); !got { if got := checkDivByZero(func() { div_b(7, 0) }); !got {
fmt.Printf("expected div by zero for b(7, 0), got no error\n") t.Errorf("expected div by zero for b(7, 0), got no error\n")
failed = true
}
if got := checkDivByZero(func() { b(7, 7) }); got {
fmt.Printf("expected no error for b(7, 7), got div by zero\n")
failed = true
} }
if got := checkDivByZero(func() { a(4, nil) }); !got { if got := checkDivByZero(func() { div_b(7, 7) }); got {
fmt.Printf("expected div by zero for a(4, nil), got no error\n") t.Errorf("expected no error for b(7, 7), got div by zero\n")
failed = true
} }
if got := checkDivByZero(func() { c(5) }); !got { if got := checkDivByZero(func() { div_a(4, nil) }); !got {
fmt.Printf("expected div by zero for c(5), got no error\n") t.Errorf("expected div by zero for a(4, nil), got no error\n")
failed = true
} }
if got := checkDivByZero(func() { div_c(5) }); !got {
if failed { t.Errorf("expected div by zero for c(5), got no error\n")
panic("tests failed")
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment