gofmt -s -w src misc
R=r, rsc
CC=golang-dev
https://golang.org/cl/2662041
diff --git a/src/pkg/big/int_test.go b/src/pkg/big/int_test.go
index 184bce5..3a2f2a0 100755
--- a/src/pkg/big/int_test.go
+++ b/src/pkg/big/int_test.go
@@ -29,20 +29,20 @@
var sumZZ = []argZZ{
- argZZ{NewInt(0), NewInt(0), NewInt(0)},
- argZZ{NewInt(1), NewInt(1), NewInt(0)},
- argZZ{NewInt(1111111110), NewInt(123456789), NewInt(987654321)},
- argZZ{NewInt(-1), NewInt(-1), NewInt(0)},
- argZZ{NewInt(864197532), NewInt(-123456789), NewInt(987654321)},
- argZZ{NewInt(-1111111110), NewInt(-123456789), NewInt(-987654321)},
+ {NewInt(0), NewInt(0), NewInt(0)},
+ {NewInt(1), NewInt(1), NewInt(0)},
+ {NewInt(1111111110), NewInt(123456789), NewInt(987654321)},
+ {NewInt(-1), NewInt(-1), NewInt(0)},
+ {NewInt(864197532), NewInt(-123456789), NewInt(987654321)},
+ {NewInt(-1111111110), NewInt(-123456789), NewInt(-987654321)},
}
var prodZZ = []argZZ{
- argZZ{NewInt(0), NewInt(0), NewInt(0)},
- argZZ{NewInt(0), NewInt(1), NewInt(0)},
- argZZ{NewInt(1), NewInt(1), NewInt(1)},
- argZZ{NewInt(-991 * 991), NewInt(991), NewInt(-991)},
+ {NewInt(0), NewInt(0), NewInt(0)},
+ {NewInt(0), NewInt(1), NewInt(0)},
+ {NewInt(1), NewInt(1), NewInt(1)},
+ {NewInt(-991 * 991), NewInt(991), NewInt(-991)},
// TODO(gri) add larger products
}
@@ -194,20 +194,20 @@
var mulRangesZ = []mulRangeZ{
// entirely positive ranges are covered by mulRangesN
- mulRangeZ{-1, 1, "0"},
- mulRangeZ{-2, -1, "2"},
- mulRangeZ{-3, -2, "6"},
- mulRangeZ{-3, -1, "-6"},
- mulRangeZ{1, 3, "6"},
- mulRangeZ{-10, -10, "-10"},
- mulRangeZ{0, -1, "1"}, // empty range
- mulRangeZ{-1, -100, "1"}, // empty range
- mulRangeZ{-1, 1, "0"}, // range includes 0
- mulRangeZ{-1e9, 0, "0"}, // range includes 0
- mulRangeZ{-1e9, 1e9, "0"}, // range includes 0
- mulRangeZ{-10, -1, "3628800"}, // 10!
- mulRangeZ{-20, -2, "-2432902008176640000"}, // -20!
- mulRangeZ{-99, -1,
+ {-1, 1, "0"},
+ {-2, -1, "2"},
+ {-3, -2, "6"},
+ {-3, -1, "-6"},
+ {1, 3, "6"},
+ {-10, -10, "-10"},
+ {0, -1, "1"}, // empty range
+ {-1, -100, "1"}, // empty range
+ {-1, 1, "0"}, // range includes 0
+ {-1e9, 0, "0"}, // range includes 0
+ {-1e9, 1e9, "0"}, // range includes 0
+ {-10, -1, "3628800"}, // 10!
+ {-20, -2, "-2432902008176640000"}, // -20!
+ {-99, -1,
"-933262154439441526816992388562667004907159682643816214685929" +
"638952175999932299156089414639761565182862536979208272237582" +
"511852109168640000000000000000000000", // -99!
@@ -244,45 +244,45 @@
var stringTests = []stringTest{
- stringTest{in: "", ok: false},
- stringTest{in: "a", ok: false},
- stringTest{in: "z", ok: false},
- stringTest{in: "+", ok: false},
- stringTest{in: "-", ok: false},
- stringTest{in: "0b", ok: false},
- stringTest{in: "0x", ok: false},
- stringTest{in: "2", base: 2, ok: false},
- stringTest{in: "0b2", base: 0, ok: false},
- stringTest{in: "08", ok: false},
- stringTest{in: "8", base: 8, ok: false},
- stringTest{in: "0xg", base: 0, ok: false},
- stringTest{in: "g", base: 16, ok: false},
- stringTest{"0", "0", 0, 0, true},
- stringTest{"0", "0", 10, 0, true},
- stringTest{"0", "0", 16, 0, true},
- stringTest{"+0", "0", 0, 0, true},
- stringTest{"-0", "0", 0, 0, true},
- stringTest{"10", "10", 0, 10, true},
- stringTest{"10", "10", 10, 10, true},
- stringTest{"10", "10", 16, 16, true},
- stringTest{"-10", "-10", 16, -16, true},
- stringTest{"+10", "10", 16, 16, true},
- stringTest{"0x10", "16", 0, 16, true},
- stringTest{in: "0x10", base: 16, ok: false},
- stringTest{"-0x10", "-16", 0, -16, true},
- stringTest{"+0x10", "16", 0, 16, true},
- stringTest{"00", "0", 0, 0, true},
- stringTest{"0", "0", 8, 0, true},
- stringTest{"07", "7", 0, 7, true},
- stringTest{"7", "7", 8, 7, true},
- stringTest{"023", "19", 0, 19, true},
- stringTest{"23", "23", 8, 19, true},
- stringTest{"cafebabe", "cafebabe", 16, 0xcafebabe, true},
- stringTest{"0b0", "0", 0, 0, true},
- stringTest{"-111", "-111", 2, -7, true},
- stringTest{"-0b111", "-7", 0, -7, true},
- stringTest{"0b1001010111", "599", 0, 0x257, true},
- stringTest{"1001010111", "1001010111", 2, 0x257, true},
+ {in: "", ok: false},
+ {in: "a", ok: false},
+ {in: "z", ok: false},
+ {in: "+", ok: false},
+ {in: "-", ok: false},
+ {in: "0b", ok: false},
+ {in: "0x", ok: false},
+ {in: "2", base: 2, ok: false},
+ {in: "0b2", base: 0, ok: false},
+ {in: "08", ok: false},
+ {in: "8", base: 8, ok: false},
+ {in: "0xg", base: 0, ok: false},
+ {in: "g", base: 16, ok: false},
+ {"0", "0", 0, 0, true},
+ {"0", "0", 10, 0, true},
+ {"0", "0", 16, 0, true},
+ {"+0", "0", 0, 0, true},
+ {"-0", "0", 0, 0, true},
+ {"10", "10", 0, 10, true},
+ {"10", "10", 10, 10, true},
+ {"10", "10", 16, 16, true},
+ {"-10", "-10", 16, -16, true},
+ {"+10", "10", 16, 16, true},
+ {"0x10", "16", 0, 16, true},
+ {in: "0x10", base: 16, ok: false},
+ {"-0x10", "-16", 0, -16, true},
+ {"+0x10", "16", 0, 16, true},
+ {"00", "0", 0, 0, true},
+ {"0", "0", 8, 0, true},
+ {"07", "7", 0, 7, true},
+ {"7", "7", 8, 7, true},
+ {"023", "19", 0, 19, true},
+ {"23", "23", 8, 19, true},
+ {"cafebabe", "cafebabe", 16, 0xcafebabe, true},
+ {"0b0", "0", 0, 0, true},
+ {"-111", "-111", 2, -7, true},
+ {"-0b111", "-7", 0, -7, true},
+ {"0b1001010111", "599", 0, 0x257, true},
+ {"1001010111", "1001010111", 2, 0x257, true},
}
@@ -362,12 +362,12 @@
// Examples from the Go Language Spec, section "Arithmetic operators"
var divisionSignsTests = []divisionSignsTest{
- divisionSignsTest{5, 3, 1, 2, 1, 2},
- divisionSignsTest{-5, 3, -1, -2, -2, 1},
- divisionSignsTest{5, -3, -1, 2, -1, 2},
- divisionSignsTest{-5, -3, 1, -2, 2, 1},
- divisionSignsTest{1, 2, 0, 1, 0, 1},
- divisionSignsTest{8, 4, 2, 0, 2, 0},
+ {5, 3, 1, 2, 1, 2},
+ {-5, 3, -1, -2, -2, 1},
+ {5, -3, -1, 2, -1, 2},
+ {-5, -3, 1, -2, 2, 1},
+ {1, 2, 0, 1, 0, 1},
+ {8, 4, 2, 0, 2, 0},
}
@@ -495,13 +495,13 @@
var quoTests = []quoTest{
- quoTest{
+ {
"476217953993950760840509444250624797097991362735329973741718102894495832294430498335824897858659711275234906400899559094370964723884706254265559534144986498357",
"9353930466774385905609975137998169297361893554149986716853295022578535724979483772383667534691121982974895531435241089241440253066816724367338287092081996",
"50911",
"1",
},
- quoTest{
+ {
"11510768301994997771168",
"1328165573307167369775",
"8",
@@ -558,18 +558,18 @@
var bitLenTests = []bitLenTest{
- bitLenTest{"-1", 1},
- bitLenTest{"0", 0},
- bitLenTest{"1", 1},
- bitLenTest{"2", 2},
- bitLenTest{"4", 3},
- bitLenTest{"0xabc", 12},
- bitLenTest{"0x8000", 16},
- bitLenTest{"0x80000000", 32},
- bitLenTest{"0x800000000000", 48},
- bitLenTest{"0x8000000000000000", 64},
- bitLenTest{"0x80000000000000000000", 80},
- bitLenTest{"-0x4000000000000000000000", 87},
+ {"-1", 1},
+ {"0", 0},
+ {"1", 1},
+ {"2", 2},
+ {"4", 3},
+ {"0xabc", 12},
+ {"0x8000", 16},
+ {"0x80000000", 32},
+ {"0x800000000000", 48},
+ {"0x8000000000000000", 64},
+ {"0x80000000000000000000", 80},
+ {"-0x4000000000000000000000", 87},
}
@@ -595,19 +595,19 @@
var expTests = []expTest{
- expTest{"5", "0", "", "1"},
- expTest{"-5", "0", "", "-1"},
- expTest{"5", "1", "", "5"},
- expTest{"-5", "1", "", "-5"},
- expTest{"-2", "3", "2", "0"},
- expTest{"5", "2", "", "25"},
- expTest{"1", "65537", "2", "1"},
- expTest{"0x8000000000000000", "2", "", "0x40000000000000000000000000000000"},
- expTest{"0x8000000000000000", "2", "6719", "4944"},
- expTest{"0x8000000000000000", "3", "6719", "5447"},
- expTest{"0x8000000000000000", "1000", "6719", "1603"},
- expTest{"0x8000000000000000", "1000000", "6719", "3199"},
- expTest{
+ {"5", "0", "", "1"},
+ {"-5", "0", "", "-1"},
+ {"5", "1", "", "5"},
+ {"-5", "1", "", "-5"},
+ {"-2", "3", "2", "0"},
+ {"5", "2", "", "25"},
+ {"1", "65537", "2", "1"},
+ {"0x8000000000000000", "2", "", "0x40000000000000000000000000000000"},
+ {"0x8000000000000000", "2", "6719", "4944"},
+ {"0x8000000000000000", "3", "6719", "5447"},
+ {"0x8000000000000000", "1000", "6719", "1603"},
+ {"0x8000000000000000", "1000000", "6719", "3199"},
+ {
"2938462938472983472983659726349017249287491026512746239764525612965293865296239471239874193284792387498274256129746192347",
"298472983472983471903246121093472394872319615612417471234712061",
"29834729834729834729347290846729561262544958723956495615629569234729836259263598127342374289365912465901365498236492183464",
@@ -671,7 +671,7 @@
var gcdTests = []gcdTest{
- gcdTest{120, 23, 1, -9, 47},
+ {120, 23, 1, -9, 47},
}
@@ -760,30 +760,30 @@
var rshTests = []intShiftTest{
- intShiftTest{"0", 0, "0"},
- intShiftTest{"-0", 0, "0"},
- intShiftTest{"0", 1, "0"},
- intShiftTest{"0", 2, "0"},
- intShiftTest{"1", 0, "1"},
- intShiftTest{"1", 1, "0"},
- intShiftTest{"1", 2, "0"},
- intShiftTest{"2", 0, "2"},
- intShiftTest{"2", 1, "1"},
- intShiftTest{"-1", 0, "-1"},
- intShiftTest{"-1", 1, "-1"},
- intShiftTest{"-1", 10, "-1"},
- intShiftTest{"-100", 2, "-25"},
- intShiftTest{"-100", 3, "-13"},
- intShiftTest{"-100", 100, "-1"},
- intShiftTest{"4294967296", 0, "4294967296"},
- intShiftTest{"4294967296", 1, "2147483648"},
- intShiftTest{"4294967296", 2, "1073741824"},
- intShiftTest{"18446744073709551616", 0, "18446744073709551616"},
- intShiftTest{"18446744073709551616", 1, "9223372036854775808"},
- intShiftTest{"18446744073709551616", 2, "4611686018427387904"},
- intShiftTest{"18446744073709551616", 64, "1"},
- intShiftTest{"340282366920938463463374607431768211456", 64, "18446744073709551616"},
- intShiftTest{"340282366920938463463374607431768211456", 128, "1"},
+ {"0", 0, "0"},
+ {"-0", 0, "0"},
+ {"0", 1, "0"},
+ {"0", 2, "0"},
+ {"1", 0, "1"},
+ {"1", 1, "0"},
+ {"1", 2, "0"},
+ {"2", 0, "2"},
+ {"2", 1, "1"},
+ {"-1", 0, "-1"},
+ {"-1", 1, "-1"},
+ {"-1", 10, "-1"},
+ {"-100", 2, "-25"},
+ {"-100", 3, "-13"},
+ {"-100", 100, "-1"},
+ {"4294967296", 0, "4294967296"},
+ {"4294967296", 1, "2147483648"},
+ {"4294967296", 2, "1073741824"},
+ {"18446744073709551616", 0, "18446744073709551616"},
+ {"18446744073709551616", 1, "9223372036854775808"},
+ {"18446744073709551616", 2, "4611686018427387904"},
+ {"18446744073709551616", 64, "1"},
+ {"340282366920938463463374607431768211456", 64, "18446744073709551616"},
+ {"340282366920938463463374607431768211456", 128, "1"},
}
@@ -820,25 +820,25 @@
var lshTests = []intShiftTest{
- intShiftTest{"0", 0, "0"},
- intShiftTest{"0", 1, "0"},
- intShiftTest{"0", 2, "0"},
- intShiftTest{"1", 0, "1"},
- intShiftTest{"1", 1, "2"},
- intShiftTest{"1", 2, "4"},
- intShiftTest{"2", 0, "2"},
- intShiftTest{"2", 1, "4"},
- intShiftTest{"2", 2, "8"},
- intShiftTest{"-87", 1, "-174"},
- intShiftTest{"4294967296", 0, "4294967296"},
- intShiftTest{"4294967296", 1, "8589934592"},
- intShiftTest{"4294967296", 2, "17179869184"},
- intShiftTest{"18446744073709551616", 0, "18446744073709551616"},
- intShiftTest{"9223372036854775808", 1, "18446744073709551616"},
- intShiftTest{"4611686018427387904", 2, "18446744073709551616"},
- intShiftTest{"1", 64, "18446744073709551616"},
- intShiftTest{"18446744073709551616", 64, "340282366920938463463374607431768211456"},
- intShiftTest{"1", 128, "340282366920938463463374607431768211456"},
+ {"0", 0, "0"},
+ {"0", 1, "0"},
+ {"0", 2, "0"},
+ {"1", 0, "1"},
+ {"1", 1, "2"},
+ {"1", 2, "4"},
+ {"2", 0, "2"},
+ {"2", 1, "4"},
+ {"2", 2, "8"},
+ {"-87", 1, "-174"},
+ {"4294967296", 0, "4294967296"},
+ {"4294967296", 1, "8589934592"},
+ {"4294967296", 2, "17179869184"},
+ {"18446744073709551616", 0, "18446744073709551616"},
+ {"9223372036854775808", 1, "18446744073709551616"},
+ {"4611686018427387904", 2, "18446744073709551616"},
+ {"1", 64, "18446744073709551616"},
+ {"18446744073709551616", 64, "340282366920938463463374607431768211456"},
+ {"1", 128, "340282366920938463463374607431768211456"},
}
@@ -934,20 +934,20 @@
}
var bitwiseTests = []bitwiseTest{
- bitwiseTest{"0x00", "0x00", "0x00", "0x00", "0x00", "0x00"},
- bitwiseTest{"0x00", "0x01", "0x00", "0x01", "0x01", "0x00"},
- bitwiseTest{"0x01", "0x00", "0x00", "0x01", "0x01", "0x01"},
- bitwiseTest{"-0x01", "0x00", "0x00", "-0x01", "-0x01", "-0x01"},
- bitwiseTest{"-0xaf", "-0x50", "-0xf0", "-0x0f", "0xe1", "0x41"},
- bitwiseTest{"0x00", "-0x01", "0x00", "-0x01", "-0x01", "0x00"},
- bitwiseTest{"0x01", "0x01", "0x01", "0x01", "0x00", "0x00"},
- bitwiseTest{"-0x01", "-0x01", "-0x01", "-0x01", "0x00", "0x00"},
- bitwiseTest{"0x07", "0x08", "0x00", "0x0f", "0x0f", "0x07"},
- bitwiseTest{"0x05", "0x0f", "0x05", "0x0f", "0x0a", "0x00"},
- bitwiseTest{"0x013ff6", "0x9a4e", "0x1a46", "0x01bffe", "0x01a5b8", "0x0125b0"},
- bitwiseTest{"-0x013ff6", "0x9a4e", "0x800a", "-0x0125b2", "-0x01a5bc", "-0x01c000"},
- bitwiseTest{"-0x013ff6", "-0x9a4e", "-0x01bffe", "-0x1a46", "0x01a5b8", "0x8008"},
- bitwiseTest{
+ {"0x00", "0x00", "0x00", "0x00", "0x00", "0x00"},
+ {"0x00", "0x01", "0x00", "0x01", "0x01", "0x00"},
+ {"0x01", "0x00", "0x00", "0x01", "0x01", "0x01"},
+ {"-0x01", "0x00", "0x00", "-0x01", "-0x01", "-0x01"},
+ {"-0xaf", "-0x50", "-0xf0", "-0x0f", "0xe1", "0x41"},
+ {"0x00", "-0x01", "0x00", "-0x01", "-0x01", "0x00"},
+ {"0x01", "0x01", "0x01", "0x01", "0x00", "0x00"},
+ {"-0x01", "-0x01", "-0x01", "-0x01", "0x00", "0x00"},
+ {"0x07", "0x08", "0x00", "0x0f", "0x0f", "0x07"},
+ {"0x05", "0x0f", "0x05", "0x0f", "0x0a", "0x00"},
+ {"0x013ff6", "0x9a4e", "0x1a46", "0x01bffe", "0x01a5b8", "0x0125b0"},
+ {"-0x013ff6", "0x9a4e", "0x800a", "-0x0125b2", "-0x01a5bc", "-0x01c000"},
+ {"-0x013ff6", "-0x9a4e", "-0x01bffe", "-0x1a46", "0x01a5b8", "0x8008"},
+ {
"0x1000009dc6e3d9822cba04129bcbe3401",
"0xb9bd7d543685789d57cb918e833af352559021483cdb05cc21fd",
"0x1000001186210100001000009048c2001",
@@ -955,7 +955,7 @@
"0xb9bd7d543685789d57ca918e8ae69d6fcdb2eae87df2b97215fc",
"0x8c40c2d8822caa04120b8321400",
},
- bitwiseTest{
+ {
"0x1000009dc6e3d9822cba04129bcbe3401",
"-0xb9bd7d543685789d57cb918e833af352559021483cdb05cc21fd",
"0x8c40c2d8822caa04120b8321401",
@@ -963,7 +963,7 @@
"-0xb9bd7d543685789d57ca918e8ae69d6fcdb2eae87df2b97215fe",
"0x1000001186210100001000009048c2000",
},
- bitwiseTest{
+ {
"-0x1000009dc6e3d9822cba04129bcbe3401",
"-0xb9bd7d543685789d57cb918e833af352559021483cdb05cc21fd",
"-0xb9bd7d543685789d57cb918e8bfeff7fddb2ebe87dfbbdfe35fd",
@@ -1025,12 +1025,12 @@
}
var notTests = []notTest{
- notTest{"0", "-1"},
- notTest{"1", "-2"},
- notTest{"7", "-8"},
- notTest{"0", "-1"},
- notTest{"-81910", "81909"},
- notTest{
+ {"0", "-1"},
+ {"1", "-2"},
+ {"7", "-8"},
+ {"0", "-1"},
+ {"-81910", "81909"},
+ {
"298472983472983471903246121093472394872319615612417471234712061",
"-298472983472983471903246121093472394872319615612417471234712062",
},
@@ -1061,9 +1061,9 @@
}
var modInverseTests = []modInverseTest{
- modInverseTest{"1", "7"},
- modInverseTest{"1", "13"},
- modInverseTest{"239487239847", "2410312426921032588552076022197566074856950548502459942654116941958108831682612228890093858261341614673227141477904012196503648957050582631942730706805009223062734745341073406696246014589361659774041027169249453200378729434170325843778659198143763193776859869524088940195577346119843545301547043747207749969763750084308926339295559968882457872412993810129130294592999947926365264059284647209730384947211681434464714438488520940127459844288859336526896320919633919"},
+ {"1", "7"},
+ {"1", "13"},
+ {"239487239847", "2410312426921032588552076022197566074856950548502459942654116941958108831682612228890093858261341614673227141477904012196503648957050582631942730706805009223062734745341073406696246014589361659774041027169249453200378729434170325843778659198143763193776859869524088940195577346119843545301547043747207749969763750084308926339295559968882457872412993810129130294592999947926365264059284647209730384947211681434464714438488520940127459844288859336526896320919633919"},
}
func TestModInverse(t *testing.T) {