597
const binaryConstR0 = "func test%vBinaryR%v(a, add, sub, mul, div, mod, and, or, xor, andnot %v, dodiv bool) {\n" +
598
" const b %v = %v;\n" +
599
" const typ = `%s`;\n" +
600
" if n, op, want := a + b, `+`, add; n != want { ok=false; println(typ, `var`, a, op, `const`, b, `=`, n, `should be`, want); }\n" +
601
" if n, op, want := a - b, `-`, sub; n != want { ok=false; println(typ, `var`, a, op, `const`, b, `=`, n, `should be`, want); }\n" +
602
" if n, op, want := a * b, `*`, mul; n != want { ok=false; println(typ, `var`, a, op, `const`, b, `=`, n, `should be`, want); }\n" +
603
" if n, op, want := a & b, `&`, and; n != want { ok=false; println(typ, `var`, a, op, `const`, b, `=`, n, `should be`, want); }\n" +
604
" if n, op, want := a | b, `|`, or; n != want { ok=false; println(typ, `var`, a, op, `const`, b, `=`, n, `should be`, want); }\n" +
605
" if n, op, want := a ^ b, `^`, xor; n != want { ok=false; println(typ, `var`, a, op, `const`, b, `=`, n, `should be`, want); }\n" +
606
" if n, op, want := a &^ b, `&^`, andnot; n != want { ok=false; println(typ, `var`, a, op, `const`, b, `=`, n, `should be`, want); }\n" +
599
610
const shiftConstL = "func test%vShiftL%v(b uint64, left, right %v) {\n" +
600
611
" const a %v = %v;\n" +
601
612
" const typ = `%s`;\n" +
623
634
func constTests() {
624
635
for i, a := range int64Values {
625
636
fmt.Fprintf(bout, binaryConstL, "Int64", i, "int64", "int64", a, "int64")
626
fmt.Fprintf(bout, binaryConstR, "Int64", i, "int64", "int64", a, "int64")
637
if a.hi == 0 && a.lo == 0 {
638
fmt.Fprintf(bout, binaryConstR0, "Int64", i, "int64", "int64", a, "int64")
640
fmt.Fprintf(bout, binaryConstR, "Int64", i, "int64", "int64", a, "int64")
627
642
fmt.Fprintf(bout, shiftConstL, "Int64", i, "int64", "int64", a, "int64")
629
644
for i, a := range uint64Values {
630
645
fmt.Fprintf(bout, binaryConstL, "Uint64", i, "uint64", "uint64", a, "uint64")
631
fmt.Fprintf(bout, binaryConstR, "Uint64", i, "uint64", "uint64", a, "uint64")
646
if a.hi == 0 && a.lo == 0 {
647
fmt.Fprintf(bout, binaryConstR0, "Uint64", i, "uint64", "uint64", a, "uint64")
649
fmt.Fprintf(bout, binaryConstR, "Uint64", i, "uint64", "uint64", a, "uint64")
632
651
fmt.Fprintf(bout, shiftConstL, "Uint64", i, "uint64", "uint64", a, "uint64")
634
653
for i, a := range shiftValues {