mirror of
https://github.com/golang/go
synced 2024-11-25 04:57:56 -07:00
- gofmt these files
- remove use of implicit string concatenation - these appear to be the only files correctly compiling under test that used implicit string concatenation R=rsc https://golang.org/cl/172043
This commit is contained in:
parent
2e4334eb3a
commit
5f5dcfbc15
397
test/64bit.go
397
test/64bit.go
@ -20,7 +20,7 @@ import (
|
|||||||
"os";
|
"os";
|
||||||
)
|
)
|
||||||
|
|
||||||
var bout *bufio.Writer;
|
var bout *bufio.Writer
|
||||||
|
|
||||||
// 64-bit math without using 64-bit numbers,
|
// 64-bit math without using 64-bit numbers,
|
||||||
// so that we can generate the test program even
|
// so that we can generate the test program even
|
||||||
@ -45,13 +45,13 @@ func (a Uint64) Int64() (c Int64) {
|
|||||||
func (a Uint64) Cmp(b Uint64) int {
|
func (a Uint64) Cmp(b Uint64) int {
|
||||||
switch {
|
switch {
|
||||||
case a.hi < b.hi:
|
case a.hi < b.hi:
|
||||||
return -1;
|
return -1
|
||||||
case a.hi > b.hi:
|
case a.hi > b.hi:
|
||||||
return 1;
|
return 1
|
||||||
case a.lo < b.lo:
|
case a.lo < b.lo:
|
||||||
return -1;
|
return -1
|
||||||
case a.lo > b.lo:
|
case a.lo > b.lo:
|
||||||
return 1;
|
return 1
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -88,14 +88,14 @@ func (a Uint64) RightShift(b uint) (c Uint64) {
|
|||||||
|
|
||||||
func (a Uint64) LeftShift64(b Uint64) (c Uint64) {
|
func (a Uint64) LeftShift64(b Uint64) (c Uint64) {
|
||||||
if b.hi != 0 || b.lo >= 64 {
|
if b.hi != 0 || b.lo >= 64 {
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
return a.LeftShift(uint(b.lo));
|
return a.LeftShift(uint(b.lo));
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Uint64) RightShift64(b Uint64) (c Uint64) {
|
func (a Uint64) RightShift64(b Uint64) (c Uint64) {
|
||||||
if b.hi != 0 || b.lo >= 64 {
|
if b.hi != 0 || b.lo >= 64 {
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
return a.RightShift(uint(b.lo));
|
return a.RightShift(uint(b.lo));
|
||||||
}
|
}
|
||||||
@ -103,7 +103,7 @@ func (a Uint64) RightShift64(b Uint64) (c Uint64) {
|
|||||||
func (a Uint64) Plus(b Uint64) (c Uint64) {
|
func (a Uint64) Plus(b Uint64) (c Uint64) {
|
||||||
var carry uint32;
|
var carry uint32;
|
||||||
if c.lo = a.lo + b.lo; c.lo < a.lo {
|
if c.lo = a.lo + b.lo; c.lo < a.lo {
|
||||||
carry = 1;
|
carry = 1
|
||||||
}
|
}
|
||||||
c.hi = a.hi + b.hi + carry;
|
c.hi = a.hi + b.hi + carry;
|
||||||
return;
|
return;
|
||||||
@ -112,7 +112,7 @@ func (a Uint64) Plus(b Uint64) (c Uint64) {
|
|||||||
func (a Uint64) Minus(b Uint64) (c Uint64) {
|
func (a Uint64) Minus(b Uint64) (c Uint64) {
|
||||||
var borrow uint32;
|
var borrow uint32;
|
||||||
if c.lo = a.lo - b.lo; c.lo > a.lo {
|
if c.lo = a.lo - b.lo; c.lo > a.lo {
|
||||||
borrow = 1;
|
borrow = 1
|
||||||
}
|
}
|
||||||
c.hi = a.hi - b.hi - borrow;
|
c.hi = a.hi - b.hi - borrow;
|
||||||
return;
|
return;
|
||||||
@ -134,13 +134,13 @@ func (a Uint64) Len() int {
|
|||||||
case a.hi != 0:
|
case a.hi != 0:
|
||||||
for i := 31; i >= 0; i-- {
|
for i := 31; i >= 0; i-- {
|
||||||
if a.hi&(1<<uint(i)) != 0 {
|
if a.hi&(1<<uint(i)) != 0 {
|
||||||
return i + 1 + 32;
|
return i + 1 + 32
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case a.lo != 0:
|
case a.lo != 0:
|
||||||
for i := 31; i >= 0; i-- {
|
for i := 31; i >= 0; i-- {
|
||||||
if a.lo&(1<<uint(i)) != 0 {
|
if a.lo&(1<<uint(i)) != 0 {
|
||||||
return i + 1;
|
return i + 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -150,17 +150,17 @@ func (a Uint64) Len() int {
|
|||||||
func (a Uint64) HasBit(b uint) bool {
|
func (a Uint64) HasBit(b uint) bool {
|
||||||
switch {
|
switch {
|
||||||
case b >= 64:
|
case b >= 64:
|
||||||
return false;
|
return false
|
||||||
case b >= 32:
|
case b >= 32:
|
||||||
return a.hi & (1<<(b-32)) != 0;
|
return a.hi&(1<<(b-32)) != 0
|
||||||
}
|
}
|
||||||
return a.lo&(1<<b) != 0;
|
return a.lo&(1<<b) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Uint64) Times(b Uint64) (c Uint64) {
|
func (a Uint64) Times(b Uint64) (c Uint64) {
|
||||||
for i := uint(0); i < 64; i++ {
|
for i := uint(0); i < 64; i++ {
|
||||||
if(b.HasBit(i)) {
|
if b.HasBit(i) {
|
||||||
c = c.Plus(a.LeftShift(i));
|
c = c.Plus(a.LeftShift(i))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -207,9 +207,7 @@ func (a Uint64) Xor(b Uint64) (c Uint64) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Uint64) String() string {
|
func (a Uint64) String() string { return fmt.Sprintf("%#x%08x", a.hi, a.lo) }
|
||||||
return fmt.Sprintf("%#x%08x", a.hi, a.lo);
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a Int64) Uint64() (c Uint64) {
|
func (a Int64) Uint64() (c Uint64) {
|
||||||
c.hi = uint32(a.hi);
|
c.hi = uint32(a.hi);
|
||||||
@ -223,20 +221,18 @@ func (a Int64) Cmp(b Int64) int {
|
|||||||
// because hi is uint32 not int32.
|
// because hi is uint32 not int32.
|
||||||
switch {
|
switch {
|
||||||
case a.hi < b.hi:
|
case a.hi < b.hi:
|
||||||
return -1;
|
return -1
|
||||||
case a.hi > b.hi:
|
case a.hi > b.hi:
|
||||||
return 1;
|
return 1
|
||||||
case a.lo < b.lo:
|
case a.lo < b.lo:
|
||||||
return -1;
|
return -1
|
||||||
case a.lo > b.lo:
|
case a.lo > b.lo:
|
||||||
return 1;
|
return 1
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Int64) LeftShift(b uint) (c Int64) {
|
func (a Int64) LeftShift(b uint) (c Int64) { return a.Uint64().LeftShift(b).Int64() }
|
||||||
return a.Uint64().LeftShift(b).Int64();
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a Int64) RightShift(b uint) (c Int64) {
|
func (a Int64) RightShift(b uint) (c Int64) {
|
||||||
switch {
|
switch {
|
||||||
@ -255,37 +251,27 @@ func (a Int64) RightShift(b uint) (c Int64) {
|
|||||||
|
|
||||||
func (a Int64) LeftShift64(b Uint64) (c Int64) {
|
func (a Int64) LeftShift64(b Uint64) (c Int64) {
|
||||||
if b.hi != 0 || b.lo >= 64 {
|
if b.hi != 0 || b.lo >= 64 {
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
return a.LeftShift(uint(b.lo));
|
return a.LeftShift(uint(b.lo));
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Int64) RightShift64(b Uint64) (c Int64) {
|
func (a Int64) RightShift64(b Uint64) (c Int64) {
|
||||||
if b.hi != 0 || b.lo >= 64 {
|
if b.hi != 0 || b.lo >= 64 {
|
||||||
return a.RightShift(64);
|
return a.RightShift(64)
|
||||||
}
|
}
|
||||||
return a.RightShift(uint(b.lo));
|
return a.RightShift(uint(b.lo));
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Int64) Plus(b Int64) (c Int64) {
|
func (a Int64) Plus(b Int64) (c Int64) { return a.Uint64().Plus(b.Uint64()).Int64() }
|
||||||
return a.Uint64().Plus(b.Uint64()).Int64();
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a Int64) Minus(b Int64) (c Int64) {
|
func (a Int64) Minus(b Int64) (c Int64) { return a.Uint64().Minus(b.Uint64()).Int64() }
|
||||||
return a.Uint64().Minus(b.Uint64()).Int64();
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a Int64) Neg() (c Int64) {
|
func (a Int64) Neg() (c Int64) { return a.Uint64().Neg().Int64() }
|
||||||
return a.Uint64().Neg().Int64();
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a Int64) Com() (c Int64) {
|
func (a Int64) Com() (c Int64) { return a.Uint64().Com().Int64() }
|
||||||
return a.Uint64().Com().Int64();
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a Int64) Times(b Int64) (c Int64) {
|
func (a Int64) Times(b Int64) (c Int64) { return a.Uint64().Times(b.Uint64()).Int64() }
|
||||||
return a.Uint64().Times(b.Uint64()).Int64();
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a Int64) DivMod(b Int64) (quo Int64, rem Int64) {
|
func (a Int64) DivMod(b Int64) (quo Int64, rem Int64) {
|
||||||
var zero Int64;
|
var zero Int64;
|
||||||
@ -307,33 +293,25 @@ func (a Int64) DivMod(b Int64) (quo Int64, rem Int64) {
|
|||||||
rem = r.Int64();
|
rem = r.Int64();
|
||||||
|
|
||||||
if quoSign < 0 {
|
if quoSign < 0 {
|
||||||
quo = quo.Neg();
|
quo = quo.Neg()
|
||||||
}
|
}
|
||||||
if remSign < 0 {
|
if remSign < 0 {
|
||||||
rem = rem.Neg();
|
rem = rem.Neg()
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Int64) And(b Int64) (c Int64) {
|
func (a Int64) And(b Int64) (c Int64) { return a.Uint64().And(b.Uint64()).Int64() }
|
||||||
return a.Uint64().And(b.Uint64()).Int64();
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a Int64) AndNot(b Int64) (c Int64) {
|
func (a Int64) AndNot(b Int64) (c Int64) { return a.Uint64().AndNot(b.Uint64()).Int64() }
|
||||||
return a.Uint64().AndNot(b.Uint64()).Int64();
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a Int64) Or(b Int64) (c Int64) {
|
func (a Int64) Or(b Int64) (c Int64) { return a.Uint64().Or(b.Uint64()).Int64() }
|
||||||
return a.Uint64().Or(b.Uint64()).Int64();
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a Int64) Xor(b Int64) (c Int64) {
|
func (a Int64) Xor(b Int64) (c Int64) { return a.Uint64().Xor(b.Uint64()).Int64() }
|
||||||
return a.Uint64().Xor(b.Uint64()).Int64();
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a Int64) String() string {
|
func (a Int64) String() string {
|
||||||
if a.hi < 0 {
|
if a.hi < 0 {
|
||||||
return fmt.Sprintf("-%s", a.Neg().Uint64());
|
return fmt.Sprintf("-%s", a.Neg().Uint64())
|
||||||
}
|
}
|
||||||
return a.Uint64().String();
|
return a.Uint64().String();
|
||||||
}
|
}
|
||||||
@ -425,108 +403,107 @@ var shiftValues = []Uint64 {
|
|||||||
Uint64{1<<32 - 1, 1<<32 - 1},
|
Uint64{1<<32 - 1, 1<<32 - 1},
|
||||||
}
|
}
|
||||||
|
|
||||||
var ntest = 0;
|
var ntest = 0
|
||||||
|
|
||||||
// Part 1 is tests of variable operations; generic functions
|
// Part 1 is tests of variable operations; generic functions
|
||||||
// called by repetitive code. Could make a table but not worth it.
|
// called by repetitive code. Could make a table but not worth it.
|
||||||
|
|
||||||
const prolog =
|
const prolog = "\n" +
|
||||||
"\n"
|
"package main\n" +
|
||||||
"package main\n"
|
"\n" +
|
||||||
"\n"
|
"import \"os\"\n" +
|
||||||
"import \"os\"\n"
|
"\n" +
|
||||||
"\n"
|
"var ok = true\n" +
|
||||||
"var ok = true\n"
|
"\n" +
|
||||||
"\n"
|
"func testInt64Unary(a, plus, xor, minus int64) {\n" +
|
||||||
"func testInt64Unary(a, plus, xor, minus int64) {\n"
|
" if n, op, want := +a, `+`, plus; n != want { ok=false; println(`int64`, op, a, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := +a, `+`, plus; n != want { ok=false; println(`int64`, op, a, `=`, n, `should be`, want); }\n"
|
" if n, op, want := ^a, `^`, xor; n != want { ok=false; println(`int64`, op, a, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := ^a, `^`, xor; n != want { ok=false; println(`int64`, op, a, `=`, n, `should be`, want); }\n"
|
" if n, op, want := -a, `-`, minus; n != want { ok=false; println(`int64`, op, a, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := -a, `-`, minus; n != want { ok=false; println(`int64`, op, a, `=`, n, `should be`, want); }\n"
|
"}\n" +
|
||||||
"}\n"
|
"\n" +
|
||||||
"\n"
|
"func testInt64Binary(a, b, add, sub, mul, div, mod, and, or, xor, andnot int64, dodiv bool) {\n" +
|
||||||
"func testInt64Binary(a, b, add, sub, mul, div, mod, and, or, xor, andnot int64, dodiv bool) {\n"
|
" if n, op, want := a + b, `+`, add; n != want { ok=false; println(`int64`, a, op, b, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := a + b, `+`, add; n != want { ok=false; println(`int64`, a, op, b, `=`, n, `should be`, want); }\n"
|
" if n, op, want := a - b, `-`, sub; n != want { ok=false; println(`int64`, a, op, b, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := a - b, `-`, sub; n != want { ok=false; println(`int64`, a, op, b, `=`, n, `should be`, want); }\n"
|
" if n, op, want := a * b, `*`, mul; n != want { ok=false; println(`int64`, a, op, b, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := a * b, `*`, mul; n != want { ok=false; println(`int64`, a, op, b, `=`, n, `should be`, want); }\n"
|
" if dodiv {\n" +
|
||||||
" if dodiv {\n"
|
" if n, op, want := a / b, `/`, div; n != want { ok=false; println(`int64`, a, op, b, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := a / b, `/`, div; n != want { ok=false; println(`int64`, a, op, b, `=`, n, `should be`, want); }\n"
|
" if n, op, want := a % b, `%`, mod; n != want { ok=false; println(`int64`, a, op, b, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := a % b, `%`, mod; n != want { ok=false; println(`int64`, a, op, b, `=`, n, `should be`, want); }\n"
|
" }\n" +
|
||||||
" }\n"
|
" if n, op, want := a & b, `&`, and; n != want { ok=false; println(`int64`, a, op, b, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := a & b, `&`, and; n != want { ok=false; println(`int64`, a, op, b, `=`, n, `should be`, want); }\n"
|
" if n, op, want := a | b, `|`, or; n != want { ok=false; println(`int64`, a, op, b, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := a | b, `|`, or; n != want { ok=false; println(`int64`, a, op, b, `=`, n, `should be`, want); }\n"
|
" if n, op, want := a ^ b, `^`, xor; n != want { ok=false; println(`int64`, a, op, b, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := a ^ b, `^`, xor; n != want { ok=false; println(`int64`, a, op, b, `=`, n, `should be`, want); }\n"
|
" if n, op, want := a &^ b, `&^`, andnot; n != want { ok=false; println(`int64`, a, op, b, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := a &^ b, `&^`, andnot; n != want { ok=false; println(`int64`, a, op, b, `=`, n, `should be`, want); }\n"
|
"}\n" +
|
||||||
"}\n"
|
"\n" +
|
||||||
"\n"
|
"func testInt64Shift(a int64, b uint64, left, right int64) {\n" +
|
||||||
"func testInt64Shift(a int64, b uint64, left, right int64) {\n"
|
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(`int64`, a, op, `uint64`, s, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(`int64`, a, op, `uint64`, s, `=`, n, `should be`, want); }\n"
|
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(`int64`, a, op, `uint64`, s, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(`int64`, a, op, `uint64`, s, `=`, n, `should be`, want); }\n"
|
" if uint64(uint(b)) == b {\n" +
|
||||||
" if uint64(uint(b)) == b {\n"
|
" b := uint(b);\n" +
|
||||||
" b := uint(b);\n"
|
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(`int64`, a, op, `uint`, s, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(`int64`, a, op, `uint`, s, `=`, n, `should be`, want); }\n"
|
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(`int64`, a, op, `uint`, s, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(`int64`, a, op, `uint`, s, `=`, n, `should be`, want); }\n"
|
" }\n" +
|
||||||
" }\n"
|
" if uint64(uint32(b)) == b {\n" +
|
||||||
" if uint64(uint32(b)) == b {\n"
|
" b := uint32(b);\n" +
|
||||||
" b := uint32(b);\n"
|
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(`int64`, a, op, `uint32`, s, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(`int64`, a, op, `uint32`, s, `=`, n, `should be`, want); }\n"
|
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(`int64`, a, op, `uint32`, s, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(`int64`, a, op, `uint32`, s, `=`, n, `should be`, want); }\n"
|
" }\n" +
|
||||||
" }\n"
|
" if uint64(uint16(b)) == b {\n" +
|
||||||
" if uint64(uint16(b)) == b {\n"
|
" b := uint16(b);\n" +
|
||||||
" b := uint16(b);\n"
|
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(`int64`, a, op, `uint16`, s, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(`int64`, a, op, `uint16`, s, `=`, n, `should be`, want); }\n"
|
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(`int64`, a, op, `uint16`, s, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(`int64`, a, op, `uint16`, s, `=`, n, `should be`, want); }\n"
|
" }\n" +
|
||||||
" }\n"
|
" if uint64(uint8(b)) == b {\n" +
|
||||||
" if uint64(uint8(b)) == b {\n"
|
" b := uint8(b);\n" +
|
||||||
" b := uint8(b);\n"
|
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(`int64`, a, op, `uint8`, s, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(`int64`, a, op, `uint8`, s, `=`, n, `should be`, want); }\n"
|
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(`int64`, a, op, `uint8`, s, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(`int64`, a, op, `uint8`, s, `=`, n, `should be`, want); }\n"
|
" }\n" +
|
||||||
" }\n"
|
"}\n" +
|
||||||
"}\n"
|
"\n" +
|
||||||
"\n"
|
"func testUint64Unary(a, plus, xor, minus uint64) {\n" +
|
||||||
"func testUint64Unary(a, plus, xor, minus uint64) {\n"
|
" if n, op, want := +a, `+`, plus; n != want { ok=false; println(`uint64`, op, a, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := +a, `+`, plus; n != want { ok=false; println(`uint64`, op, a, `=`, n, `should be`, want); }\n"
|
" if n, op, want := ^a, `^`, xor; n != want { ok=false; println(`uint64`, op, a, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := ^a, `^`, xor; n != want { ok=false; println(`uint64`, op, a, `=`, n, `should be`, want); }\n"
|
" if n, op, want := -a, `-`, minus; n != want { ok=false; println(`uint64`, op, a, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := -a, `-`, minus; n != want { ok=false; println(`uint64`, op, a, `=`, n, `should be`, want); }\n"
|
"}\n" +
|
||||||
"}\n"
|
"\n" +
|
||||||
"\n"
|
"func testUint64Binary(a, b, add, sub, mul, div, mod, and, or, xor, andnot uint64, dodiv bool) {\n" +
|
||||||
"func testUint64Binary(a, b, add, sub, mul, div, mod, and, or, xor, andnot uint64, dodiv bool) {\n"
|
" if n, op, want := a + b, `+`, add; n != want { ok=false; println(`uint64`, a, op, b, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := a + b, `+`, add; n != want { ok=false; println(`uint64`, a, op, b, `=`, n, `should be`, want); }\n"
|
" if n, op, want := a - b, `-`, sub; n != want { ok=false; println(`uint64`, a, op, b, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := a - b, `-`, sub; n != want { ok=false; println(`uint64`, a, op, b, `=`, n, `should be`, want); }\n"
|
" if n, op, want := a * b, `*`, mul; n != want { ok=false; println(`uint64`, a, op, b, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := a * b, `*`, mul; n != want { ok=false; println(`uint64`, a, op, b, `=`, n, `should be`, want); }\n"
|
" if dodiv {\n" +
|
||||||
" if dodiv {\n"
|
" if n, op, want := a / b, `/`, div; n != want { ok=false; println(`uint64`, a, op, b, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := a / b, `/`, div; n != want { ok=false; println(`uint64`, a, op, b, `=`, n, `should be`, want); }\n"
|
" if n, op, want := a % b, `%`, mod; n != want { ok=false; println(`uint64`, a, op, b, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := a % b, `%`, mod; n != want { ok=false; println(`uint64`, a, op, b, `=`, n, `should be`, want); }\n"
|
" }\n" +
|
||||||
" }\n"
|
" if n, op, want := a & b, `&`, and; n != want { ok=false; println(`uint64`, a, op, b, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := a & b, `&`, and; n != want { ok=false; println(`uint64`, a, op, b, `=`, n, `should be`, want); }\n"
|
" if n, op, want := a | b, `|`, or; n != want { ok=false; println(`uint64`, a, op, b, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := a | b, `|`, or; n != want { ok=false; println(`uint64`, a, op, b, `=`, n, `should be`, want); }\n"
|
" if n, op, want := a ^ b, `^`, xor; n != want { ok=false; println(`uint64`, a, op, b, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := a ^ b, `^`, xor; n != want { ok=false; println(`uint64`, a, op, b, `=`, n, `should be`, want); }\n"
|
" if n, op, want := a &^ b, `&^`, andnot; n != want { ok=false; println(`uint64`, a, op, b, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := a &^ b, `&^`, andnot; n != want { ok=false; println(`uint64`, a, op, b, `=`, n, `should be`, want); }\n"
|
"}\n" +
|
||||||
"}\n"
|
"\n" +
|
||||||
"\n"
|
"func testUint64Shift(a, b, left, right uint64) {\n" +
|
||||||
"func testUint64Shift(a, b, left, right uint64) {\n"
|
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(`uint64`, a, op, `uint64`, s, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(`uint64`, a, op, `uint64`, s, `=`, n, `should be`, want); }\n"
|
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(`uint64`, a, op, `uint64`, s, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(`uint64`, a, op, `uint64`, s, `=`, n, `should be`, want); }\n"
|
" if uint64(uint(b)) == b {\n" +
|
||||||
" if uint64(uint(b)) == b {\n"
|
" b := uint(b);\n" +
|
||||||
" b := uint(b);\n"
|
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(`uint64`, a, op, `uint`, s, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(`uint64`, a, op, `uint`, s, `=`, n, `should be`, want); }\n"
|
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(`uint64`, a, op, `uint`, s, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(`uint64`, a, op, `uint`, s, `=`, n, `should be`, want); }\n"
|
" }\n" +
|
||||||
" }\n"
|
" if uint64(uint32(b)) == b {\n" +
|
||||||
" if uint64(uint32(b)) == b {\n"
|
" b := uint32(b);\n" +
|
||||||
" b := uint32(b);\n"
|
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(`uint64`, a, op, `uint32`, s, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(`uint64`, a, op, `uint32`, s, `=`, n, `should be`, want); }\n"
|
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(`uint64`, a, op, `uint32`, s, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(`uint64`, a, op, `uint32`, s, `=`, n, `should be`, want); }\n"
|
" }\n" +
|
||||||
" }\n"
|
" if uint64(uint16(b)) == b {\n" +
|
||||||
" if uint64(uint16(b)) == b {\n"
|
" b := uint16(b);\n" +
|
||||||
" b := uint16(b);\n"
|
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(`uint64`, a, op, `uint16`, s, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(`uint64`, a, op, `uint16`, s, `=`, n, `should be`, want); }\n"
|
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(`uint64`, a, op, `uint16`, s, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(`uint64`, a, op, `uint16`, s, `=`, n, `should be`, want); }\n"
|
" }\n" +
|
||||||
" }\n"
|
" if uint64(uint8(b)) == b {\n" +
|
||||||
" if uint64(uint8(b)) == b {\n"
|
" b := uint8(b);\n" +
|
||||||
" b := uint8(b);\n"
|
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(`uint64`, a, op, `uint8`, s, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(`uint64`, a, op, `uint8`, s, `=`, n, `should be`, want); }\n"
|
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(`uint64`, a, op, `uint8`, s, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(`uint64`, a, op, `uint8`, s, `=`, n, `should be`, want); }\n"
|
" }\n" +
|
||||||
" }\n"
|
"}\n" +
|
||||||
"}\n"
|
|
||||||
"\n"
|
"\n"
|
||||||
|
|
||||||
func varTests() {
|
func varTests() {
|
||||||
@ -554,7 +531,7 @@ func varTests() {
|
|||||||
}
|
}
|
||||||
for _, b := range shiftValues {
|
for _, b := range shiftValues {
|
||||||
fmt.Fprintf(bout, "\ttestInt64Shift(%v, %v, %v, %v);\n",
|
fmt.Fprintf(bout, "\ttestInt64Shift(%v, %v, %v, %v);\n",
|
||||||
a, b, a.LeftShift64(b), a.RightShift64(b));
|
a, b, a.LeftShift64(b), a.RightShift64(b))
|
||||||
}
|
}
|
||||||
fmt.Fprintf(bout, "}\n");
|
fmt.Fprintf(bout, "}\n");
|
||||||
}
|
}
|
||||||
@ -577,7 +554,7 @@ func varTests() {
|
|||||||
}
|
}
|
||||||
for _, b := range shiftValues {
|
for _, b := range shiftValues {
|
||||||
fmt.Fprintf(bout, "\ttestUint64Shift(%v, %v, %v, %v);\n",
|
fmt.Fprintf(bout, "\ttestUint64Shift(%v, %v, %v, %v);\n",
|
||||||
a, b, a.LeftShift64(b), a.RightShift64(b));
|
a, b, a.LeftShift64(b), a.RightShift64(b))
|
||||||
}
|
}
|
||||||
fmt.Fprintf(bout, "}\n");
|
fmt.Fprintf(bout, "}\n");
|
||||||
}
|
}
|
||||||
@ -585,66 +562,62 @@ func varTests() {
|
|||||||
|
|
||||||
// Part 2 is tests of operations involving one variable and one constant.
|
// Part 2 is tests of operations involving one variable and one constant.
|
||||||
|
|
||||||
const binaryConstL =
|
const binaryConstL = "func test%vBinaryL%v(b, add, sub, mul, div, mod, and, or, xor, andnot %v, dodiv bool) {\n" +
|
||||||
"func test%vBinaryL%v(b, add, sub, mul, div, mod, and, or, xor, andnot %v, dodiv bool) {\n"
|
" const a %v = %v;\n" +
|
||||||
" const a %v = %v;\n"
|
" const typ = `%s`;\n" +
|
||||||
" const typ = `%s`;\n"
|
" if n, op, want := a + b, `+`, add; n != want { ok=false; println(typ, `const`, a, op, `var`, b, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := a + b, `+`, add; n != want { ok=false; println(typ, `const`, a, op, `var`, b, `=`, n, `should be`, want); }\n"
|
" if n, op, want := a - b, `-`, sub; n != want { ok=false; println(typ, `const`, a, op, `var`, b, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := a - b, `-`, sub; n != want { ok=false; println(typ, `const`, a, op, `var`, b, `=`, n, `should be`, want); }\n"
|
" if n, op, want := a * b, `*`, mul; n != want { ok=false; println(typ, `const`, a, op, `var`, b, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := a * b, `*`, mul; n != want { ok=false; println(typ, `const`, a, op, `var`, b, `=`, n, `should be`, want); }\n"
|
" if dodiv {\n" +
|
||||||
" if dodiv {\n"
|
" if n, op, want := a / b, `/`, div; n != want { ok=false; println(typ, `const`, a, op, `var`, b, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := a / b, `/`, div; n != want { ok=false; println(typ, `const`, a, op, `var`, b, `=`, n, `should be`, want); }\n"
|
" if n, op, want := a %% b, `%%`, mod; n != want { ok=false; println(typ, `const`, a, op, `var`, b, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := a %% b, `%%`, mod; n != want { ok=false; println(typ, `const`, a, op, `var`, b, `=`, n, `should be`, want); }\n"
|
" }\n" +
|
||||||
" }\n"
|
" if n, op, want := a & b, `&`, and; n != want { ok=false; println(typ, `const`, a, op, `var`, b, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := a & b, `&`, and; n != want { ok=false; println(typ, `const`, a, op, `var`, b, `=`, n, `should be`, want); }\n"
|
" if n, op, want := a | b, `|`, or; n != want { ok=false; println(typ, `const`, a, op, `var`, b, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := a | b, `|`, or; n != want { ok=false; println(typ, `const`, a, op, `var`, b, `=`, n, `should be`, want); }\n"
|
" if n, op, want := a ^ b, `^`, xor; n != want { ok=false; println(typ, `const`, a, op, `var`, b, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := a ^ b, `^`, xor; n != want { ok=false; println(typ, `const`, a, op, `var`, b, `=`, n, `should be`, want); }\n"
|
" if n, op, want := a &^ b, `&^`, andnot; n != want { ok=false; println(typ, `const`, a, op, `var`, b, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := a &^ b, `&^`, andnot; n != want { ok=false; println(typ, `const`, a, op, `var`, b, `=`, n, `should be`, want); }\n"
|
"}\n" +
|
||||||
"}\n"
|
|
||||||
"\n"
|
"\n"
|
||||||
|
|
||||||
const binaryConstR =
|
const binaryConstR = "func test%vBinaryR%v(a, add, sub, mul, div, mod, and, or, xor, andnot %v, dodiv bool) {\n" +
|
||||||
"func test%vBinaryR%v(a, add, sub, mul, div, mod, and, or, xor, andnot %v, dodiv bool) {\n"
|
" const b %v = %v;\n" +
|
||||||
" const b %v = %v;\n"
|
" const typ = `%s`;\n" +
|
||||||
" const typ = `%s`;\n"
|
" if n, op, want := a + b, `+`, add; n != want { ok=false; println(typ, `var`, a, op, `const`, b, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := a + b, `+`, add; n != want { ok=false; println(typ, `var`, a, op, `const`, b, `=`, n, `should be`, want); }\n"
|
" if n, op, want := a - b, `-`, sub; n != want { ok=false; println(typ, `var`, a, op, `const`, b, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := a - b, `-`, sub; n != want { ok=false; println(typ, `var`, a, op, `const`, b, `=`, n, `should be`, want); }\n"
|
" if n, op, want := a * b, `*`, mul; n != want { ok=false; println(typ, `var`, a, op, `const`, b, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := a * b, `*`, mul; n != want { ok=false; println(typ, `var`, a, op, `const`, b, `=`, n, `should be`, want); }\n"
|
" if dodiv {\n" +
|
||||||
" if dodiv {\n"
|
" if n, op, want := a / b, `/`, div; n != want { ok=false; println(typ, `var`, a, op, `const`, b, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := a / b, `/`, div; n != want { ok=false; println(typ, `var`, a, op, `const`, b, `=`, n, `should be`, want); }\n"
|
" if n, op, want := a %% b, `%%`, mod; n != want { ok=false; println(typ, `var`, a, op, `const`, b, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := a %% b, `%%`, mod; n != want { ok=false; println(typ, `var`, a, op, `const`, b, `=`, n, `should be`, want); }\n"
|
" }\n" +
|
||||||
" }\n"
|
" if n, op, want := a & b, `&`, and; n != want { ok=false; println(typ, `var`, a, op, `const`, b, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := a & b, `&`, and; n != want { ok=false; println(typ, `var`, a, op, `const`, b, `=`, n, `should be`, want); }\n"
|
" if n, op, want := a | b, `|`, or; n != want { ok=false; println(typ, `var`, a, op, `const`, b, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := a | b, `|`, or; n != want { ok=false; println(typ, `var`, a, op, `const`, b, `=`, n, `should be`, want); }\n"
|
" if n, op, want := a ^ b, `^`, xor; n != want { ok=false; println(typ, `var`, a, op, `const`, b, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := a ^ b, `^`, xor; n != want { ok=false; println(typ, `var`, a, op, `const`, b, `=`, n, `should be`, want); }\n"
|
" if n, op, want := a &^ b, `&^`, andnot; n != want { ok=false; println(typ, `var`, a, op, `const`, b, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, want := a &^ b, `&^`, andnot; n != want { ok=false; println(typ, `var`, a, op, `const`, b, `=`, n, `should be`, want); }\n"
|
"}\n" +
|
||||||
"}\n"
|
|
||||||
"\n"
|
"\n"
|
||||||
|
|
||||||
const shiftConstL =
|
const shiftConstL = "func test%vShiftL%v(b uint64, left, right %v) {\n" +
|
||||||
"func test%vShiftL%v(b uint64, left, right %v) {\n"
|
" const a %v = %v;\n" +
|
||||||
" const a %v = %v;\n"
|
" const typ = `%s`;\n" +
|
||||||
" const typ = `%s`;\n"
|
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(typ, `const`, a, op, `var`, s, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(typ, `const`, a, op, `var`, s, `=`, n, `should be`, want); }\n"
|
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(typ, `const`, a, op, `var`, s, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(typ, `const`, a, op, `var`, s, `=`, n, `should be`, want); }\n"
|
" if uint64(uint32(b)) == b {\n" +
|
||||||
" if uint64(uint32(b)) == b {\n"
|
" b := uint32(b);\n" +
|
||||||
" b := uint32(b);\n"
|
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(typ, `const`, a, op, `var`, s, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(typ, `const`, a, op, `var`, s, `=`, n, `should be`, want); }\n"
|
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(typ, `const`, a, op, `var`, s, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(typ, `const`, a, op, `var`, s, `=`, n, `should be`, want); }\n"
|
" }\n" +
|
||||||
" }\n"
|
|
||||||
"}\n"
|
"}\n"
|
||||||
|
|
||||||
const shiftConstR =
|
const shiftConstR = "func test%vShiftR%v(a, left, right %v) {\n" +
|
||||||
"func test%vShiftR%v(a, left, right %v) {\n"
|
" const b uint64 = %v;\n" +
|
||||||
" const b uint64 = %v;\n"
|
" const typ = `%s`;\n" +
|
||||||
" const typ = `%s`;\n"
|
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(typ, `var`, a, op, `const`, s, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(typ, `var`, a, op, `const`, s, `=`, n, `should be`, want); }\n"
|
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(typ, `var`, a, op, `const`, s, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(typ, `var`, a, op, `const`, s, `=`, n, `should be`, want); }\n"
|
" if b & 0xffffffff == b {\n" +
|
||||||
" if b & 0xffffffff == b {\n"
|
" const b = uint32(b & 0xffffffff);\n" +
|
||||||
" const b = uint32(b & 0xffffffff);\n"
|
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(typ, `var`, a, op, `const`, s, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, s, want := a << b, `<<`, b, left; n != want { ok=false; println(typ, `var`, a, op, `const`, s, `=`, n, `should be`, want); }\n"
|
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(typ, `var`, a, op, `const`, s, `=`, n, `should be`, want); }\n" +
|
||||||
" if n, op, s, want := a >> b, `>>`, b, right; n != want { ok=false; println(typ, `var`, a, op, `const`, s, `=`, n, `should be`, want); }\n"
|
" }\n" +
|
||||||
" }\n"
|
|
||||||
"}\n"
|
"}\n"
|
||||||
|
|
||||||
func constTests() {
|
func constTests() {
|
||||||
@ -728,7 +701,7 @@ func main() {
|
|||||||
|
|
||||||
fmt.Fprintf(bout, "func main() {\n");
|
fmt.Fprintf(bout, "func main() {\n");
|
||||||
for i := 0; i < ntest; i++ {
|
for i := 0; i < ntest; i++ {
|
||||||
fmt.Fprintf(bout, "\ttest%v();\n", i);
|
fmt.Fprintf(bout, "\ttest%v();\n", i)
|
||||||
}
|
}
|
||||||
fmt.Fprintf(bout, "\tif !ok { os.Exit(1) }\n");
|
fmt.Fprintf(bout, "\tif !ok { os.Exit(1) }\n");
|
||||||
fmt.Fprintf(bout, "}\n");
|
fmt.Fprintf(bout, "}\n");
|
||||||
|
@ -162,12 +162,12 @@ func main() {
|
|||||||
AccumulateProbabilities(homosapiens);
|
AccumulateProbabilities(homosapiens);
|
||||||
|
|
||||||
alu := strings.Bytes(
|
alu := strings.Bytes(
|
||||||
"GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG"
|
"GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG" +
|
||||||
"GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA"
|
"GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA" +
|
||||||
"CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT"
|
"CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT" +
|
||||||
"ACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCA"
|
"ACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCA" +
|
||||||
"GCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGG"
|
"GCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGG" +
|
||||||
"AGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCC"
|
"AGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCC" +
|
||||||
"AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA");
|
"AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA");
|
||||||
|
|
||||||
out.WriteString(">ONE Homo sapiens alu\n");
|
out.WriteString(">ONE Homo sapiens alu\n");
|
||||||
|
@ -8,7 +8,7 @@ package main
|
|||||||
|
|
||||||
import "os"
|
import "os"
|
||||||
|
|
||||||
var ecode int;
|
var ecode int
|
||||||
|
|
||||||
func assert(a, b, c string) {
|
func assert(a, b, c string) {
|
||||||
if a != b {
|
if a != b {
|
||||||
@ -16,19 +16,19 @@ func assert(a, b, c string) {
|
|||||||
print("FAIL: ", c, ": ", a, "!=", b, "\n");
|
print("FAIL: ", c, ": ", a, "!=", b, "\n");
|
||||||
var max int = len(a);
|
var max int = len(a);
|
||||||
if len(b) > max {
|
if len(b) > max {
|
||||||
max = len(b);
|
max = len(b)
|
||||||
}
|
}
|
||||||
for i := 0; i < max; i++ {
|
for i := 0; i < max; i++ {
|
||||||
ac := 0;
|
ac := 0;
|
||||||
bc := 0;
|
bc := 0;
|
||||||
if i < len(a) {
|
if i < len(a) {
|
||||||
ac = int(a[i]);
|
ac = int(a[i])
|
||||||
}
|
}
|
||||||
if i < len(b) {
|
if i < len(b) {
|
||||||
bc = int(b[i]);
|
bc = int(b[i])
|
||||||
}
|
}
|
||||||
if ac != bc {
|
if ac != bc {
|
||||||
print("\ta[", i, "] = ", ac, "; b[", i, "] =", bc, "\n");
|
print("\ta[", i, "] = ", ac, "; b[", i, "] =", bc, "\n")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -37,25 +37,25 @@ func assert(a, b, c string) {
|
|||||||
func main() {
|
func main() {
|
||||||
ecode = 0;
|
ecode = 0;
|
||||||
s :=
|
s :=
|
||||||
""
|
"" +
|
||||||
" "
|
" " +
|
||||||
"'`"
|
"'`" +
|
||||||
"a"
|
"a" +
|
||||||
"ä"
|
"ä" +
|
||||||
"本"
|
"本" +
|
||||||
"\a\b\f\n\r\t\v\\\""
|
"\a\b\f\n\r\t\v\\\"" +
|
||||||
"\000\123\x00\xca\xFE\u0123\ubabe\U0000babe"
|
"\000\123\x00\xca\xFE\u0123\ubabe\U0000babe" +
|
||||||
|
|
||||||
|
`` +
|
||||||
|
` ` +
|
||||||
|
`'"` +
|
||||||
|
`a` +
|
||||||
|
`ä` +
|
||||||
|
`本` +
|
||||||
|
`\a\b\f\n\r\t\v\\\'` +
|
||||||
|
`\000\123\x00\xca\xFE\u0123\ubabe\U0000babe` +
|
||||||
|
`\x\u\U\`;
|
||||||
|
|
||||||
``
|
|
||||||
` `
|
|
||||||
`'"`
|
|
||||||
`a`
|
|
||||||
`ä`
|
|
||||||
`本`
|
|
||||||
`\a\b\f\n\r\t\v\\\'`
|
|
||||||
`\000\123\x00\xca\xFE\u0123\ubabe\U0000babe`
|
|
||||||
`\x\u\U\`
|
|
||||||
;
|
|
||||||
assert("", ``, "empty");
|
assert("", ``, "empty");
|
||||||
assert(" ", " ", "blank");
|
assert(" ", " ", "blank");
|
||||||
assert("\x61", "a", "lowercase a");
|
assert("\x61", "a", "lowercase a");
|
||||||
|
Loading…
Reference in New Issue
Block a user