mirror of
https://github.com/golang/go
synced 2024-11-23 15:30:05 -07:00
cmd/compile: move autogenerated tests to new infrastructure
Update #26469 R=go1.12 Change-Id: Ib9a00ee5e98371769669bb9cad58320b66127374 Reviewed-on: https://go-review.googlesource.com/127095 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
This commit is contained in:
parent
ed21535a60
commit
776298abdc
@ -227,17 +227,8 @@ func TestCode(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestArithmeticBoundary tests boundary results for arithmetic operations.
|
||||
func TestArithmeticBoundary(t *testing.T) { runTest(t, "arithBoundary.go") }
|
||||
|
||||
// TestArithmeticConst tests results for arithmetic operations against constants.
|
||||
func TestArithmeticConst(t *testing.T) { runTest(t, "arithConst.go") }
|
||||
|
||||
func TestChan(t *testing.T) { runTest(t, "chan.go") }
|
||||
|
||||
// TestComparisonsConst tests results for comparison operations against constants.
|
||||
func TestComparisonsConst(t *testing.T) { runTest(t, "cmpConst.go") }
|
||||
|
||||
func TestCompound(t *testing.T) { runTest(t, "compound.go") }
|
||||
|
||||
func TestCtl(t *testing.T) { runTest(t, "ctl.go") }
|
||||
@ -259,12 +250,8 @@ func TestArray(t *testing.T) { runTest(t, "array.go") }
|
||||
|
||||
func TestAppend(t *testing.T) { runTest(t, "append.go") }
|
||||
|
||||
func TestZero(t *testing.T) { runTest(t, "zero.go") }
|
||||
|
||||
func TestAddressed(t *testing.T) { runTest(t, "addressed.go") }
|
||||
|
||||
func TestCopy(t *testing.T) { runTest(t, "copy.go") }
|
||||
|
||||
func TestUnsafe(t *testing.T) { runTest(t, "unsafe.go") }
|
||||
|
||||
func TestPhi(t *testing.T) { runTest(t, "phi.go") }
|
||||
|
@ -1,9 +1,8 @@
|
||||
// run
|
||||
// Code generated by gen/arithBoundaryGen.go. DO NOT EDIT.
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
import "testing"
|
||||
|
||||
type utd64 struct {
|
||||
a, b uint64
|
||||
@ -504,235 +503,192 @@ var int8_data []itd8 = []itd8{itd8{a: -128, b: -128, add: 0, sub: 0, mul: 0, div
|
||||
itd8{a: 127, b: 126, add: -3, sub: 1, mul: -126, div: 1, mod: 1},
|
||||
itd8{a: 127, b: 127, add: -2, sub: 0, mul: 1, div: 1, mod: 0},
|
||||
}
|
||||
var failed bool
|
||||
|
||||
func main() {
|
||||
//TestArithmeticBoundary tests boundary results for arithmetic operations.
|
||||
func TestArithmeticBoundary(t *testing.T) {
|
||||
|
||||
for _, v := range uint64_data {
|
||||
if got := add_uint64_ssa(v.a, v.b); got != v.add {
|
||||
fmt.Printf("add_uint64 %d+%d = %d, wanted %d\n", v.a, v.b, got, v.add)
|
||||
failed = true
|
||||
t.Errorf("add_uint64 %d+%d = %d, wanted %d\n", v.a, v.b, got, v.add)
|
||||
}
|
||||
if got := sub_uint64_ssa(v.a, v.b); got != v.sub {
|
||||
fmt.Printf("sub_uint64 %d-%d = %d, wanted %d\n", v.a, v.b, got, v.sub)
|
||||
failed = true
|
||||
t.Errorf("sub_uint64 %d-%d = %d, wanted %d\n", v.a, v.b, got, v.sub)
|
||||
}
|
||||
if v.b != 0 {
|
||||
if got := div_uint64_ssa(v.a, v.b); got != v.div {
|
||||
fmt.Printf("div_uint64 %d/%d = %d, wanted %d\n", v.a, v.b, got, v.div)
|
||||
failed = true
|
||||
t.Errorf("div_uint64 %d/%d = %d, wanted %d\n", v.a, v.b, got, v.div)
|
||||
}
|
||||
|
||||
}
|
||||
if v.b != 0 {
|
||||
if got := mod_uint64_ssa(v.a, v.b); got != v.mod {
|
||||
fmt.Printf("mod_uint64 %d%%%d = %d, wanted %d\n", v.a, v.b, got, v.mod)
|
||||
failed = true
|
||||
t.Errorf("mod_uint64 %d%%%d = %d, wanted %d\n", v.a, v.b, got, v.mod)
|
||||
}
|
||||
|
||||
}
|
||||
if got := mul_uint64_ssa(v.a, v.b); got != v.mul {
|
||||
fmt.Printf("mul_uint64 %d*%d = %d, wanted %d\n", v.a, v.b, got, v.mul)
|
||||
failed = true
|
||||
t.Errorf("mul_uint64 %d*%d = %d, wanted %d\n", v.a, v.b, got, v.mul)
|
||||
}
|
||||
}
|
||||
for _, v := range int64_data {
|
||||
if got := add_int64_ssa(v.a, v.b); got != v.add {
|
||||
fmt.Printf("add_int64 %d+%d = %d, wanted %d\n", v.a, v.b, got, v.add)
|
||||
failed = true
|
||||
t.Errorf("add_int64 %d+%d = %d, wanted %d\n", v.a, v.b, got, v.add)
|
||||
}
|
||||
if got := sub_int64_ssa(v.a, v.b); got != v.sub {
|
||||
fmt.Printf("sub_int64 %d-%d = %d, wanted %d\n", v.a, v.b, got, v.sub)
|
||||
failed = true
|
||||
t.Errorf("sub_int64 %d-%d = %d, wanted %d\n", v.a, v.b, got, v.sub)
|
||||
}
|
||||
if v.b != 0 {
|
||||
if got := div_int64_ssa(v.a, v.b); got != v.div {
|
||||
fmt.Printf("div_int64 %d/%d = %d, wanted %d\n", v.a, v.b, got, v.div)
|
||||
failed = true
|
||||
t.Errorf("div_int64 %d/%d = %d, wanted %d\n", v.a, v.b, got, v.div)
|
||||
}
|
||||
|
||||
}
|
||||
if v.b != 0 {
|
||||
if got := mod_int64_ssa(v.a, v.b); got != v.mod {
|
||||
fmt.Printf("mod_int64 %d%%%d = %d, wanted %d\n", v.a, v.b, got, v.mod)
|
||||
failed = true
|
||||
t.Errorf("mod_int64 %d%%%d = %d, wanted %d\n", v.a, v.b, got, v.mod)
|
||||
}
|
||||
|
||||
}
|
||||
if got := mul_int64_ssa(v.a, v.b); got != v.mul {
|
||||
fmt.Printf("mul_int64 %d*%d = %d, wanted %d\n", v.a, v.b, got, v.mul)
|
||||
failed = true
|
||||
t.Errorf("mul_int64 %d*%d = %d, wanted %d\n", v.a, v.b, got, v.mul)
|
||||
}
|
||||
}
|
||||
for _, v := range uint32_data {
|
||||
if got := add_uint32_ssa(v.a, v.b); got != v.add {
|
||||
fmt.Printf("add_uint32 %d+%d = %d, wanted %d\n", v.a, v.b, got, v.add)
|
||||
failed = true
|
||||
t.Errorf("add_uint32 %d+%d = %d, wanted %d\n", v.a, v.b, got, v.add)
|
||||
}
|
||||
if got := sub_uint32_ssa(v.a, v.b); got != v.sub {
|
||||
fmt.Printf("sub_uint32 %d-%d = %d, wanted %d\n", v.a, v.b, got, v.sub)
|
||||
failed = true
|
||||
t.Errorf("sub_uint32 %d-%d = %d, wanted %d\n", v.a, v.b, got, v.sub)
|
||||
}
|
||||
if v.b != 0 {
|
||||
if got := div_uint32_ssa(v.a, v.b); got != v.div {
|
||||
fmt.Printf("div_uint32 %d/%d = %d, wanted %d\n", v.a, v.b, got, v.div)
|
||||
failed = true
|
||||
t.Errorf("div_uint32 %d/%d = %d, wanted %d\n", v.a, v.b, got, v.div)
|
||||
}
|
||||
|
||||
}
|
||||
if v.b != 0 {
|
||||
if got := mod_uint32_ssa(v.a, v.b); got != v.mod {
|
||||
fmt.Printf("mod_uint32 %d%%%d = %d, wanted %d\n", v.a, v.b, got, v.mod)
|
||||
failed = true
|
||||
t.Errorf("mod_uint32 %d%%%d = %d, wanted %d\n", v.a, v.b, got, v.mod)
|
||||
}
|
||||
|
||||
}
|
||||
if got := mul_uint32_ssa(v.a, v.b); got != v.mul {
|
||||
fmt.Printf("mul_uint32 %d*%d = %d, wanted %d\n", v.a, v.b, got, v.mul)
|
||||
failed = true
|
||||
t.Errorf("mul_uint32 %d*%d = %d, wanted %d\n", v.a, v.b, got, v.mul)
|
||||
}
|
||||
}
|
||||
for _, v := range int32_data {
|
||||
if got := add_int32_ssa(v.a, v.b); got != v.add {
|
||||
fmt.Printf("add_int32 %d+%d = %d, wanted %d\n", v.a, v.b, got, v.add)
|
||||
failed = true
|
||||
t.Errorf("add_int32 %d+%d = %d, wanted %d\n", v.a, v.b, got, v.add)
|
||||
}
|
||||
if got := sub_int32_ssa(v.a, v.b); got != v.sub {
|
||||
fmt.Printf("sub_int32 %d-%d = %d, wanted %d\n", v.a, v.b, got, v.sub)
|
||||
failed = true
|
||||
t.Errorf("sub_int32 %d-%d = %d, wanted %d\n", v.a, v.b, got, v.sub)
|
||||
}
|
||||
if v.b != 0 {
|
||||
if got := div_int32_ssa(v.a, v.b); got != v.div {
|
||||
fmt.Printf("div_int32 %d/%d = %d, wanted %d\n", v.a, v.b, got, v.div)
|
||||
failed = true
|
||||
t.Errorf("div_int32 %d/%d = %d, wanted %d\n", v.a, v.b, got, v.div)
|
||||
}
|
||||
|
||||
}
|
||||
if v.b != 0 {
|
||||
if got := mod_int32_ssa(v.a, v.b); got != v.mod {
|
||||
fmt.Printf("mod_int32 %d%%%d = %d, wanted %d\n", v.a, v.b, got, v.mod)
|
||||
failed = true
|
||||
t.Errorf("mod_int32 %d%%%d = %d, wanted %d\n", v.a, v.b, got, v.mod)
|
||||
}
|
||||
|
||||
}
|
||||
if got := mul_int32_ssa(v.a, v.b); got != v.mul {
|
||||
fmt.Printf("mul_int32 %d*%d = %d, wanted %d\n", v.a, v.b, got, v.mul)
|
||||
failed = true
|
||||
t.Errorf("mul_int32 %d*%d = %d, wanted %d\n", v.a, v.b, got, v.mul)
|
||||
}
|
||||
}
|
||||
for _, v := range uint16_data {
|
||||
if got := add_uint16_ssa(v.a, v.b); got != v.add {
|
||||
fmt.Printf("add_uint16 %d+%d = %d, wanted %d\n", v.a, v.b, got, v.add)
|
||||
failed = true
|
||||
t.Errorf("add_uint16 %d+%d = %d, wanted %d\n", v.a, v.b, got, v.add)
|
||||
}
|
||||
if got := sub_uint16_ssa(v.a, v.b); got != v.sub {
|
||||
fmt.Printf("sub_uint16 %d-%d = %d, wanted %d\n", v.a, v.b, got, v.sub)
|
||||
failed = true
|
||||
t.Errorf("sub_uint16 %d-%d = %d, wanted %d\n", v.a, v.b, got, v.sub)
|
||||
}
|
||||
if v.b != 0 {
|
||||
if got := div_uint16_ssa(v.a, v.b); got != v.div {
|
||||
fmt.Printf("div_uint16 %d/%d = %d, wanted %d\n", v.a, v.b, got, v.div)
|
||||
failed = true
|
||||
t.Errorf("div_uint16 %d/%d = %d, wanted %d\n", v.a, v.b, got, v.div)
|
||||
}
|
||||
|
||||
}
|
||||
if v.b != 0 {
|
||||
if got := mod_uint16_ssa(v.a, v.b); got != v.mod {
|
||||
fmt.Printf("mod_uint16 %d%%%d = %d, wanted %d\n", v.a, v.b, got, v.mod)
|
||||
failed = true
|
||||
t.Errorf("mod_uint16 %d%%%d = %d, wanted %d\n", v.a, v.b, got, v.mod)
|
||||
}
|
||||
|
||||
}
|
||||
if got := mul_uint16_ssa(v.a, v.b); got != v.mul {
|
||||
fmt.Printf("mul_uint16 %d*%d = %d, wanted %d\n", v.a, v.b, got, v.mul)
|
||||
failed = true
|
||||
t.Errorf("mul_uint16 %d*%d = %d, wanted %d\n", v.a, v.b, got, v.mul)
|
||||
}
|
||||
}
|
||||
for _, v := range int16_data {
|
||||
if got := add_int16_ssa(v.a, v.b); got != v.add {
|
||||
fmt.Printf("add_int16 %d+%d = %d, wanted %d\n", v.a, v.b, got, v.add)
|
||||
failed = true
|
||||
t.Errorf("add_int16 %d+%d = %d, wanted %d\n", v.a, v.b, got, v.add)
|
||||
}
|
||||
if got := sub_int16_ssa(v.a, v.b); got != v.sub {
|
||||
fmt.Printf("sub_int16 %d-%d = %d, wanted %d\n", v.a, v.b, got, v.sub)
|
||||
failed = true
|
||||
t.Errorf("sub_int16 %d-%d = %d, wanted %d\n", v.a, v.b, got, v.sub)
|
||||
}
|
||||
if v.b != 0 {
|
||||
if got := div_int16_ssa(v.a, v.b); got != v.div {
|
||||
fmt.Printf("div_int16 %d/%d = %d, wanted %d\n", v.a, v.b, got, v.div)
|
||||
failed = true
|
||||
t.Errorf("div_int16 %d/%d = %d, wanted %d\n", v.a, v.b, got, v.div)
|
||||
}
|
||||
|
||||
}
|
||||
if v.b != 0 {
|
||||
if got := mod_int16_ssa(v.a, v.b); got != v.mod {
|
||||
fmt.Printf("mod_int16 %d%%%d = %d, wanted %d\n", v.a, v.b, got, v.mod)
|
||||
failed = true
|
||||
t.Errorf("mod_int16 %d%%%d = %d, wanted %d\n", v.a, v.b, got, v.mod)
|
||||
}
|
||||
|
||||
}
|
||||
if got := mul_int16_ssa(v.a, v.b); got != v.mul {
|
||||
fmt.Printf("mul_int16 %d*%d = %d, wanted %d\n", v.a, v.b, got, v.mul)
|
||||
failed = true
|
||||
t.Errorf("mul_int16 %d*%d = %d, wanted %d\n", v.a, v.b, got, v.mul)
|
||||
}
|
||||
}
|
||||
for _, v := range uint8_data {
|
||||
if got := add_uint8_ssa(v.a, v.b); got != v.add {
|
||||
fmt.Printf("add_uint8 %d+%d = %d, wanted %d\n", v.a, v.b, got, v.add)
|
||||
failed = true
|
||||
t.Errorf("add_uint8 %d+%d = %d, wanted %d\n", v.a, v.b, got, v.add)
|
||||
}
|
||||
if got := sub_uint8_ssa(v.a, v.b); got != v.sub {
|
||||
fmt.Printf("sub_uint8 %d-%d = %d, wanted %d\n", v.a, v.b, got, v.sub)
|
||||
failed = true
|
||||
t.Errorf("sub_uint8 %d-%d = %d, wanted %d\n", v.a, v.b, got, v.sub)
|
||||
}
|
||||
if v.b != 0 {
|
||||
if got := div_uint8_ssa(v.a, v.b); got != v.div {
|
||||
fmt.Printf("div_uint8 %d/%d = %d, wanted %d\n", v.a, v.b, got, v.div)
|
||||
failed = true
|
||||
t.Errorf("div_uint8 %d/%d = %d, wanted %d\n", v.a, v.b, got, v.div)
|
||||
}
|
||||
|
||||
}
|
||||
if v.b != 0 {
|
||||
if got := mod_uint8_ssa(v.a, v.b); got != v.mod {
|
||||
fmt.Printf("mod_uint8 %d%%%d = %d, wanted %d\n", v.a, v.b, got, v.mod)
|
||||
failed = true
|
||||
t.Errorf("mod_uint8 %d%%%d = %d, wanted %d\n", v.a, v.b, got, v.mod)
|
||||
}
|
||||
|
||||
}
|
||||
if got := mul_uint8_ssa(v.a, v.b); got != v.mul {
|
||||
fmt.Printf("mul_uint8 %d*%d = %d, wanted %d\n", v.a, v.b, got, v.mul)
|
||||
failed = true
|
||||
t.Errorf("mul_uint8 %d*%d = %d, wanted %d\n", v.a, v.b, got, v.mul)
|
||||
}
|
||||
}
|
||||
for _, v := range int8_data {
|
||||
if got := add_int8_ssa(v.a, v.b); got != v.add {
|
||||
fmt.Printf("add_int8 %d+%d = %d, wanted %d\n", v.a, v.b, got, v.add)
|
||||
failed = true
|
||||
t.Errorf("add_int8 %d+%d = %d, wanted %d\n", v.a, v.b, got, v.add)
|
||||
}
|
||||
if got := sub_int8_ssa(v.a, v.b); got != v.sub {
|
||||
fmt.Printf("sub_int8 %d-%d = %d, wanted %d\n", v.a, v.b, got, v.sub)
|
||||
failed = true
|
||||
t.Errorf("sub_int8 %d-%d = %d, wanted %d\n", v.a, v.b, got, v.sub)
|
||||
}
|
||||
if v.b != 0 {
|
||||
if got := div_int8_ssa(v.a, v.b); got != v.div {
|
||||
fmt.Printf("div_int8 %d/%d = %d, wanted %d\n", v.a, v.b, got, v.div)
|
||||
failed = true
|
||||
t.Errorf("div_int8 %d/%d = %d, wanted %d\n", v.a, v.b, got, v.div)
|
||||
}
|
||||
|
||||
}
|
||||
if v.b != 0 {
|
||||
if got := mod_int8_ssa(v.a, v.b); got != v.mod {
|
||||
fmt.Printf("mod_int8 %d%%%d = %d, wanted %d\n", v.a, v.b, got, v.mod)
|
||||
failed = true
|
||||
t.Errorf("mod_int8 %d%%%d = %d, wanted %d\n", v.a, v.b, got, v.mod)
|
||||
}
|
||||
|
||||
}
|
||||
if got := mul_int8_ssa(v.a, v.b); got != v.mul {
|
||||
fmt.Printf("mul_int8 %d*%d = %d, wanted %d\n", v.a, v.b, got, v.mul)
|
||||
failed = true
|
||||
t.Errorf("mul_int8 %d*%d = %d, wanted %d\n", v.a, v.b, got, v.mul)
|
||||
}
|
||||
}
|
||||
if failed {
|
||||
panic("tests failed")
|
||||
}
|
||||
}
|
@ -1,10 +1,8 @@
|
||||
// run
|
||||
// Code generated by gen/arithConstGen.go. DO NOT EDIT.
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
import "os"
|
||||
import "testing"
|
||||
|
||||
//go:noinline
|
||||
func add_uint64_0(a uint64) uint64 { return a + 0 }
|
||||
@ -9506,83 +9504,67 @@ var tests_int8 = []test_int8{
|
||||
test_int8{fn: xor_127_int8, fnname: "xor_127_int8", in: 127, want: 0},
|
||||
test_int8{fn: xor_int8_127, fnname: "xor_int8_127", in: 127, want: 0}}
|
||||
|
||||
var failed bool
|
||||
|
||||
func main() {
|
||||
// TestArithmeticConst tests results for arithmetic operations against constants.
|
||||
func TestArithmeticConst(t *testing.T) {
|
||||
for _, test := range tests_uint64 {
|
||||
if got := test.fn(test.in); got != test.want {
|
||||
fmt.Printf("%s(%d) = %d, want %d\n", test.fnname, test.in, got, test.want)
|
||||
failed = true
|
||||
t.Errorf("%s(%d) = %d, want %d\n", test.fnname, test.in, got, test.want)
|
||||
}
|
||||
}
|
||||
for _, test := range tests_uint64mul {
|
||||
if got := test.fn(test.in); got != test.want {
|
||||
fmt.Printf("%s(%d) = %d, want %d\n", test.fnname, test.in, got, test.want)
|
||||
failed = true
|
||||
t.Errorf("%s(%d) = %d, want %d\n", test.fnname, test.in, got, test.want)
|
||||
}
|
||||
}
|
||||
for _, test := range tests_int64 {
|
||||
if got := test.fn(test.in); got != test.want {
|
||||
fmt.Printf("%s(%d) = %d, want %d\n", test.fnname, test.in, got, test.want)
|
||||
failed = true
|
||||
t.Errorf("%s(%d) = %d, want %d\n", test.fnname, test.in, got, test.want)
|
||||
}
|
||||
}
|
||||
for _, test := range tests_int64mul {
|
||||
if got := test.fn(test.in); got != test.want {
|
||||
fmt.Printf("%s(%d) = %d, want %d\n", test.fnname, test.in, got, test.want)
|
||||
failed = true
|
||||
t.Errorf("%s(%d) = %d, want %d\n", test.fnname, test.in, got, test.want)
|
||||
}
|
||||
}
|
||||
for _, test := range tests_uint32 {
|
||||
if got := test.fn(test.in); got != test.want {
|
||||
fmt.Printf("%s(%d) = %d, want %d\n", test.fnname, test.in, got, test.want)
|
||||
failed = true
|
||||
t.Errorf("%s(%d) = %d, want %d\n", test.fnname, test.in, got, test.want)
|
||||
}
|
||||
}
|
||||
for _, test := range tests_uint32mul {
|
||||
if got := test.fn(test.in); got != test.want {
|
||||
fmt.Printf("%s(%d) = %d, want %d\n", test.fnname, test.in, got, test.want)
|
||||
failed = true
|
||||
t.Errorf("%s(%d) = %d, want %d\n", test.fnname, test.in, got, test.want)
|
||||
}
|
||||
}
|
||||
for _, test := range tests_int32 {
|
||||
if got := test.fn(test.in); got != test.want {
|
||||
fmt.Printf("%s(%d) = %d, want %d\n", test.fnname, test.in, got, test.want)
|
||||
failed = true
|
||||
t.Errorf("%s(%d) = %d, want %d\n", test.fnname, test.in, got, test.want)
|
||||
}
|
||||
}
|
||||
for _, test := range tests_int32mul {
|
||||
if got := test.fn(test.in); got != test.want {
|
||||
fmt.Printf("%s(%d) = %d, want %d\n", test.fnname, test.in, got, test.want)
|
||||
failed = true
|
||||
t.Errorf("%s(%d) = %d, want %d\n", test.fnname, test.in, got, test.want)
|
||||
}
|
||||
}
|
||||
for _, test := range tests_uint16 {
|
||||
if got := test.fn(test.in); got != test.want {
|
||||
fmt.Printf("%s(%d) = %d, want %d\n", test.fnname, test.in, got, test.want)
|
||||
failed = true
|
||||
t.Errorf("%s(%d) = %d, want %d\n", test.fnname, test.in, got, test.want)
|
||||
}
|
||||
}
|
||||
for _, test := range tests_int16 {
|
||||
if got := test.fn(test.in); got != test.want {
|
||||
fmt.Printf("%s(%d) = %d, want %d\n", test.fnname, test.in, got, test.want)
|
||||
failed = true
|
||||
t.Errorf("%s(%d) = %d, want %d\n", test.fnname, test.in, got, test.want)
|
||||
}
|
||||
}
|
||||
for _, test := range tests_uint8 {
|
||||
if got := test.fn(test.in); got != test.want {
|
||||
fmt.Printf("%s(%d) = %d, want %d\n", test.fnname, test.in, got, test.want)
|
||||
failed = true
|
||||
t.Errorf("%s(%d) = %d, want %d\n", test.fnname, test.in, got, test.want)
|
||||
}
|
||||
}
|
||||
for _, test := range tests_int8 {
|
||||
if got := test.fn(test.in); got != test.want {
|
||||
fmt.Printf("%s(%d) = %d, want %d\n", test.fnname, test.in, got, test.want)
|
||||
failed = true
|
||||
t.Errorf("%s(%d) = %d, want %d\n", test.fnname, test.in, got, test.want)
|
||||
}
|
||||
}
|
||||
|
||||
if failed {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
@ -1,12 +1,11 @@
|
||||
// run
|
||||
// Code generated by gen/cmpConstGen.go. DO NOT EDIT.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// results show the expected result for the elements left of, equal to and right of the index.
|
||||
@ -2093,7 +2092,8 @@ var int8_tests = []struct {
|
||||
{idx: 6, exp: ne, fn: ne_127_int8},
|
||||
}
|
||||
|
||||
func main() {
|
||||
// TestComparisonsConst tests results for comparison operations against constants.
|
||||
func TestComparisonsConst(t *testing.T) {
|
||||
for i, test := range uint64_tests {
|
||||
for j, x := range uint64_vals {
|
||||
want := test.exp.l
|
||||
@ -2104,8 +2104,7 @@ func main() {
|
||||
}
|
||||
if test.fn(x) != want {
|
||||
fn := runtime.FuncForPC(reflect.ValueOf(test.fn).Pointer()).Name()
|
||||
msg := fmt.Sprintf("test failed: %v(%v) != %v [type=uint64 i=%v j=%v idx=%v]", fn, x, want, i, j, test.idx)
|
||||
panic(msg)
|
||||
t.Errorf("test failed: %v(%v) != %v [type=uint64 i=%v j=%v idx=%v]", fn, x, want, i, j, test.idx)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2119,8 +2118,7 @@ func main() {
|
||||
}
|
||||
if test.fn(x) != want {
|
||||
fn := runtime.FuncForPC(reflect.ValueOf(test.fn).Pointer()).Name()
|
||||
msg := fmt.Sprintf("test failed: %v(%v) != %v [type=uint32 i=%v j=%v idx=%v]", fn, x, want, i, j, test.idx)
|
||||
panic(msg)
|
||||
t.Errorf("test failed: %v(%v) != %v [type=uint32 i=%v j=%v idx=%v]", fn, x, want, i, j, test.idx)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2134,8 +2132,7 @@ func main() {
|
||||
}
|
||||
if test.fn(x) != want {
|
||||
fn := runtime.FuncForPC(reflect.ValueOf(test.fn).Pointer()).Name()
|
||||
msg := fmt.Sprintf("test failed: %v(%v) != %v [type=uint16 i=%v j=%v idx=%v]", fn, x, want, i, j, test.idx)
|
||||
panic(msg)
|
||||
t.Errorf("test failed: %v(%v) != %v [type=uint16 i=%v j=%v idx=%v]", fn, x, want, i, j, test.idx)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2149,8 +2146,7 @@ func main() {
|
||||
}
|
||||
if test.fn(x) != want {
|
||||
fn := runtime.FuncForPC(reflect.ValueOf(test.fn).Pointer()).Name()
|
||||
msg := fmt.Sprintf("test failed: %v(%v) != %v [type=uint8 i=%v j=%v idx=%v]", fn, x, want, i, j, test.idx)
|
||||
panic(msg)
|
||||
t.Errorf("test failed: %v(%v) != %v [type=uint8 i=%v j=%v idx=%v]", fn, x, want, i, j, test.idx)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2164,8 +2160,7 @@ func main() {
|
||||
}
|
||||
if test.fn(x) != want {
|
||||
fn := runtime.FuncForPC(reflect.ValueOf(test.fn).Pointer()).Name()
|
||||
msg := fmt.Sprintf("test failed: %v(%v) != %v [type=int64 i=%v j=%v idx=%v]", fn, x, want, i, j, test.idx)
|
||||
panic(msg)
|
||||
t.Errorf("test failed: %v(%v) != %v [type=int64 i=%v j=%v idx=%v]", fn, x, want, i, j, test.idx)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2179,8 +2174,7 @@ func main() {
|
||||
}
|
||||
if test.fn(x) != want {
|
||||
fn := runtime.FuncForPC(reflect.ValueOf(test.fn).Pointer()).Name()
|
||||
msg := fmt.Sprintf("test failed: %v(%v) != %v [type=int32 i=%v j=%v idx=%v]", fn, x, want, i, j, test.idx)
|
||||
panic(msg)
|
||||
t.Errorf("test failed: %v(%v) != %v [type=int32 i=%v j=%v idx=%v]", fn, x, want, i, j, test.idx)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2194,8 +2188,7 @@ func main() {
|
||||
}
|
||||
if test.fn(x) != want {
|
||||
fn := runtime.FuncForPC(reflect.ValueOf(test.fn).Pointer()).Name()
|
||||
msg := fmt.Sprintf("test failed: %v(%v) != %v [type=int16 i=%v j=%v idx=%v]", fn, x, want, i, j, test.idx)
|
||||
panic(msg)
|
||||
t.Errorf("test failed: %v(%v) != %v [type=int16 i=%v j=%v idx=%v]", fn, x, want, i, j, test.idx)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2209,8 +2202,7 @@ func main() {
|
||||
}
|
||||
if test.fn(x) != want {
|
||||
fn := runtime.FuncForPC(reflect.ValueOf(test.fn).Pointer()).Name()
|
||||
msg := fmt.Sprintf("test failed: %v(%v) != %v [type=int8 i=%v j=%v idx=%v]", fn, x, want, i, j, test.idx)
|
||||
panic(msg)
|
||||
t.Errorf("test failed: %v(%v) != %v [type=int8 i=%v j=%v idx=%v]", fn, x, want, i, j, test.idx)
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because one or more lines are too long
@ -91,10 +91,9 @@ var ops = []op{op{"add", "+"}, op{"sub", "-"}, op{"div", "/"}, op{"mod", "%%"},
|
||||
|
||||
func main() {
|
||||
w := new(bytes.Buffer)
|
||||
fmt.Fprintf(w, "// run\n")
|
||||
fmt.Fprintf(w, "// Code generated by gen/arithBoundaryGen.go. DO NOT EDIT.\n\n")
|
||||
fmt.Fprintf(w, "package main;\n")
|
||||
fmt.Fprintf(w, "import \"fmt\"\n")
|
||||
fmt.Fprintf(w, "import \"testing\"\n")
|
||||
|
||||
for _, sz := range []int{64, 32, 16, 8} {
|
||||
fmt.Fprintf(w, "type utd%d struct {\n", sz)
|
||||
@ -160,13 +159,12 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Fprintf(w, "var failed bool\n\n")
|
||||
fmt.Fprintf(w, "func main() {\n\n")
|
||||
fmt.Fprintf(w, "//TestArithmeticBoundary tests boundary results for arithmetic operations.\n")
|
||||
fmt.Fprintf(w, "func TestArithmeticBoundary(t *testing.T) {\n\n")
|
||||
|
||||
verify, err := template.New("tst").Parse(
|
||||
`if got := {{.Name}}_{{.Stype}}_ssa(v.a, v.b); got != v.{{.Name}} {
|
||||
fmt.Printf("{{.Name}}_{{.Stype}} %d{{.Symbol}}%d = %d, wanted %d\n",v.a,v.b,got,v.{{.Name}})
|
||||
failed = true
|
||||
t.Errorf("{{.Name}}_{{.Stype}} %d{{.Symbol}}%d = %d, wanted %d\n",v.a,v.b,got,v.{{.Name}})
|
||||
}
|
||||
`)
|
||||
|
||||
@ -193,10 +191,6 @@ func main() {
|
||||
fmt.Fprint(w, " }\n")
|
||||
}
|
||||
|
||||
fmt.Fprintf(w, `if failed {
|
||||
panic("tests failed")
|
||||
}
|
||||
`)
|
||||
fmt.Fprintf(w, "}\n")
|
||||
|
||||
// gofmt result
|
||||
@ -208,7 +202,7 @@ func main() {
|
||||
}
|
||||
|
||||
// write to file
|
||||
err = ioutil.WriteFile("../arithBoundary.go", src, 0666)
|
||||
err = ioutil.WriteFile("../arithBoundary_test.go", src, 0666)
|
||||
if err != nil {
|
||||
log.Fatalf("can't write output: %v\n", err)
|
||||
}
|
||||
|
@ -148,11 +148,9 @@ func ansS(i, j int64, t, op string) string {
|
||||
|
||||
func main() {
|
||||
w := new(bytes.Buffer)
|
||||
fmt.Fprintf(w, "// run\n")
|
||||
fmt.Fprintf(w, "// Code generated by gen/arithConstGen.go. DO NOT EDIT.\n\n")
|
||||
fmt.Fprintf(w, "package main;\n")
|
||||
fmt.Fprintf(w, "import \"fmt\"\n")
|
||||
fmt.Fprintf(w, "import \"os\"\n")
|
||||
fmt.Fprintf(w, "import \"testing\"\n")
|
||||
|
||||
fncCnst1 := template.Must(template.New("fnc").Parse(
|
||||
`//go:noinline
|
||||
@ -313,26 +311,22 @@ type test_%[1]s%[2]s struct {
|
||||
}
|
||||
|
||||
fmt.Fprint(w, `
|
||||
var failed bool
|
||||
|
||||
func main() {
|
||||
// TestArithmeticConst tests results for arithmetic operations against constants.
|
||||
func TestArithmeticConst(t *testing.T) {
|
||||
`)
|
||||
|
||||
for _, s := range szs {
|
||||
fmt.Fprintf(w, `for _, test := range tests_%s%s {`, s.name, s.oponly)
|
||||
// Use WriteString here to avoid a vet warning about formatting directives.
|
||||
w.WriteString(`if got := test.fn(test.in); got != test.want {
|
||||
fmt.Printf("%s(%d) = %d, want %d\n", test.fnname, test.in, got, test.want)
|
||||
failed = true
|
||||
t.Errorf("%s(%d) = %d, want %d\n", test.fnname, test.in, got, test.want)
|
||||
}
|
||||
}
|
||||
`)
|
||||
}
|
||||
|
||||
fmt.Fprint(w, `
|
||||
if failed {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
`)
|
||||
|
||||
@ -345,7 +339,7 @@ func main() {
|
||||
}
|
||||
|
||||
// write to file
|
||||
err = ioutil.WriteFile("../arithConst.go", src, 0666)
|
||||
err = ioutil.WriteFile("../arithConst_test.go", src, 0666)
|
||||
if err != nil {
|
||||
log.Fatalf("can't write output: %v\n", err)
|
||||
}
|
||||
|
@ -153,10 +153,9 @@ func main() {
|
||||
}
|
||||
|
||||
w := new(bytes.Buffer)
|
||||
fmt.Fprintf(w, "// run\n")
|
||||
fmt.Fprintf(w, "// Code generated by gen/cmpConstGen.go. DO NOT EDIT.\n\n")
|
||||
fmt.Fprintf(w, "package main;\n")
|
||||
fmt.Fprintf(w, "import (\"fmt\"; \"reflect\"; \"runtime\";)\n")
|
||||
fmt.Fprintf(w, "import (\"testing\"; \"reflect\"; \"runtime\";)\n")
|
||||
fmt.Fprintf(w, "// results show the expected result for the elements left of, equal to and right of the index.\n")
|
||||
fmt.Fprintf(w, "type result struct{l, e, r bool}\n")
|
||||
fmt.Fprintf(w, "var (\n")
|
||||
@ -215,7 +214,8 @@ func main() {
|
||||
}
|
||||
|
||||
// emit the main function, looping over all test cases
|
||||
fmt.Fprintf(w, "func main() {\n")
|
||||
fmt.Fprintf(w, "// TestComparisonsConst tests results for comparison operations against constants.\n")
|
||||
fmt.Fprintf(w, "func TestComparisonsConst(t *testing.T) {\n")
|
||||
for _, typ := range types {
|
||||
fmt.Fprintf(w, "for i, test := range %v_tests {\n", typ)
|
||||
fmt.Fprintf(w, " for j, x := range %v_vals {\n", typ)
|
||||
@ -224,8 +224,7 @@ func main() {
|
||||
fmt.Fprintf(w, " else if j > test.idx {\nwant = test.exp.r\n}\n")
|
||||
fmt.Fprintf(w, " if test.fn(x) != want {\n")
|
||||
fmt.Fprintf(w, " fn := runtime.FuncForPC(reflect.ValueOf(test.fn).Pointer()).Name()\n")
|
||||
fmt.Fprintf(w, " msg := fmt.Sprintf(\"test failed: %%v(%%v) != %%v [type=%v i=%%v j=%%v idx=%%v]\", fn, x, want, i, j, test.idx)\n", typ)
|
||||
fmt.Fprintf(w, " panic(msg)\n")
|
||||
fmt.Fprintf(w, " t.Errorf(\"test failed: %%v(%%v) != %%v [type=%v i=%%v j=%%v idx=%%v]\", fn, x, want, i, j, test.idx)\n", typ)
|
||||
fmt.Fprintf(w, " }\n")
|
||||
fmt.Fprintf(w, " }\n")
|
||||
fmt.Fprintf(w, "}\n")
|
||||
@ -241,7 +240,7 @@ func main() {
|
||||
}
|
||||
|
||||
// write to file
|
||||
err = ioutil.WriteFile("../cmpConst.go", src, 0666)
|
||||
err = ioutil.WriteFile("../cmpConst_test.go", src, 0666)
|
||||
if err != nil {
|
||||
log.Fatalf("can't write output: %v\n", err)
|
||||
}
|
||||
|
@ -24,10 +24,9 @@ var usizes = [...]int{2, 3, 4, 5, 6, 7}
|
||||
|
||||
func main() {
|
||||
w := new(bytes.Buffer)
|
||||
fmt.Fprintf(w, "// run\n")
|
||||
fmt.Fprintf(w, "// Code generated by gen/copyGen.go. DO NOT EDIT.\n\n")
|
||||
fmt.Fprintf(w, "package main\n")
|
||||
fmt.Fprintf(w, "import \"fmt\"\n")
|
||||
fmt.Fprintf(w, "import \"testing\"\n")
|
||||
|
||||
for _, s := range sizes {
|
||||
// type for test
|
||||
@ -44,7 +43,7 @@ func main() {
|
||||
fmt.Fprintf(w, "}\n")
|
||||
|
||||
// testing harness
|
||||
fmt.Fprintf(w, "func testCopy%d() {\n", s)
|
||||
fmt.Fprintf(w, "func testCopy%d(t *testing.T) {\n", s)
|
||||
fmt.Fprintf(w, " a := T%d{[8]byte{201, 202, 203, 204, 205, 206, 207, 208},[%d]byte{", s, s)
|
||||
for i := 0; i < s; i++ {
|
||||
fmt.Fprintf(w, "%d,", i%100)
|
||||
@ -62,8 +61,7 @@ func main() {
|
||||
}
|
||||
fmt.Fprintf(w, "},[8]byte{211, 212, 213, 214, 215, 216, 217, 218}}\n")
|
||||
fmt.Fprintf(w, " if a != want {\n")
|
||||
fmt.Fprintf(w, " fmt.Printf(\"t%dcopy got=%%v, want %%v\\n\", a, want)\n", s)
|
||||
fmt.Fprintf(w, " failed=true\n")
|
||||
fmt.Fprintf(w, " t.Errorf(\"t%dcopy got=%%v, want %%v\\n\", a, want)\n", s)
|
||||
fmt.Fprintf(w, " }\n")
|
||||
fmt.Fprintf(w, "}\n")
|
||||
}
|
||||
@ -78,7 +76,7 @@ func main() {
|
||||
fmt.Fprintf(w, "}\n")
|
||||
|
||||
// testing harness
|
||||
fmt.Fprintf(w, "func testUnalignedCopy%d() {\n", s)
|
||||
fmt.Fprintf(w, "func testUnalignedCopy%d(t *testing.T) {\n", s)
|
||||
fmt.Fprintf(w, " var a [%d]byte\n", s)
|
||||
fmt.Fprintf(w, " t%d := [%d]byte{", s, s)
|
||||
for i := 0; i < s; i++ {
|
||||
@ -92,24 +90,19 @@ func main() {
|
||||
}
|
||||
fmt.Fprintf(w, "}\n")
|
||||
fmt.Fprintf(w, " if a != want%d {\n", s)
|
||||
fmt.Fprintf(w, " fmt.Printf(\"tu%dcopy got=%%v, want %%v\\n\", a, want%d)\n", s, s)
|
||||
fmt.Fprintf(w, " failed=true\n")
|
||||
fmt.Fprintf(w, " t.Errorf(\"tu%dcopy got=%%v, want %%v\\n\", a, want%d)\n", s, s)
|
||||
fmt.Fprintf(w, " }\n")
|
||||
fmt.Fprintf(w, "}\n")
|
||||
}
|
||||
|
||||
// boilerplate at end
|
||||
fmt.Fprintf(w, "var failed bool\n")
|
||||
fmt.Fprintf(w, "func main() {\n")
|
||||
fmt.Fprintf(w, "func TestCopy(t *testing.T) {\n")
|
||||
for _, s := range sizes {
|
||||
fmt.Fprintf(w, " testCopy%d()\n", s)
|
||||
fmt.Fprintf(w, " testCopy%d(t)\n", s)
|
||||
}
|
||||
for _, s := range usizes {
|
||||
fmt.Fprintf(w, " testUnalignedCopy%d()\n", s)
|
||||
fmt.Fprintf(w, " testUnalignedCopy%d(t)\n", s)
|
||||
}
|
||||
fmt.Fprintf(w, " if failed {\n")
|
||||
fmt.Fprintf(w, " panic(\"failed\")\n")
|
||||
fmt.Fprintf(w, " }\n")
|
||||
fmt.Fprintf(w, "}\n")
|
||||
|
||||
// gofmt result
|
||||
@ -121,7 +114,7 @@ func main() {
|
||||
}
|
||||
|
||||
// write to file
|
||||
err = ioutil.WriteFile("../copy.go", src, 0666)
|
||||
err = ioutil.WriteFile("../copy_test.go", src, 0666)
|
||||
if err != nil {
|
||||
log.Fatalf("can't write output: %v\n", err)
|
||||
}
|
||||
|
@ -23,14 +23,13 @@ var usizes = [...]int{8, 16, 24, 32, 64, 256}
|
||||
|
||||
func main() {
|
||||
w := new(bytes.Buffer)
|
||||
fmt.Fprintf(w, "// run\n")
|
||||
fmt.Fprintf(w, "// Code generated by gen/zeroGen.go. DO NOT EDIT.\n\n")
|
||||
fmt.Fprintf(w, "package main\n")
|
||||
fmt.Fprintf(w, "import \"fmt\"\n")
|
||||
fmt.Fprintf(w, "import \"testing\"\n")
|
||||
|
||||
for _, s := range sizes {
|
||||
// type for test
|
||||
fmt.Fprintf(w, "type T%d struct {\n", s)
|
||||
fmt.Fprintf(w, "type Z%d struct {\n", s)
|
||||
fmt.Fprintf(w, " pre [8]byte\n")
|
||||
fmt.Fprintf(w, " mid [%d]byte\n", s)
|
||||
fmt.Fprintf(w, " post [8]byte\n")
|
||||
@ -43,96 +42,89 @@ func main() {
|
||||
fmt.Fprintf(w, "}\n")
|
||||
|
||||
// testing harness
|
||||
fmt.Fprintf(w, "func testZero%d() {\n", s)
|
||||
fmt.Fprintf(w, " a := T%d{[8]byte{255,255,255,255,255,255,255,255},[%d]byte{", s, s)
|
||||
fmt.Fprintf(w, "func testZero%d(t *testing.T) {\n", s)
|
||||
fmt.Fprintf(w, " a := Z%d{[8]byte{255,255,255,255,255,255,255,255},[%d]byte{", s, s)
|
||||
for i := 0; i < s; i++ {
|
||||
fmt.Fprintf(w, "255,")
|
||||
}
|
||||
fmt.Fprintf(w, "},[8]byte{255,255,255,255,255,255,255,255}}\n")
|
||||
fmt.Fprintf(w, " zero%d_ssa(&a.mid)\n", s)
|
||||
fmt.Fprintf(w, " want := T%d{[8]byte{255,255,255,255,255,255,255,255},[%d]byte{", s, s)
|
||||
fmt.Fprintf(w, " want := Z%d{[8]byte{255,255,255,255,255,255,255,255},[%d]byte{", s, s)
|
||||
for i := 0; i < s; i++ {
|
||||
fmt.Fprintf(w, "0,")
|
||||
}
|
||||
fmt.Fprintf(w, "},[8]byte{255,255,255,255,255,255,255,255}}\n")
|
||||
fmt.Fprintf(w, " if a != want {\n")
|
||||
fmt.Fprintf(w, " fmt.Printf(\"zero%d got=%%v, want %%v\\n\", a, want)\n", s)
|
||||
fmt.Fprintf(w, " failed=true\n")
|
||||
fmt.Fprintf(w, " t.Errorf(\"zero%d got=%%v, want %%v\\n\", a, want)\n", s)
|
||||
fmt.Fprintf(w, " }\n")
|
||||
fmt.Fprintf(w, "}\n")
|
||||
}
|
||||
|
||||
for _, s := range usizes {
|
||||
// type for test
|
||||
fmt.Fprintf(w, "type T%du1 struct {\n", s)
|
||||
fmt.Fprintf(w, "type Z%du1 struct {\n", s)
|
||||
fmt.Fprintf(w, " b bool\n")
|
||||
fmt.Fprintf(w, " val [%d]byte\n", s)
|
||||
fmt.Fprintf(w, "}\n")
|
||||
|
||||
fmt.Fprintf(w, "type T%du2 struct {\n", s)
|
||||
fmt.Fprintf(w, "type Z%du2 struct {\n", s)
|
||||
fmt.Fprintf(w, " i uint16\n")
|
||||
fmt.Fprintf(w, " val [%d]byte\n", s)
|
||||
fmt.Fprintf(w, "}\n")
|
||||
|
||||
// function being tested
|
||||
fmt.Fprintf(w, "//go:noinline\n")
|
||||
fmt.Fprintf(w, "func zero%du1_ssa(t *T%du1) {\n", s, s)
|
||||
fmt.Fprintf(w, "func zero%du1_ssa(t *Z%du1) {\n", s, s)
|
||||
fmt.Fprintf(w, " t.val = [%d]byte{}\n", s)
|
||||
fmt.Fprintf(w, "}\n")
|
||||
|
||||
// function being tested
|
||||
fmt.Fprintf(w, "//go:noinline\n")
|
||||
fmt.Fprintf(w, "func zero%du2_ssa(t *T%du2) {\n", s, s)
|
||||
fmt.Fprintf(w, "func zero%du2_ssa(t *Z%du2) {\n", s, s)
|
||||
fmt.Fprintf(w, " t.val = [%d]byte{}\n", s)
|
||||
fmt.Fprintf(w, "}\n")
|
||||
|
||||
// testing harness
|
||||
fmt.Fprintf(w, "func testZero%du() {\n", s)
|
||||
fmt.Fprintf(w, " a := T%du1{false, [%d]byte{", s, s)
|
||||
fmt.Fprintf(w, "func testZero%du(t *testing.T) {\n", s)
|
||||
fmt.Fprintf(w, " a := Z%du1{false, [%d]byte{", s, s)
|
||||
for i := 0; i < s; i++ {
|
||||
fmt.Fprintf(w, "255,")
|
||||
}
|
||||
fmt.Fprintf(w, "}}\n")
|
||||
fmt.Fprintf(w, " zero%du1_ssa(&a)\n", s)
|
||||
fmt.Fprintf(w, " want := T%du1{false, [%d]byte{", s, s)
|
||||
fmt.Fprintf(w, " want := Z%du1{false, [%d]byte{", s, s)
|
||||
for i := 0; i < s; i++ {
|
||||
fmt.Fprintf(w, "0,")
|
||||
}
|
||||
fmt.Fprintf(w, "}}\n")
|
||||
fmt.Fprintf(w, " if a != want {\n")
|
||||
fmt.Fprintf(w, " fmt.Printf(\"zero%du2 got=%%v, want %%v\\n\", a, want)\n", s)
|
||||
fmt.Fprintf(w, " failed=true\n")
|
||||
fmt.Fprintf(w, " t.Errorf(\"zero%du2 got=%%v, want %%v\\n\", a, want)\n", s)
|
||||
fmt.Fprintf(w, " }\n")
|
||||
fmt.Fprintf(w, " b := T%du2{15, [%d]byte{", s, s)
|
||||
fmt.Fprintf(w, " b := Z%du2{15, [%d]byte{", s, s)
|
||||
for i := 0; i < s; i++ {
|
||||
fmt.Fprintf(w, "255,")
|
||||
}
|
||||
fmt.Fprintf(w, "}}\n")
|
||||
fmt.Fprintf(w, " zero%du2_ssa(&b)\n", s)
|
||||
fmt.Fprintf(w, " wantb := T%du2{15, [%d]byte{", s, s)
|
||||
fmt.Fprintf(w, " wantb := Z%du2{15, [%d]byte{", s, s)
|
||||
for i := 0; i < s; i++ {
|
||||
fmt.Fprintf(w, "0,")
|
||||
}
|
||||
fmt.Fprintf(w, "}}\n")
|
||||
fmt.Fprintf(w, " if b != wantb {\n")
|
||||
fmt.Fprintf(w, " fmt.Printf(\"zero%du2 got=%%v, want %%v\\n\", b, wantb)\n", s)
|
||||
fmt.Fprintf(w, " failed=true\n")
|
||||
fmt.Fprintf(w, " t.Errorf(\"zero%du2 got=%%v, want %%v\\n\", b, wantb)\n", s)
|
||||
fmt.Fprintf(w, " }\n")
|
||||
fmt.Fprintf(w, "}\n")
|
||||
}
|
||||
|
||||
// boilerplate at end
|
||||
fmt.Fprintf(w, "var failed bool\n")
|
||||
fmt.Fprintf(w, "func main() {\n")
|
||||
fmt.Fprintf(w, "func TestZero(t *testing.T) {\n")
|
||||
for _, s := range sizes {
|
||||
fmt.Fprintf(w, " testZero%d()\n", s)
|
||||
fmt.Fprintf(w, " testZero%d(t)\n", s)
|
||||
}
|
||||
for _, s := range usizes {
|
||||
fmt.Fprintf(w, " testZero%du()\n", s)
|
||||
fmt.Fprintf(w, " testZero%du(t)\n", s)
|
||||
}
|
||||
fmt.Fprintf(w, " if failed {\n")
|
||||
fmt.Fprintf(w, " panic(\"failed\")\n")
|
||||
fmt.Fprintf(w, " }\n")
|
||||
fmt.Fprintf(w, "}\n")
|
||||
|
||||
// gofmt result
|
||||
@ -144,7 +136,7 @@ func main() {
|
||||
}
|
||||
|
||||
// write to file
|
||||
err = ioutil.WriteFile("../zero.go", src, 0666)
|
||||
err = ioutil.WriteFile("../zero_test.go", src, 0666)
|
||||
if err != nil {
|
||||
log.Fatalf("can't write output: %v\n", err)
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user