diff --git a/doc/progs/cat_rot13.go b/doc/progs/cat_rot13.go index d2b017bd2c..cfb193609f 100644 --- a/doc/progs/cat_rot13.go +++ b/doc/progs/cat_rot13.go @@ -32,7 +32,7 @@ type rotate13 struct { } func newRotate13(source reader) *rotate13 { - return &rotate13{source} + return &rotate13(source) } func (r13 *rotate13) Read(b []byte) (ret int, err *os.Error) { diff --git a/doc/progs/fd.go b/doc/progs/fd.go index c99c87777a..b686d0b784 100644 --- a/doc/progs/fd.go +++ b/doc/progs/fd.go @@ -18,7 +18,7 @@ func newFD(fd int64, name string) *FD { if fd < 0 { return nil } - return &FD{fd, name} + return &FD(fd, name) } var ( diff --git a/doc/progs/helloworld3.go b/doc/progs/helloworld3.go index 59aebc7213..36624ab53d 100644 --- a/doc/progs/helloworld3.go +++ b/doc/progs/helloworld3.go @@ -7,7 +7,7 @@ package main import fd "fd" func main() { - hello := []byte{'h', 'e', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd', '\n'}; + hello := []byte('h', 'e', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd', '\n'); fd.Stdout.Write(hello); file, err := fd.Open("/does/not/exist", 0, 0); if file == nil { diff --git a/doc/progs/print.go b/doc/progs/print.go index cc146fed8c..5f651d6d83 100644 --- a/doc/progs/print.go +++ b/doc/progs/print.go @@ -12,8 +12,8 @@ func main() { // harder stuff type T struct { a int; b string }; - t := T{77, "Sunset Strip"}; - a := []int{1, 2, 3, 4}; + t := T(77, "Sunset Strip"); + a := []int(1, 2, 3, 4); fmt.Printf("%v %v %v\n", u64, t, a); fmt.Print(u64, " ", t, " ", a, "\n"); fmt.Println(u64, t, a); diff --git a/doc/progs/print_string.go b/doc/progs/print_string.go index 13a8d82418..8150be8948 100644 --- a/doc/progs/print_string.go +++ b/doc/progs/print_string.go @@ -13,6 +13,6 @@ func (t *testType) String() string { } func main() { - t := &testType{77, "Sunset Strip"}; + t := &testType(77, "Sunset Strip"); fmt.Println(t) } diff --git a/doc/progs/sortmain.go b/doc/progs/sortmain.go index 74d1d18408..a945295790 100644 --- a/doc/progs/sortmain.go +++ b/doc/progs/sortmain.go @@ -7,7 +7,7 @@ package main import "sort" func ints() { - data := []int{74, 59, 238, -784, 9845, 959, 905, 0, 0, 42, 7586, -5467984, 7586}; + data := []int(74, 59, 238, -784, 9845, 959, 905, 0, 0, 42, 7586, -5467984, 7586); a := sort.IntArray(data); sort.Sort(a); if !sort.IsSorted(a) { @@ -16,7 +16,7 @@ func ints() { } func strings() { - data := []string{"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"}; + data := []string("monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"); a := sort.StringArray(data); sort.Sort(a); if !sort.IsSorted(a) { @@ -39,15 +39,15 @@ func (p *dayArray) Less(i, j int) bool { return p.data[i].num < p.data[j].num; func (p *dayArray) Swap(i, j int) { p.data[i], p.data[j] = p.data[j], p.data[i]; } func days() { - Sunday := day{ 0, "SUN", "Sunday" }; - Monday := day{ 1, "MON", "Monday" }; - Tuesday := day{ 2, "TUE", "Tuesday" }; - Wednesday := day{ 3, "WED", "Wednesday" }; - Thursday := day{ 4, "THU", "Thursday" }; - Friday := day{ 5, "FRI", "Friday" }; - Saturday := day{ 6, "SAT", "Saturday" }; - data := []*day{&Tuesday, &Thursday, &Sunday, &Monday, &Friday}; - a := dayArray{data}; + Sunday := day( 0, "SUN", "Sunday" ); + Monday := day( 1, "MON", "Monday" ); + Tuesday := day( 2, "TUE", "Tuesday" ); + Wednesday := day( 3, "WED", "Wednesday" ); + Thursday := day( 4, "THU", "Thursday" ); + Friday := day( 5, "FRI", "Friday" ); + Saturday := day( 6, "SAT", "Saturday" ); + data := []*day(&Tuesday, &Thursday, &Sunday, &Monday, &Friday); + a := dayArray(data); sort.Sort(&a); if !sort.IsSorted(&a) { panic() diff --git a/doc/progs/sum.go b/doc/progs/sum.go index 3ca1a58770..0ca7c042ac 100644 --- a/doc/progs/sum.go +++ b/doc/progs/sum.go @@ -14,6 +14,6 @@ func sum(a []int) int { // returns an int func main() { - s := sum([3]int{1,2,3}); // a slice of the array is passed to sum + s := sum([3]int(1,2,3)); // a slice of the array is passed to sum print(s, "\n"); } diff --git a/src/cmd/gotest/gotest b/src/cmd/gotest/gotest index 0ec17322d1..cddbeb0316 100755 --- a/src/cmd/gotest/gotest +++ b/src/cmd/gotest/gotest @@ -71,7 +71,7 @@ trap "rm -f _testmain.go _testmain.6" 0 1 2 3 14 15 echo 'import "testing"' # test array echo - echo 'var tests = []testing.Test {' + echo 'var tests = []testing.Test(' for ofile in $ofiles do # test functions are named TestFoo @@ -84,11 +84,11 @@ trap "rm -f _testmain.go _testmain.6" 0 1 2 3 14 15 else for i in $tests do - echo ' testing.Test{ "'$i'", '$i' },' + echo ' testing.Test( "'$i'", '$i' ),' done fi done - echo '}' + echo ')' # body echo echo 'func main() {' diff --git a/src/lib/bignum.go b/src/lib/bignum.go index 078374ad7e..2ae3a73baf 100755 --- a/src/lib/bignum.go +++ b/src/lib/bignum.go @@ -114,10 +114,10 @@ func Dump(x []Digit) { type Natural []Digit; var ( - natZero Natural = Natural{}; - natOne Natural = Natural{1}; - natTwo Natural = Natural{2}; - natTen Natural = Natural{10}; + natZero Natural = Natural(); + natOne Natural = Natural(1); + natTwo Natural = Natural(2); + natTen Natural = Natural(10); ) @@ -131,7 +131,7 @@ func Nat(x uint) Natural { case 10: return natTen; } assert(Digit(x) < _B); - return Natural{Digit(x)}; + return Natural(Digit(x)); } @@ -818,7 +818,7 @@ func MakeInt(sign bool, mant Natural) *Integer { if mant.IsZero() { sign = false; // normalize } - return &Integer{sign, mant}; + return &Integer(sign, mant); } @@ -1140,7 +1140,7 @@ func MakeRat(a *Integer, b Natural) *Rational { a = MakeInt(a.sign, a.mant.Div(f)); b = b.Div(f); } - return &Rational{a, b}; + return &Rational(a, b); } diff --git a/src/lib/bignum_test.go b/src/lib/bignum_test.go index d8d214dd78..91304c1e0f 100644 --- a/src/lib/bignum_test.go +++ b/src/lib/bignum_test.go @@ -264,16 +264,16 @@ func TestIntQuoRem(t *testing.T) { tester = t; test_msg = "IntQuoRem"; type T struct { x, y, q, r int }; - a := []T{ - T{+8, +3, +2, +2}, - T{+8, -3, -2, +2}, - T{-8, +3, -2, -2}, - T{-8, -3, +2, -2}, - T{+1, +2, 0, +1}, - T{+1, -2, 0, +1}, - T{-1, +2, 0, -1}, - T{-1, -2, 0, -1}, - }; + a := []T( + T(+8, +3, +2, +2), + T(+8, -3, -2, +2), + T(-8, +3, -2, -2), + T(-8, -3, +2, -2), + T(+1, +2, 0, +1), + T(+1, -2, 0, +1), + T(-1, +2, 0, -1), + T(-1, -2, 0, -1), + ); for i := uint(0); i < uint(len(a)); i++ { e := &a[i]; x, y := bignum.Int(e.x).Mul(ip), bignum.Int(e.y).Mul(ip); @@ -291,16 +291,16 @@ func TestIntDivMod(t *testing.T) { tester = t; test_msg = "IntDivMod"; type T struct { x, y, q, r int }; - a := []T{ - T{+8, +3, +2, +2}, - T{+8, -3, -2, +2}, - T{-8, +3, -3, +1}, - T{-8, -3, +3, +1}, - T{+1, +2, 0, +1}, - T{+1, -2, 0, +1}, - T{-1, +2, -1, +1}, - T{-1, -2, +1, +1}, - }; + a := []T( + T(+8, +3, +2, +2), + T(+8, -3, -2, +2), + T(-8, +3, -3, +1), + T(-8, -3, +3, +1), + T(+1, +2, 0, +1), + T(+1, -2, 0, +1), + T(-1, +2, -1, +1), + T(-1, -2, +1, +1), + ); for i := uint(0); i < uint(len(a)); i++ { e := &a[i]; x, y := bignum.Int(e.x).Mul(ip), bignum.Int(e.y).Mul(ip); diff --git a/src/lib/bufio.go b/src/lib/bufio.go index 9f36885885..fd3267fd44 100644 --- a/src/lib/bufio.go +++ b/src/lib/bufio.go @@ -477,6 +477,6 @@ type BufReadWrite struct { } func NewBufReadWrite(r *BufRead, w *BufWrite) *BufReadWrite { - return &BufReadWrite{r, w} + return &BufReadWrite(r, w) } diff --git a/src/lib/bufio_test.go b/src/lib/bufio_test.go index 9ffd6cbfd4..fe8698b00d 100644 --- a/src/lib/bufio_test.go +++ b/src/lib/bufio_test.go @@ -98,10 +98,10 @@ type readMaker struct { name string; fn func([]byte) io.Read; } -var readMakers = []readMaker { - readMaker{ "full", func(p []byte) io.Read { return newByteReader(p) } }, - readMaker{ "half", func(p []byte) io.Read { return newHalfByteReader(p) } }, -} +var readMakers = []readMaker ( + readMaker( "full", func(p []byte) io.Read { return newByteReader(p) } ), + readMaker( "half", func(p []byte) io.Read { return newHalfByteReader(p) } ), +) // Call ReadLineString (which ends up calling everything else) // to accumulate the text of a file. @@ -157,21 +157,21 @@ type bufReader struct { name string; fn func(*BufRead) string; } -var bufreaders = []bufReader { - bufReader{ "1", func(b *BufRead) string { return reads(b, 1) } }, - bufReader{ "2", func(b *BufRead) string { return reads(b, 2) } }, - bufReader{ "3", func(b *BufRead) string { return reads(b, 3) } }, - bufReader{ "4", func(b *BufRead) string { return reads(b, 4) } }, - bufReader{ "5", func(b *BufRead) string { return reads(b, 5) } }, - bufReader{ "7", func(b *BufRead) string { return reads(b, 7) } }, - bufReader{ "bytes", readBytes }, - bufReader{ "lines", readLines }, -} +var bufreaders = []bufReader ( + bufReader( "1", func(b *BufRead) string { return reads(b, 1) } ), + bufReader( "2", func(b *BufRead) string { return reads(b, 2) } ), + bufReader( "3", func(b *BufRead) string { return reads(b, 3) } ), + bufReader( "4", func(b *BufRead) string { return reads(b, 4) } ), + bufReader( "5", func(b *BufRead) string { return reads(b, 5) } ), + bufReader( "7", func(b *BufRead) string { return reads(b, 7) } ), + bufReader( "bytes", readBytes ), + bufReader( "lines", readLines ), +) -var bufsizes = []int { +var bufsizes = []int ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 23, 32, 46, 64, 93, 128, 1024, 4096 -} +) func TestBufReadSimple(t *testing.T) { b := NewBufRead(newByteReader(io.StringBytes("hello world"))); @@ -281,10 +281,10 @@ type writeMaker struct { func TestBufWrite(t *testing.T) { var data [8192]byte; - var writers = []writeMaker { - writeMaker{ "full", newByteWriter }, - writeMaker{ "half", newHalfByteWriter }, - }; + var writers = []writeMaker ( + writeMaker( "full", newByteWriter ), + writeMaker( "half", newHalfByteWriter ), + ); for i := 0; i < len(data); i++ { data[i] = byte(' '+ i%('~'-' ')); diff --git a/src/lib/flag.go b/src/lib/flag.go index 19d3e2ebfb..35e18f9e66 100644 --- a/src/lib/flag.go +++ b/src/lib/flag.go @@ -112,7 +112,7 @@ type boolValue struct { func newBoolValue(val bool, p *bool) *boolValue { *p = val; - return &boolValue{p} + return &boolValue(p) } func (b *boolValue) set(val bool) { @@ -130,7 +130,7 @@ type intValue struct { func newIntValue(val int, p *int) *intValue { *p = val; - return &intValue{p} + return &intValue(p) } func (i *intValue) set(val int) { @@ -148,7 +148,7 @@ type int64Value struct { func newInt64Value(val int64, p *int64) *int64Value { *p = val; - return &int64Value{p} + return &int64Value(p) } func (i *int64Value) set(val int64) { @@ -166,7 +166,7 @@ type uintValue struct { func newUintValue(val uint, p *uint) *uintValue { *p = val; - return &uintValue{p} + return &uintValue(p) } func (i *uintValue) set(val uint) { @@ -184,7 +184,7 @@ type uint64Value struct { func newUint64Value(val uint64, p *uint64) *uint64Value { *p = val; - return &uint64Value{p} + return &uint64Value(p) } func (i *uint64Value) set(val uint64) { @@ -202,7 +202,7 @@ type stringValue struct { func newStringValue(val string, p *string) *stringValue { *p = val; - return &stringValue{p} + return &stringValue(p) } func (s *stringValue) set(val string) { @@ -232,7 +232,7 @@ type allFlags struct { first_arg int; // 0 is the program name, 1 is first arg } -var flags *allFlags = &allFlags{make(map[string] *Flag), make(map[string] *Flag), 1} +var flags *allFlags = &allFlags(make(map[string] *Flag), make(map[string] *Flag), 1) func PrintDefaults() { for k, f := range flags.formal { diff --git a/src/lib/fmt/fmt_test.go b/src/lib/fmt/fmt_test.go index 8cafcd159a..6541ee0dd4 100644 --- a/src/lib/fmt/fmt_test.go +++ b/src/lib/fmt/fmt_test.go @@ -29,127 +29,127 @@ type fmtTest struct { const b32 uint32 = 1<<32 - 1 const b64 uint64 = 1<<64 - 1 -var array = []int{1, 2, 3, 4, 5} +var array = []int(1, 2, 3, 4, 5) -var fmttests = []fmtTest{ +var fmttests = []fmtTest( // basic string - fmtTest{ "%s", "abc", "abc" }, - fmtTest{ "%x", "abc", "616263" }, - fmtTest{ "%x", "xyz", "78797a" }, - fmtTest{ "%X", "xyz", "78797A" }, - fmtTest{ "%q", "abc", `"abc"` }, + fmtTest( "%s", "abc", "abc" ), + fmtTest( "%x", "abc", "616263" ), + fmtTest( "%x", "xyz", "78797a" ), + fmtTest( "%X", "xyz", "78797A" ), + fmtTest( "%q", "abc", `"abc"` ), // basic bytes - fmtTest{ "%s", io.StringBytes("abc"), "abc" }, - fmtTest{ "%x", io.StringBytes("abc"), "616263" }, - fmtTest{ "% x", io.StringBytes("abc"), "61 62 63" }, - fmtTest{ "%x", io.StringBytes("xyz"), "78797a" }, - fmtTest{ "%X", io.StringBytes("xyz"), "78797A" }, - fmtTest{ "%q", io.StringBytes("abc"), `"abc"` }, + fmtTest( "%s", io.StringBytes("abc"), "abc" ), + fmtTest( "%x", io.StringBytes("abc"), "616263" ), + fmtTest( "% x", io.StringBytes("abc"), "61 62 63" ), + fmtTest( "%x", io.StringBytes("xyz"), "78797a" ), + fmtTest( "%X", io.StringBytes("xyz"), "78797A" ), + fmtTest( "%q", io.StringBytes("abc"), `"abc"` ), // escaped strings - fmtTest{ "%#q", `abc`, "`abc`" }, - fmtTest{ "%#q", `"`, "`\"`" }, - fmtTest{ "1 %#q", `\n`, "1 `\\n`" }, - fmtTest{ "2 %#q", "\n", `2 "\n"` }, - fmtTest{ "%q", `"`, `"\""` }, - fmtTest{ "%q", "\a\b\f\r\n\t\v", `"\a\b\f\r\n\t\v"` }, - fmtTest{ "%q", "abc\xffdef", `"abc\xffdef"` }, - fmtTest{ "%q", "\u263a", `"\u263a"` }, - fmtTest{ "%q", "\U0010ffff", `"\U0010ffff"` }, + fmtTest( "%#q", `abc`, "`abc`" ), + fmtTest( "%#q", `"`, "`\"`" ), + fmtTest( "1 %#q", `\n`, "1 `\\n`" ), + fmtTest( "2 %#q", "\n", `2 "\n"` ), + fmtTest( "%q", `"`, `"\""` ), + fmtTest( "%q", "\a\b\f\r\n\t\v", `"\a\b\f\r\n\t\v"` ), + fmtTest( "%q", "abc\xffdef", `"abc\xffdef"` ), + fmtTest( "%q", "\u263a", `"\u263a"` ), + fmtTest( "%q", "\U0010ffff", `"\U0010ffff"` ), // width - fmtTest{ "%5s", "abc", " abc" }, - fmtTest{ "%-5s", "abc", "abc " }, - fmtTest{ "%05s", "abc", "00abc" }, + fmtTest( "%5s", "abc", " abc" ), + fmtTest( "%-5s", "abc", "abc " ), + fmtTest( "%05s", "abc", "00abc" ), // integers - fmtTest{ "%d", 12345, "12345" }, - fmtTest{ "%d", -12345, "-12345" }, - fmtTest{ "%10d", 12345, " 12345" }, - fmtTest{ "%10d", -12345, " -12345" }, - fmtTest{ "%+10d", 12345, " +12345" }, - fmtTest{ "%010d", 12345, "0000012345" }, - fmtTest{ "%010d", -12345, "-000012345" }, - fmtTest{ "%-10d", 12345, "12345 " }, - fmtTest{ "%010.3d", 1, " 001" }, - fmtTest{ "%010.3d", -1, " -001" }, - fmtTest{ "%+d", 12345, "+12345" }, - fmtTest{ "%+d", -12345, "-12345" }, - fmtTest{ "% d", 12345, " 12345" }, - fmtTest{ "% d", -12345, "-12345" }, + fmtTest( "%d", 12345, "12345" ), + fmtTest( "%d", -12345, "-12345" ), + fmtTest( "%10d", 12345, " 12345" ), + fmtTest( "%10d", -12345, " -12345" ), + fmtTest( "%+10d", 12345, " +12345" ), + fmtTest( "%010d", 12345, "0000012345" ), + fmtTest( "%010d", -12345, "-000012345" ), + fmtTest( "%-10d", 12345, "12345 " ), + fmtTest( "%010.3d", 1, " 001" ), + fmtTest( "%010.3d", -1, " -001" ), + fmtTest( "%+d", 12345, "+12345" ), + fmtTest( "%+d", -12345, "-12345" ), + fmtTest( "% d", 12345, " 12345" ), + fmtTest( "% d", -12345, "-12345" ), // arrays // TODO: when arrays work in interfaces, enable this line // and delete the TestArrayPrinter routine below // fmtTest{ "%v", array, "[1 2 3 4 5]" }, - fmtTest{ "%v", &array, "&[1 2 3 4 5]" }, + fmtTest( "%v", &array, "&[1 2 3 4 5]" ), // old test/fmt_test.go - fmtTest{ "%d", 1234, "1234" }, - fmtTest{ "%d", -1234, "-1234" }, - fmtTest{ "%d", uint(1234), "1234" }, - fmtTest{ "%d", uint32(b32), "4294967295" }, - fmtTest{ "%d", uint64(b64), "18446744073709551615" }, - fmtTest{ "%o", 01234, "1234" }, - fmtTest{ "%o", uint32(b32), "37777777777" }, - fmtTest{ "%o", uint64(b64), "1777777777777777777777" }, - fmtTest{ "%x", 0x1234abcd, "1234abcd" }, - fmtTest{ "%x", b32-0x1234567, "fedcba98" }, - fmtTest{ "%X", 0x1234abcd, "1234ABCD" }, - fmtTest{ "%X", b32-0x1234567, "FEDCBA98" }, - fmtTest{ "%x", b64, "ffffffffffffffff" }, - fmtTest{ "%b", 7, "111" }, - fmtTest{ "%b", b64, "1111111111111111111111111111111111111111111111111111111111111111" }, - fmtTest{ "%e", float64(1), "1.000000e+00" }, - fmtTest{ "%e", float64(1234.5678e3), "1.234568e+06" }, - fmtTest{ "%e", float64(1234.5678e-8), "1.234568e-05" }, - fmtTest{ "%e", float64(-7), "-7.000000e+00" }, - fmtTest{ "%e", float64(-1e-9), "-1.000000e-09" }, - fmtTest{ "%f", float64(1234.5678e3), "1234567.800000" }, - fmtTest{ "%f", float64(1234.5678e-8), "0.000012" }, - fmtTest{ "%f", float64(-7), "-7.000000" }, - fmtTest{ "%f", float64(-1e-9), "-0.000000" }, - fmtTest{ "%g", float64(1234.5678e3), "1.2345678e+06" }, - fmtTest{ "%g", float32(1234.5678e3), "1.2345678e+06" }, - fmtTest{ "%g", float64(1234.5678e-8), "1.2345678e-05" }, - fmtTest{ "%g", float64(-7), "-7" }, - fmtTest{ "%g", float64(-1e-9), "-1e-09", }, - fmtTest{ "%g", float32(-1e-9), "-1e-09" }, - fmtTest{ "%c", 'x', "x" }, - fmtTest{ "%c", 0xe4, "ä" }, - fmtTest{ "%c", 0x672c, "本" }, - fmtTest{ "%c", '日', "日" }, - fmtTest{ "%20.8d", 1234, " 00001234" }, - fmtTest{ "%20.8d", -1234, " -00001234" }, - fmtTest{ "%20d", 1234, " 1234" }, - fmtTest{ "%-20.8d", 1234, "00001234 " }, - fmtTest{ "%-20.8d", -1234, "-00001234 " }, - fmtTest{ "%.20b", 7, "00000000000000000111" }, - fmtTest{ "%20.5s", "qwertyuiop", " qwert" }, - fmtTest{ "%.5s", "qwertyuiop", "qwert" }, - fmtTest{ "%-20.5s", "qwertyuiop", "qwert " }, - fmtTest{ "%20c", 'x', " x" }, - fmtTest{ "%-20c", 'x', "x " }, - fmtTest{ "%20.6e", 1.2345e3, " 1.234500e+03" }, - fmtTest{ "%20.6e", 1.2345e-3, " 1.234500e-03" }, - fmtTest{ "%20e", 1.2345e3, " 1.234500e+03" }, - fmtTest{ "%20e", 1.2345e-3, " 1.234500e-03" }, - fmtTest{ "%20.8e", 1.2345e3, " 1.23450000e+03" }, - fmtTest{ "%20f", float64(1.23456789e3), " 1234.567890" }, - fmtTest{ "%20f", float64(1.23456789e-3), " 0.001235" }, - fmtTest{ "%20f", float64(12345678901.23456789), " 12345678901.234568" }, - fmtTest{ "%-20f", float64(1.23456789e3), "1234.567890 " }, - fmtTest{ "%20.8f", float64(1.23456789e3), " 1234.56789000" }, - fmtTest{ "%20.8f", float64(1.23456789e-3), " 0.00123457" }, - fmtTest{ "%g", float64(1.23456789e3), "1234.56789" }, - fmtTest{ "%g", float64(1.23456789e-3), "0.00123456789" }, - fmtTest{ "%g", float64(1.23456789e20), "1.23456789e+20" }, - fmtTest{ "%20e", math.Inf(1), " +Inf" }, - fmtTest{ "%-20f", math.Inf(-1), "-Inf " }, - fmtTest{ "%20g", math.NaN(), " NaN" }, -} + fmtTest( "%d", 1234, "1234" ), + fmtTest( "%d", -1234, "-1234" ), + fmtTest( "%d", uint(1234), "1234" ), + fmtTest( "%d", uint32(b32), "4294967295" ), + fmtTest( "%d", uint64(b64), "18446744073709551615" ), + fmtTest( "%o", 01234, "1234" ), + fmtTest( "%o", uint32(b32), "37777777777" ), + fmtTest( "%o", uint64(b64), "1777777777777777777777" ), + fmtTest( "%x", 0x1234abcd, "1234abcd" ), + fmtTest( "%x", b32-0x1234567, "fedcba98" ), + fmtTest( "%X", 0x1234abcd, "1234ABCD" ), + fmtTest( "%X", b32-0x1234567, "FEDCBA98" ), + fmtTest( "%x", b64, "ffffffffffffffff" ), + fmtTest( "%b", 7, "111" ), + fmtTest( "%b", b64, "1111111111111111111111111111111111111111111111111111111111111111" ), + fmtTest( "%e", float64(1), "1.000000e+00" ), + fmtTest( "%e", float64(1234.5678e3), "1.234568e+06" ), + fmtTest( "%e", float64(1234.5678e-8), "1.234568e-05" ), + fmtTest( "%e", float64(-7), "-7.000000e+00" ), + fmtTest( "%e", float64(-1e-9), "-1.000000e-09" ), + fmtTest( "%f", float64(1234.5678e3), "1234567.800000" ), + fmtTest( "%f", float64(1234.5678e-8), "0.000012" ), + fmtTest( "%f", float64(-7), "-7.000000" ), + fmtTest( "%f", float64(-1e-9), "-0.000000" ), + fmtTest( "%g", float64(1234.5678e3), "1.2345678e+06" ), + fmtTest( "%g", float32(1234.5678e3), "1.2345678e+06" ), + fmtTest( "%g", float64(1234.5678e-8), "1.2345678e-05" ), + fmtTest( "%g", float64(-7), "-7" ), + fmtTest( "%g", float64(-1e-9), "-1e-09", ), + fmtTest( "%g", float32(-1e-9), "-1e-09" ), + fmtTest( "%c", 'x', "x" ), + fmtTest( "%c", 0xe4, "ä" ), + fmtTest( "%c", 0x672c, "本" ), + fmtTest( "%c", '日', "日" ), + fmtTest( "%20.8d", 1234, " 00001234" ), + fmtTest( "%20.8d", -1234, " -00001234" ), + fmtTest( "%20d", 1234, " 1234" ), + fmtTest( "%-20.8d", 1234, "00001234 " ), + fmtTest( "%-20.8d", -1234, "-00001234 " ), + fmtTest( "%.20b", 7, "00000000000000000111" ), + fmtTest( "%20.5s", "qwertyuiop", " qwert" ), + fmtTest( "%.5s", "qwertyuiop", "qwert" ), + fmtTest( "%-20.5s", "qwertyuiop", "qwert " ), + fmtTest( "%20c", 'x', " x" ), + fmtTest( "%-20c", 'x', "x " ), + fmtTest( "%20.6e", 1.2345e3, " 1.234500e+03" ), + fmtTest( "%20.6e", 1.2345e-3, " 1.234500e-03" ), + fmtTest( "%20e", 1.2345e3, " 1.234500e+03" ), + fmtTest( "%20e", 1.2345e-3, " 1.234500e-03" ), + fmtTest( "%20.8e", 1.2345e3, " 1.23450000e+03" ), + fmtTest( "%20f", float64(1.23456789e3), " 1234.567890" ), + fmtTest( "%20f", float64(1.23456789e-3), " 0.001235" ), + fmtTest( "%20f", float64(12345678901.23456789), " 12345678901.234568" ), + fmtTest( "%-20f", float64(1.23456789e3), "1234.567890 " ), + fmtTest( "%20.8f", float64(1.23456789e3), " 1234.56789000" ), + fmtTest( "%20.8f", float64(1.23456789e-3), " 0.00123457" ), + fmtTest( "%g", float64(1.23456789e3), "1234.56789" ), + fmtTest( "%g", float64(1.23456789e-3), "0.00123456789" ), + fmtTest( "%g", float64(1.23456789e20), "1.23456789e+20" ), + fmtTest( "%20e", math.Inf(1), " +Inf" ), + fmtTest( "%-20f", math.Inf(-1), "-Inf " ), + fmtTest( "%20g", math.NaN(), " NaN" ), +) func TestSprintf(t *testing.T) { for i := 0; i < len(fmttests); i++ { @@ -190,20 +190,20 @@ type flagTest struct { out string; } -var flagtests = []flagTest { - flagTest{ "%a", "[%a]" }, - flagTest{ "%-a", "[%-a]" }, - flagTest{ "%+a", "[%+a]" }, - flagTest{ "%#a", "[%#a]" }, - flagTest{ "% a", "[% a]" }, - flagTest{ "%0a", "[%0a]" }, - flagTest{ "%1.2a", "[%1.2a]" }, - flagTest{ "%-1.2a", "[%-1.2a]" }, - flagTest{ "%+1.2a", "[%+1.2a]" }, - flagTest{ "%-+1.2a", "[%+-1.2a]" }, - flagTest{ "%-+1.2abc", "[%+-1.2a]bc" }, - flagTest{ "%-1.2abc", "[%-1.2a]bc" }, -} +var flagtests = []flagTest ( + flagTest( "%a", "[%a]" ), + flagTest( "%-a", "[%-a]" ), + flagTest( "%+a", "[%+a]" ), + flagTest( "%#a", "[%#a]" ), + flagTest( "% a", "[% a]" ), + flagTest( "%0a", "[%0a]" ), + flagTest( "%1.2a", "[%1.2a]" ), + flagTest( "%-1.2a", "[%-1.2a]" ), + flagTest( "%+1.2a", "[%+1.2a]" ), + flagTest( "%-+1.2a", "[%+-1.2a]" ), + flagTest( "%-+1.2abc", "[%+-1.2a]bc" ), + flagTest( "%-1.2abc", "[%-1.2a]bc" ), +) func TestFlagParser(t *testing.T) { var flagprinter flagPrinter; @@ -229,10 +229,10 @@ func TestStructPrinter(t *testing.T) { fmt string; out string; } - var tests = []Test { - Test{ "%v", "{abc def 123}" }, - Test{ "%+v", "{a=abc b=def c=123}" }, - }; + var tests = []Test ( + Test( "%v", "{abc def 123}" ), + Test( "%+v", "{a=abc b=def c=123}" ), + ); for i := 0; i < len(tests); i++ { tt := tests[i]; out := fmt.Sprintf(tt.fmt, s); @@ -243,7 +243,7 @@ func TestStructPrinter(t *testing.T) { } func TestArrayPrinter(t *testing.T) { - a := []int{1, 2, 3, 4, 5}; + a := []int(1, 2, 3, 4, 5); want := "[1 2 3 4 5]"; out := fmt.Sprintf("%v", a); if out != want { diff --git a/src/lib/hash/adler32.go b/src/lib/hash/adler32.go index 07818992ea..9bfca550b6 100644 --- a/src/lib/hash/adler32.go +++ b/src/lib/hash/adler32.go @@ -25,7 +25,7 @@ const ( ) func NewDigest() *Digest { - return &Digest{1, 0, 0}; + return &Digest(1, 0, 0); } func (d *Digest) Write(p []byte) (nn int, err *os.Error) { diff --git a/src/lib/hash/adler32_test.go b/src/lib/hash/adler32_test.go index 97b918f131..aecf90c746 100644 --- a/src/lib/hash/adler32_test.go +++ b/src/lib/hash/adler32_test.go @@ -15,39 +15,39 @@ type _Adler32Test struct { in string; } -var golden = []_Adler32Test { - _Adler32Test{ 0x1, "" }, - _Adler32Test{ 0x620062, "a" }, - _Adler32Test{ 0x12600c4, "ab" }, - _Adler32Test{ 0x24d0127, "abc" }, - _Adler32Test{ 0x3d8018b, "abcd" }, - _Adler32Test{ 0x5c801f0, "abcde" }, - _Adler32Test{ 0x81e0256, "abcdef" }, - _Adler32Test{ 0xadb02bd, "abcdefg" }, - _Adler32Test{ 0xe000325, "abcdefgh" }, - _Adler32Test{ 0x118e038e, "abcdefghi" }, - _Adler32Test{ 0x158603f8, "abcdefghij" }, - _Adler32Test{ 0x3f090f02, "Discard medicine more than two years old." }, - _Adler32Test{ 0x46d81477, "He who has a shady past knows that nice guys finish last." }, - _Adler32Test{ 0x40ee0ee1, "I wouldn't marry him with a ten foot pole." }, - _Adler32Test{ 0x16661315, "Free! Free!/A trip/to Mars/for 900/empty jars/Burma Shave" }, - _Adler32Test{ 0x5b2e1480, "The days of the digital watch are numbered. -Tom Stoppard" }, - _Adler32Test{ 0x8c3c09ea, "Nepal premier won't resign." }, - _Adler32Test{ 0x45ac18fd, "For every action there is an equal and opposite government program." }, - _Adler32Test{ 0x53c61462, "His money is twice tainted: 'taint yours and 'taint mine." }, - _Adler32Test{ 0x7e511e63, "There is no reason for any individual to have a computer in their home. -Ken Olsen, 1977" }, - _Adler32Test{ 0xe4801a6a, "It's a tiny change to the code and not completely disgusting. - Bob Manchek" }, - _Adler32Test{ 0x61b507df, "size: a.out: bad magic" }, - _Adler32Test{ 0xb8631171, "The major problem is with sendmail. -Mark Horton" }, - _Adler32Test{ 0x8b5e1904, "Give me a rock, paper and scissors and I will move the world. CCFestoon" }, - _Adler32Test{ 0x7cc6102b, "If the enemy is within range, then so are you." }, - _Adler32Test{ 0x700318e7, "It's well we cannot hear the screams/That we create in others' dreams." }, - _Adler32Test{ 0x1e601747, "You remind me of a TV show, but that's all right: I watch it anyway." }, - _Adler32Test{ 0xb55b0b09, "C is as portable as Stonehedge!!" }, - _Adler32Test{ 0x39111dd0, "Even if I could be Shakespeare, I think I should still choose to be Faraday. - A. Huxley" }, - _Adler32Test{ 0x91dd304f, "The fugacity of a constituent in a mixture of gases at a given temperature is proportional to its mole fraction. Lewis-Randall Rule" }, - _Adler32Test{ 0x2e5d1316, "How can you write a big system without C++? -Paul Glick" }, -} +var golden = []_Adler32Test ( + _Adler32Test( 0x1, "" ), + _Adler32Test( 0x620062, "a" ), + _Adler32Test( 0x12600c4, "ab" ), + _Adler32Test( 0x24d0127, "abc" ), + _Adler32Test( 0x3d8018b, "abcd" ), + _Adler32Test( 0x5c801f0, "abcde" ), + _Adler32Test( 0x81e0256, "abcdef" ), + _Adler32Test( 0xadb02bd, "abcdefg" ), + _Adler32Test( 0xe000325, "abcdefgh" ), + _Adler32Test( 0x118e038e, "abcdefghi" ), + _Adler32Test( 0x158603f8, "abcdefghij" ), + _Adler32Test( 0x3f090f02, "Discard medicine more than two years old." ), + _Adler32Test( 0x46d81477, "He who has a shady past knows that nice guys finish last." ), + _Adler32Test( 0x40ee0ee1, "I wouldn't marry him with a ten foot pole." ), + _Adler32Test( 0x16661315, "Free! Free!/A trip/to Mars/for 900/empty jars/Burma Shave" ), + _Adler32Test( 0x5b2e1480, "The days of the digital watch are numbered. -Tom Stoppard" ), + _Adler32Test( 0x8c3c09ea, "Nepal premier won't resign." ), + _Adler32Test( 0x45ac18fd, "For every action there is an equal and opposite government program." ), + _Adler32Test( 0x53c61462, "His money is twice tainted: 'taint yours and 'taint mine." ), + _Adler32Test( 0x7e511e63, "There is no reason for any individual to have a computer in their home. -Ken Olsen, 1977" ), + _Adler32Test( 0xe4801a6a, "It's a tiny change to the code and not completely disgusting. - Bob Manchek" ), + _Adler32Test( 0x61b507df, "size: a.out: bad magic" ), + _Adler32Test( 0xb8631171, "The major problem is with sendmail. -Mark Horton" ), + _Adler32Test( 0x8b5e1904, "Give me a rock, paper and scissors and I will move the world. CCFestoon" ), + _Adler32Test( 0x7cc6102b, "If the enemy is within range, then so are you." ), + _Adler32Test( 0x700318e7, "It's well we cannot hear the screams/That we create in others' dreams." ), + _Adler32Test( 0x1e601747, "You remind me of a TV show, but that's all right: I watch it anyway." ), + _Adler32Test( 0xb55b0b09, "C is as portable as Stonehedge!!" ), + _Adler32Test( 0x39111dd0, "Even if I could be Shakespeare, I think I should still choose to be Faraday. - A. Huxley" ), + _Adler32Test( 0x91dd304f, "The fugacity of a constituent in a mixture of gases at a given temperature is proportional to its mole fraction. Lewis-Randall Rule" ), + _Adler32Test( 0x2e5d1316, "How can you write a big system without C++? -Paul Glick" ), +) func TestGolden(t *testing.T) { for i := 0; i < len(golden); i++ { diff --git a/src/lib/hash/crc32.go b/src/lib/hash/crc32.go index 7bfca39d3f..02b2d6cabe 100644 --- a/src/lib/hash/crc32.go +++ b/src/lib/hash/crc32.go @@ -52,7 +52,7 @@ type Digest struct { } func NewDigest(tab Table) *Digest { - return &Digest{0, tab}; + return &Digest(0, tab); } func NewIEEEDigest() *Digest { diff --git a/src/lib/hash/crc32_test.go b/src/lib/hash/crc32_test.go index a2a37cf4ac..e827ccc6d5 100644 --- a/src/lib/hash/crc32_test.go +++ b/src/lib/hash/crc32_test.go @@ -15,39 +15,39 @@ type _Crc32Test struct { in string; } -var golden = []_Crc32Test { - _Crc32Test{ 0x0, "" }, - _Crc32Test{ 0xe8b7be43, "a" }, - _Crc32Test{ 0x9e83486d, "ab" }, - _Crc32Test{ 0x352441c2, "abc" }, - _Crc32Test{ 0xed82cd11, "abcd" }, - _Crc32Test{ 0x8587d865, "abcde" }, - _Crc32Test{ 0x4b8e39ef, "abcdef" }, - _Crc32Test{ 0x312a6aa6, "abcdefg" }, - _Crc32Test{ 0xaeef2a50, "abcdefgh" }, - _Crc32Test{ 0x8da988af, "abcdefghi" }, - _Crc32Test{ 0x3981703a, "abcdefghij" }, - _Crc32Test{ 0x6b9cdfe7, "Discard medicine more than two years old." }, - _Crc32Test{ 0xc90ef73f, "He who has a shady past knows that nice guys finish last." }, - _Crc32Test{ 0xb902341f, "I wouldn't marry him with a ten foot pole." }, - _Crc32Test{ 0x42080e8, "Free! Free!/A trip/to Mars/for 900/empty jars/Burma Shave" }, - _Crc32Test{ 0x154c6d11, "The days of the digital watch are numbered. -Tom Stoppard" }, - _Crc32Test{ 0x4c418325, "Nepal premier won't resign." }, - _Crc32Test{ 0x33955150, "For every action there is an equal and opposite government program." }, - _Crc32Test{ 0x26216a4b, "His money is twice tainted: 'taint yours and 'taint mine." }, - _Crc32Test{ 0x1abbe45e, "There is no reason for any individual to have a computer in their home. -Ken Olsen, 1977" }, - _Crc32Test{ 0xc89a94f7, "It's a tiny change to the code and not completely disgusting. - Bob Manchek" }, - _Crc32Test{ 0xab3abe14, "size: a.out: bad magic" }, - _Crc32Test{ 0xbab102b6, "The major problem is with sendmail. -Mark Horton" }, - _Crc32Test{ 0x999149d7, "Give me a rock, paper and scissors and I will move the world. CCFestoon" }, - _Crc32Test{ 0x6d52a33c, "If the enemy is within range, then so are you." }, - _Crc32Test{ 0x90631e8d, "It's well we cannot hear the screams/That we create in others' dreams." }, - _Crc32Test{ 0x78309130, "You remind me of a TV show, but that's all right: I watch it anyway." }, - _Crc32Test{ 0x7d0a377f, "C is as portable as Stonehedge!!" }, - _Crc32Test{ 0x8c79fd79, "Even if I could be Shakespeare, I think I should still choose to be Faraday. - A. Huxley" }, - _Crc32Test{ 0xa20b7167, "The fugacity of a constituent in a mixture of gases at a given temperature is proportional to its mole fraction. Lewis-Randall Rule" }, - _Crc32Test{ 0x8e0bb443, "How can you write a big system without C++? -Paul Glick" }, -} +var golden = []_Crc32Test ( + _Crc32Test( 0x0, "" ), + _Crc32Test( 0xe8b7be43, "a" ), + _Crc32Test( 0x9e83486d, "ab" ), + _Crc32Test( 0x352441c2, "abc" ), + _Crc32Test( 0xed82cd11, "abcd" ), + _Crc32Test( 0x8587d865, "abcde" ), + _Crc32Test( 0x4b8e39ef, "abcdef" ), + _Crc32Test( 0x312a6aa6, "abcdefg" ), + _Crc32Test( 0xaeef2a50, "abcdefgh" ), + _Crc32Test( 0x8da988af, "abcdefghi" ), + _Crc32Test( 0x3981703a, "abcdefghij" ), + _Crc32Test( 0x6b9cdfe7, "Discard medicine more than two years old." ), + _Crc32Test( 0xc90ef73f, "He who has a shady past knows that nice guys finish last." ), + _Crc32Test( 0xb902341f, "I wouldn't marry him with a ten foot pole." ), + _Crc32Test( 0x42080e8, "Free! Free!/A trip/to Mars/for 900/empty jars/Burma Shave" ), + _Crc32Test( 0x154c6d11, "The days of the digital watch are numbered. -Tom Stoppard" ), + _Crc32Test( 0x4c418325, "Nepal premier won't resign." ), + _Crc32Test( 0x33955150, "For every action there is an equal and opposite government program." ), + _Crc32Test( 0x26216a4b, "His money is twice tainted: 'taint yours and 'taint mine." ), + _Crc32Test( 0x1abbe45e, "There is no reason for any individual to have a computer in their home. -Ken Olsen, 1977" ), + _Crc32Test( 0xc89a94f7, "It's a tiny change to the code and not completely disgusting. - Bob Manchek" ), + _Crc32Test( 0xab3abe14, "size: a.out: bad magic" ), + _Crc32Test( 0xbab102b6, "The major problem is with sendmail. -Mark Horton" ), + _Crc32Test( 0x999149d7, "Give me a rock, paper and scissors and I will move the world. CCFestoon" ), + _Crc32Test( 0x6d52a33c, "If the enemy is within range, then so are you." ), + _Crc32Test( 0x90631e8d, "It's well we cannot hear the screams/That we create in others' dreams." ), + _Crc32Test( 0x78309130, "You remind me of a TV show, but that's all right: I watch it anyway." ), + _Crc32Test( 0x7d0a377f, "C is as portable as Stonehedge!!" ), + _Crc32Test( 0x8c79fd79, "Even if I could be Shakespeare, I think I should still choose to be Faraday. - A. Huxley" ), + _Crc32Test( 0xa20b7167, "The fugacity of a constituent in a mixture of gases at a given temperature is proportional to its mole fraction. Lewis-Randall Rule" ), + _Crc32Test( 0x8e0bb443, "How can you write a big system without C++? -Paul Glick" ), +) func TestGolden(t *testing.T) { for i := 0; i < len(golden); i++ { diff --git a/src/lib/hash/md5_test.go b/src/lib/hash/md5_test.go index 6410346944..b6724fb591 100644 --- a/src/lib/hash/md5_test.go +++ b/src/lib/hash/md5_test.go @@ -16,39 +16,39 @@ type md5Test struct { in string; } -var golden = []md5Test { - md5Test{ "d41d8cd98f00b204e9800998ecf8427e", "" }, - md5Test{ "0cc175b9c0f1b6a831c399e269772661", "a" }, - md5Test{ "187ef4436122d1cc2f40dc2b92f0eba0", "ab" }, - md5Test{ "900150983cd24fb0d6963f7d28e17f72", "abc" }, - md5Test{ "e2fc714c4727ee9395f324cd2e7f331f", "abcd" }, - md5Test{ "ab56b4d92b40713acc5af89985d4b786", "abcde" }, - md5Test{ "e80b5017098950fc58aad83c8c14978e", "abcdef" }, - md5Test{ "7ac66c0f148de9519b8bd264312c4d64", "abcdefg" }, - md5Test{ "e8dc4081b13434b45189a720b77b6818", "abcdefgh" }, - md5Test{ "8aa99b1f439ff71293e95357bac6fd94", "abcdefghi" }, - md5Test{ "a925576942e94b2ef57a066101b48876", "abcdefghij" }, - md5Test{ "d747fc1719c7eacb84058196cfe56d57", "Discard medicine more than two years old." }, - md5Test{ "bff2dcb37ef3a44ba43ab144768ca837", "He who has a shady past knows that nice guys finish last." }, - md5Test{ "0441015ecb54a7342d017ed1bcfdbea5", "I wouldn't marry him with a ten foot pole." }, - md5Test{ "9e3cac8e9e9757a60c3ea391130d3689", "Free! Free!/A trip/to Mars/for 900/empty jars/Burma Shave" }, - md5Test{ "a0f04459b031f916a59a35cc482dc039", "The days of the digital watch are numbered. -Tom Stoppard" }, - md5Test{ "e7a48e0fe884faf31475d2a04b1362cc", "Nepal premier won't resign." }, - md5Test{ "637d2fe925c07c113800509964fb0e06", "For every action there is an equal and opposite government program." }, - md5Test{ "834a8d18d5c6562119cf4c7f5086cb71", "His money is twice tainted: 'taint yours and 'taint mine." }, - md5Test{ "de3a4d2fd6c73ec2db2abad23b444281", "There is no reason for any individual to have a computer in their home. -Ken Olsen, 1977" }, - md5Test{ "acf203f997e2cf74ea3aff86985aefaf", "It's a tiny change to the code and not completely disgusting. - Bob Manchek" }, - md5Test{ "e1c1384cb4d2221dfdd7c795a4222c9a", "size: a.out: bad magic" }, - md5Test{ "c90f3ddecc54f34228c063d7525bf644", "The major problem is with sendmail. -Mark Horton" }, - md5Test{ "cdf7ab6c1fd49bd9933c43f3ea5af185", "Give me a rock, paper and scissors and I will move the world. CCFestoon" }, - md5Test{ "83bc85234942fc883c063cbd7f0ad5d0", "If the enemy is within range, then so are you." }, - md5Test{ "277cbe255686b48dd7e8f389394d9299", "It's well we cannot hear the screams/That we create in others' dreams." }, - md5Test{ "fd3fb0a7ffb8af16603f3d3af98f8e1f", "You remind me of a TV show, but that's all right: I watch it anyway." }, - md5Test{ "469b13a78ebf297ecda64d4723655154", "C is as portable as Stonehedge!!" }, - md5Test{ "63eb3a2f466410104731c4b037600110", "Even if I could be Shakespeare, I think I should still choose to be Faraday. - A. Huxley" }, - md5Test{ "72c2ed7592debca1c90fc0100f931a2f", "The fugacity of a constituent in a mixture of gases at a given temperature is proportional to its mole fraction. Lewis-Randall Rule" }, - md5Test{ "132f7619d33b523b1d9e5bd8e0928355", "How can you write a big system without C++? -Paul Glick" }, -} +var golden = []md5Test ( + md5Test( "d41d8cd98f00b204e9800998ecf8427e", "" ), + md5Test( "0cc175b9c0f1b6a831c399e269772661", "a" ), + md5Test( "187ef4436122d1cc2f40dc2b92f0eba0", "ab" ), + md5Test( "900150983cd24fb0d6963f7d28e17f72", "abc" ), + md5Test( "e2fc714c4727ee9395f324cd2e7f331f", "abcd" ), + md5Test( "ab56b4d92b40713acc5af89985d4b786", "abcde" ), + md5Test( "e80b5017098950fc58aad83c8c14978e", "abcdef" ), + md5Test( "7ac66c0f148de9519b8bd264312c4d64", "abcdefg" ), + md5Test( "e8dc4081b13434b45189a720b77b6818", "abcdefgh" ), + md5Test( "8aa99b1f439ff71293e95357bac6fd94", "abcdefghi" ), + md5Test( "a925576942e94b2ef57a066101b48876", "abcdefghij" ), + md5Test( "d747fc1719c7eacb84058196cfe56d57", "Discard medicine more than two years old." ), + md5Test( "bff2dcb37ef3a44ba43ab144768ca837", "He who has a shady past knows that nice guys finish last." ), + md5Test( "0441015ecb54a7342d017ed1bcfdbea5", "I wouldn't marry him with a ten foot pole." ), + md5Test( "9e3cac8e9e9757a60c3ea391130d3689", "Free! Free!/A trip/to Mars/for 900/empty jars/Burma Shave" ), + md5Test( "a0f04459b031f916a59a35cc482dc039", "The days of the digital watch are numbered. -Tom Stoppard" ), + md5Test( "e7a48e0fe884faf31475d2a04b1362cc", "Nepal premier won't resign." ), + md5Test( "637d2fe925c07c113800509964fb0e06", "For every action there is an equal and opposite government program." ), + md5Test( "834a8d18d5c6562119cf4c7f5086cb71", "His money is twice tainted: 'taint yours and 'taint mine." ), + md5Test( "de3a4d2fd6c73ec2db2abad23b444281", "There is no reason for any individual to have a computer in their home. -Ken Olsen, 1977" ), + md5Test( "acf203f997e2cf74ea3aff86985aefaf", "It's a tiny change to the code and not completely disgusting. - Bob Manchek" ), + md5Test( "e1c1384cb4d2221dfdd7c795a4222c9a", "size: a.out: bad magic" ), + md5Test( "c90f3ddecc54f34228c063d7525bf644", "The major problem is with sendmail. -Mark Horton" ), + md5Test( "cdf7ab6c1fd49bd9933c43f3ea5af185", "Give me a rock, paper and scissors and I will move the world. CCFestoon" ), + md5Test( "83bc85234942fc883c063cbd7f0ad5d0", "If the enemy is within range, then so are you." ), + md5Test( "277cbe255686b48dd7e8f389394d9299", "It's well we cannot hear the screams/That we create in others' dreams." ), + md5Test( "fd3fb0a7ffb8af16603f3d3af98f8e1f", "You remind me of a TV show, but that's all right: I watch it anyway." ), + md5Test( "469b13a78ebf297ecda64d4723655154", "C is as portable as Stonehedge!!" ), + md5Test( "63eb3a2f466410104731c4b037600110", "Even if I could be Shakespeare, I think I should still choose to be Faraday. - A. Huxley" ), + md5Test( "72c2ed7592debca1c90fc0100f931a2f", "The fugacity of a constituent in a mixture of gases at a given temperature is proportional to its mole fraction. Lewis-Randall Rule" ), + md5Test( "132f7619d33b523b1d9e5bd8e0928355", "How can you write a big system without C++? -Paul Glick" ), +) func TestGolden(t *testing.T) { for i := 0; i < len(golden); i++ { diff --git a/src/lib/hash/md5block.go b/src/lib/hash/md5block.go index 7974dbf0b9..b5328cb831 100644 --- a/src/lib/hash/md5block.go +++ b/src/lib/hash/md5block.go @@ -11,7 +11,7 @@ package md5 import "md5" // table[i] = int((1<<32) * abs(sin(i+1 radians))). -var table = []uint32 { +var table = []uint32 ( // round 1 0xd76aa478, 0xe8c7b756, @@ -83,12 +83,12 @@ var table = []uint32 { 0xbd3af235, 0x2ad7d2bb, 0xeb86d391, -} +) -var shift1 = []uint { 7, 12, 17, 22 }; -var shift2 = []uint { 5, 9, 14, 20 }; -var shift3 = []uint { 4, 11, 16, 23 }; -var shift4 = []uint { 6, 10, 15, 21 }; +var shift1 = []uint ( 7, 12, 17, 22 ); +var shift2 = []uint ( 5, 9, 14, 20 ); +var shift3 = []uint ( 4, 11, 16, 23 ); +var shift4 = []uint ( 6, 10, 15, 21 ); func _Block(dig *Digest, p []byte) int { a := dig.s[0]; diff --git a/src/lib/hash/sha1_test.go b/src/lib/hash/sha1_test.go index 2dde3973d9..02be3a77ba 100644 --- a/src/lib/hash/sha1_test.go +++ b/src/lib/hash/sha1_test.go @@ -18,39 +18,39 @@ type sha1Test struct { in string; } -var golden = []sha1Test { - sha1Test{ "da39a3ee5e6b4b0d3255bfef95601890afd80709", "" }, - sha1Test{ "86f7e437faa5a7fce15d1ddcb9eaeaea377667b8", "a" }, - sha1Test{ "da23614e02469a0d7c7bd1bdab5c9c474b1904dc", "ab" }, - sha1Test{ "a9993e364706816aba3e25717850c26c9cd0d89d", "abc" }, - sha1Test{ "81fe8bfe87576c3ecb22426f8e57847382917acf", "abcd" }, - sha1Test{ "03de6c570bfe24bfc328ccd7ca46b76eadaf4334", "abcde" }, - sha1Test{ "1f8ac10f23c5b5bc1167bda84b833e5c057a77d2", "abcdef" }, - sha1Test{ "2fb5e13419fc89246865e7a324f476ec624e8740", "abcdefg" }, - sha1Test{ "425af12a0743502b322e93a015bcf868e324d56a", "abcdefgh" }, - sha1Test{ "c63b19f1e4c8b5f76b25c49b8b87f57d8e4872a1", "abcdefghi" }, - sha1Test{ "d68c19a0a345b7eab78d5e11e991c026ec60db63", "abcdefghij" }, - sha1Test{ "ebf81ddcbe5bf13aaabdc4d65354fdf2044f38a7", "Discard medicine more than two years old." }, - sha1Test{ "e5dea09392dd886ca63531aaa00571dc07554bb6", "He who has a shady past knows that nice guys finish last." }, - sha1Test{ "45988f7234467b94e3e9494434c96ee3609d8f8f", "I wouldn't marry him with a ten foot pole." }, - sha1Test{ "55dee037eb7460d5a692d1ce11330b260e40c988", "Free! Free!/A trip/to Mars/for 900/empty jars/Burma Shave" }, - sha1Test{ "b7bc5fb91080c7de6b582ea281f8a396d7c0aee8", "The days of the digital watch are numbered. -Tom Stoppard" }, - sha1Test{ "c3aed9358f7c77f523afe86135f06b95b3999797", "Nepal premier won't resign." }, - sha1Test{ "6e29d302bf6e3a5e4305ff318d983197d6906bb9", "For every action there is an equal and opposite government program." }, - sha1Test{ "597f6a540010f94c15d71806a99a2c8710e747bd", "His money is twice tainted: 'taint yours and 'taint mine." }, - sha1Test{ "6859733b2590a8a091cecf50086febc5ceef1e80", "There is no reason for any individual to have a computer in their home. -Ken Olsen, 1977" }, - sha1Test{ "514b2630ec089b8aee18795fc0cf1f4860cdacad", "It's a tiny change to the code and not completely disgusting. - Bob Manchek" }, - sha1Test{ "c5ca0d4a7b6676fc7aa72caa41cc3d5df567ed69", "size: a.out: bad magic" }, - sha1Test{ "74c51fa9a04eadc8c1bbeaa7fc442f834b90a00a", "The major problem is with sendmail. -Mark Horton" }, - sha1Test{ "0b4c4ce5f52c3ad2821852a8dc00217fa18b8b66", "Give me a rock, paper and scissors and I will move the world. CCFestoon" }, - sha1Test{ "3ae7937dd790315beb0f48330e8642237c61550a", "If the enemy is within range, then so are you." }, - sha1Test{ "410a2b296df92b9a47412b13281df8f830a9f44b", "It's well we cannot hear the screams/That we create in others' dreams." }, - sha1Test{ "841e7c85ca1adcddbdd0187f1289acb5c642f7f5", "You remind me of a TV show, but that's all right: I watch it anyway." }, - sha1Test{ "163173b825d03b952601376b25212df66763e1db", "C is as portable as Stonehedge!!" }, - sha1Test{ "32b0377f2687eb88e22106f133c586ab314d5279", "Even if I could be Shakespeare, I think I should still choose to be Faraday. - A. Huxley" }, - sha1Test{ "0885aaf99b569542fd165fa44e322718f4a984e0", "The fugacity of a constituent in a mixture of gases at a given temperature is proportional to its mole fraction. Lewis-Randall Rule" }, - sha1Test{ "6627d6904d71420b0bf3886ab629623538689f45", "How can you write a big system without C++? -Paul Glick" }, -} +var golden = []sha1Test ( + sha1Test( "da39a3ee5e6b4b0d3255bfef95601890afd80709", "" ), + sha1Test( "86f7e437faa5a7fce15d1ddcb9eaeaea377667b8", "a" ), + sha1Test( "da23614e02469a0d7c7bd1bdab5c9c474b1904dc", "ab" ), + sha1Test( "a9993e364706816aba3e25717850c26c9cd0d89d", "abc" ), + sha1Test( "81fe8bfe87576c3ecb22426f8e57847382917acf", "abcd" ), + sha1Test( "03de6c570bfe24bfc328ccd7ca46b76eadaf4334", "abcde" ), + sha1Test( "1f8ac10f23c5b5bc1167bda84b833e5c057a77d2", "abcdef" ), + sha1Test( "2fb5e13419fc89246865e7a324f476ec624e8740", "abcdefg" ), + sha1Test( "425af12a0743502b322e93a015bcf868e324d56a", "abcdefgh" ), + sha1Test( "c63b19f1e4c8b5f76b25c49b8b87f57d8e4872a1", "abcdefghi" ), + sha1Test( "d68c19a0a345b7eab78d5e11e991c026ec60db63", "abcdefghij" ), + sha1Test( "ebf81ddcbe5bf13aaabdc4d65354fdf2044f38a7", "Discard medicine more than two years old." ), + sha1Test( "e5dea09392dd886ca63531aaa00571dc07554bb6", "He who has a shady past knows that nice guys finish last." ), + sha1Test( "45988f7234467b94e3e9494434c96ee3609d8f8f", "I wouldn't marry him with a ten foot pole." ), + sha1Test( "55dee037eb7460d5a692d1ce11330b260e40c988", "Free! Free!/A trip/to Mars/for 900/empty jars/Burma Shave" ), + sha1Test( "b7bc5fb91080c7de6b582ea281f8a396d7c0aee8", "The days of the digital watch are numbered. -Tom Stoppard" ), + sha1Test( "c3aed9358f7c77f523afe86135f06b95b3999797", "Nepal premier won't resign." ), + sha1Test( "6e29d302bf6e3a5e4305ff318d983197d6906bb9", "For every action there is an equal and opposite government program." ), + sha1Test( "597f6a540010f94c15d71806a99a2c8710e747bd", "His money is twice tainted: 'taint yours and 'taint mine." ), + sha1Test( "6859733b2590a8a091cecf50086febc5ceef1e80", "There is no reason for any individual to have a computer in their home. -Ken Olsen, 1977" ), + sha1Test( "514b2630ec089b8aee18795fc0cf1f4860cdacad", "It's a tiny change to the code and not completely disgusting. - Bob Manchek" ), + sha1Test( "c5ca0d4a7b6676fc7aa72caa41cc3d5df567ed69", "size: a.out: bad magic" ), + sha1Test( "74c51fa9a04eadc8c1bbeaa7fc442f834b90a00a", "The major problem is with sendmail. -Mark Horton" ), + sha1Test( "0b4c4ce5f52c3ad2821852a8dc00217fa18b8b66", "Give me a rock, paper and scissors and I will move the world. CCFestoon" ), + sha1Test( "3ae7937dd790315beb0f48330e8642237c61550a", "If the enemy is within range, then so are you." ), + sha1Test( "410a2b296df92b9a47412b13281df8f830a9f44b", "It's well we cannot hear the screams/That we create in others' dreams." ), + sha1Test( "841e7c85ca1adcddbdd0187f1289acb5c642f7f5", "You remind me of a TV show, but that's all right: I watch it anyway." ), + sha1Test( "163173b825d03b952601376b25212df66763e1db", "C is as portable as Stonehedge!!" ), + sha1Test( "32b0377f2687eb88e22106f133c586ab314d5279", "Even if I could be Shakespeare, I think I should still choose to be Faraday. - A. Huxley" ), + sha1Test( "0885aaf99b569542fd165fa44e322718f4a984e0", "The fugacity of a constituent in a mixture of gases at a given temperature is proportional to its mole fraction. Lewis-Randall Rule" ), + sha1Test( "6627d6904d71420b0bf3886ab629623538689f45", "How can you write a big system without C++? -Paul Glick" ), +) func TestGolden(t *testing.T) { for i := 0; i < len(golden); i++ { diff --git a/src/lib/http/server.go b/src/lib/http/server.go index ffb81cc90c..086621ae1a 100644 --- a/src/lib/http/server.go +++ b/src/lib/http/server.go @@ -247,7 +247,7 @@ func (h *redirectHandler) ServeHTTP(c *Conn, req *Request) { } func RedirectHandler(to string) Handler { - return &redirectHandler{to}; + return &redirectHandler(to); } // Path-based HTTP request multiplexer. @@ -265,7 +265,7 @@ type ServeMux struct { } func NewServeMux() *ServeMux { - return &ServeMux{make(map[string] Handler)}; + return &ServeMux(make(map[string] Handler)); } var DefaultServeMux = NewServeMux(); diff --git a/src/lib/http/status.go b/src/lib/http/status.go index 82a8b214c4..f7409eb4c5 100644 --- a/src/lib/http/status.go +++ b/src/lib/http/status.go @@ -53,7 +53,7 @@ const ( StatusHTTPVersionNotSupported = 505; ) -var statusText = map[int]string { +var statusText = map[int]string ( StatusContinue: "Continue", StatusSwitchingProtocols: "Switching Protocols", @@ -98,5 +98,5 @@ var statusText = map[int]string { StatusServiceUnavailable: "Service Unavailable", StatusGatewayTimeout: "Gateway Timeout", StatusHTTPVersionNotSupported: "HTTP Version Not Supported", -} +) diff --git a/src/lib/io/io.go b/src/lib/io/io.go index 1004ac901b..cda7a9bbbe 100644 --- a/src/lib/io/io.go +++ b/src/lib/io/io.go @@ -83,7 +83,7 @@ func Make_FullReader(fd Read) Read { // already a _FullRead return fd } - return &_FullRead{fd} + return &_FullRead(fd) } // Copies n bytes (or until EOF is reached) from src to dst. diff --git a/src/lib/json/generic.go b/src/lib/json/generic.go index 08ae8dc29f..89c6921341 100644 --- a/src/lib/json/generic.go +++ b/src/lib/json/generic.go @@ -45,7 +45,7 @@ func JsonToString(j Json) string { } type _Null struct { } -var Null Json = &_Null{} +var Null Json = &_Null() func (*_Null) Kind() int { return NullKind } func (*_Null) String() string { return "null" } func (*_Null) Number() float64 { return 0 } @@ -240,7 +240,7 @@ func (b *_JsonBuilder) Get() Json { } func (b *_JsonBuilder) Float64(f float64) { - b.Put(&_Number{f, _Null{}}) + b.Put(&_Number(f, _Null())) } func (b *_JsonBuilder) Int64(i int64) { @@ -252,7 +252,7 @@ func (b *_JsonBuilder) Uint64(i uint64) { } func (b *_JsonBuilder) Bool(tf bool) { - b.Put(&_Bool{tf, _Null{}}) + b.Put(&_Bool(tf, _Null())) } func (b *_JsonBuilder) Null() { @@ -260,16 +260,16 @@ func (b *_JsonBuilder) Null() { } func (b *_JsonBuilder) String(s string) { - b.Put(&_String{s, _Null{}}) + b.Put(&_String(s, _Null())) } func (b *_JsonBuilder) Array() { - b.Put(&_Array{array.New(0), _Null{}}) + b.Put(&_Array(array.New(0), _Null())) } func (b *_JsonBuilder) Map() { - b.Put(&_Map{make(map[string]Json), _Null{}}) + b.Put(&_Map(make(map[string]Json), _Null())) } func (b *_JsonBuilder) Elem(i int) Builder { diff --git a/src/lib/json/generic_test.go b/src/lib/json/generic_test.go index ab3e24fb80..6e409b3e4c 100644 --- a/src/lib/json/generic_test.go +++ b/src/lib/json/generic_test.go @@ -9,7 +9,7 @@ import ( "testing"; ) -var jsontests = []string { +var jsontests = []string ( `null`, `true`, `false`, @@ -22,7 +22,7 @@ var jsontests = []string { `[1,2,"abc",null,true,false]`, `{}`, `{"a":1}`, -} +) func TestJson(t *testing.T) { for i := 0; i < len(jsontests); i++ { diff --git a/src/lib/json/struct.go b/src/lib/json/struct.go index 82e0a80a7b..7d48dff4b8 100644 --- a/src/lib/json/struct.go +++ b/src/lib/json/struct.go @@ -163,7 +163,7 @@ func (b *_StructBuilder) Elem(i int) Builder { av.SetLen(i+1); } if i < av.Len() { - return &_StructBuilder{ av.Elem(i) } + return &_StructBuilder( av.Elem(i) ) } } return nobuilder @@ -195,7 +195,7 @@ func (b *_StructBuilder) Key(k string) Builder { for i := 0; i < t.Len(); i++ { name, typ, tag, off := t.Field(i); if k == name { - return &_StructBuilder{ sv.Field(i) } + return &_StructBuilder( sv.Field(i) ) } } } @@ -205,7 +205,7 @@ func (b *_StructBuilder) Key(k string) Builder { func Unmarshal(s string, val interface{}) (ok bool, errtok string) { var errindx int; var val1 interface{}; - b := &_StructBuilder{ reflect.NewValue(val) }; + b := &_StructBuilder( reflect.NewValue(val) ); ok, errindx, errtok = Parse(s, b); if !ok { return false, errtok diff --git a/src/lib/log.go b/src/lib/log.go index 1134ace32c..6e03709cdc 100644 --- a/src/lib/log.go +++ b/src/lib/log.go @@ -43,7 +43,7 @@ type Logger struct { } func NewLogger(out0, out1 io.Write, prefix string, flag int) *Logger { - return &Logger{out0, out1, prefix, flag} + return &Logger(out0, out1, prefix, flag) } var ( diff --git a/src/lib/log_test.go b/src/lib/log_test.go index 23e58b9901..aa8cb6e8e8 100644 --- a/src/lib/log_test.go +++ b/src/lib/log_test.go @@ -29,21 +29,21 @@ type tester struct { pattern string; // regexp that log output must match; we add ^ and expected_text$ always } -var tests = []tester { +var tests = []tester ( // individual pieces: - tester{ 0, "", "" }, - tester{ 0, "XXX", "XXX" }, - tester{ Lok|Ldate, "", Rdate+" " }, - tester{ Lok|Ltime, "", Rtime+" " }, - tester{ Lok|Ltime|Lmicroseconds, "", Rtime+Rmicroseconds+" " }, - tester{ Lok|Lmicroseconds, "", Rtime+Rmicroseconds+" " }, // microsec implies time - tester{ Lok|Llongfile, "", Rlongfile+" " }, - tester{ Lok|Lshortfile, "", Rshortfile+" " }, - tester{ Lok|Llongfile|Lshortfile, "", Rshortfile+" " }, // shortfile overrides longfile + tester( 0, "", "" ), + tester( 0, "XXX", "XXX" ), + tester( Lok|Ldate, "", Rdate+" " ), + tester( Lok|Ltime, "", Rtime+" " ), + tester( Lok|Ltime|Lmicroseconds, "", Rtime+Rmicroseconds+" " ), + tester( Lok|Lmicroseconds, "", Rtime+Rmicroseconds+" " ), // microsec implies time + tester( Lok|Llongfile, "", Rlongfile+" " ), + tester( Lok|Lshortfile, "", Rshortfile+" " ), + tester( Lok|Llongfile|Lshortfile, "", Rshortfile+" " ), // shortfile overrides longfile // everything at once: - tester{ Lok|Ldate|Ltime|Lmicroseconds|Llongfile, "XXX", "XXX"+Rdate+" "+Rtime+Rmicroseconds+" "+Rlongfile+" " }, - tester{ Lok|Ldate|Ltime|Lmicroseconds|Lshortfile, "XXX", "XXX"+Rdate+" "+Rtime+Rmicroseconds+" "+Rshortfile+" " }, -} + tester( Lok|Ldate|Ltime|Lmicroseconds|Llongfile, "XXX", "XXX"+Rdate+" "+Rtime+Rmicroseconds+" "+Rlongfile+" " ), + tester( Lok|Ldate|Ltime|Lmicroseconds|Lshortfile, "XXX", "XXX"+Rdate+" "+Rtime+Rmicroseconds+" "+Rshortfile+" " ), +) // Test using Log("hello", 23, "world") or using Logf("hello %d world", 23) func testLog(t *testing.T, flag int, prefix string, pattern string, useLogf bool) { diff --git a/src/lib/math/all_test.go b/src/lib/math/all_test.go index c5d5c01c41..2f01ff9e50 100644 --- a/src/lib/math/all_test.go +++ b/src/lib/math/all_test.go @@ -9,7 +9,7 @@ import ( "testing"; ) -var vf = []float64 { +var vf = []float64 ( 4.9790119248836735e+00, 7.7388724745781045e+00, -2.7688005719200159e-01, @@ -20,8 +20,8 @@ var vf = []float64 { 2.7279399104360102e+00, 1.8253080916808550e+00, -8.6859247685756013e+00, -} -var asin = []float64 { +) +var asin = []float64 ( 5.2117697218417440e-01, 8.8495619865825236e-01, -2.7691544662819413e-02, @@ -32,8 +32,8 @@ var asin = []float64 { 2.7629597861677200e-01, 1.8355989225745148e-01, -1.0523547536021498e+00, -} -var atan = []float64 { +) +var atan = []float64 ( 1.3725902621296217e+00, 1.4422906096452980e+00, -2.7011324359471755e-01, @@ -44,8 +44,8 @@ var atan = []float64 { 1.2194305844639670e+00, 1.0696031952318783e+00, -1.4561721938838085e+00, -} -var exp = []float64 { +) +var exp = []float64 ( 1.4533071302642137e+02, 2.2958822575694450e+03, 7.5814542574851666e-01, @@ -56,8 +56,8 @@ var exp = []float64 { 1.5301332413189379e+01, 6.2047063430646876e+00, 1.6894712385826522e-04, -} -var floor = []float64 { +) +var floor = []float64 ( 4.0000000000000000e+00, 7.0000000000000000e+00, -1.0000000000000000e+00, @@ -68,8 +68,8 @@ var floor = []float64 { 2.0000000000000000e+00, 1.0000000000000000e+00, -9.0000000000000000e+00, -} -var log = []float64 { +) +var log = []float64 ( 1.6052314626930630e+00, 2.0462560018708768e+00, -1.2841708730962657e+00, @@ -80,8 +80,8 @@ var log = []float64 { 1.0035467127723465e+00, 6.0174879014578053e-01, 2.1617038728473527e+00, -} -var pow = []float64 { +) +var pow = []float64 ( 9.5282232631648415e+04, 5.4811599352999900e+07, 5.2859121715894400e-01, @@ -92,8 +92,8 @@ var pow = []float64 { 5.3449040147551940e+02, 6.6881821384514159e+01, 2.0609869004248744e-09, -} -var sin = []float64 { +) +var sin = []float64 ( -9.6466616586009283e-01, 9.9338225271646543e-01, -2.7335587039794395e-01, @@ -104,8 +104,8 @@ var sin = []float64 { 4.0195666811555783e-01, 9.6778633541688000e-01, -6.7344058690503452e-01, -} -var sinh = []float64 { +) +var sinh = []float64 ( 7.2661916084208533e+01, 1.1479409110035194e+03, -2.8043136512812520e-01, @@ -116,8 +116,8 @@ var sinh = []float64 { 7.6179893137269143e+00, 3.0217691805496156e+00, -2.9595057572444951e+03, -} -var sqrt = []float64 { +) +var sqrt = []float64 ( 2.2313699659365484e+00, 2.7818829009464263e+00, 5.2619393496314792e-01, @@ -128,8 +128,8 @@ var sqrt = []float64 { 1.6516476350711160e+00, 1.3510396336454586e+00, 2.9471892997524950e+00, -} -var tan = []float64 { +) +var tan = []float64 ( -3.6613165650402277e+00, 8.6490023264859754e+00, -2.8417941955033615e-01, @@ -140,8 +140,8 @@ var tan = []float64 { -4.3898089147528178e-01, -3.8438855602011305e+00, 9.1098879337768517e-01, -} -var tanh = []float64 { +) +var tanh = []float64 ( 9.9990531206936328e-01, 9.9999962057085307e-01, -2.7001505097318680e-01, @@ -152,7 +152,7 @@ var tanh = []float64 { 9.9149409509772863e-01, 9.4936501296239700e-01, -9.9999994291374019e-01, -} +) func tolerance(a,b,e float64) bool { d := a-b; diff --git a/src/lib/net/dialgoogle_test.go b/src/lib/net/dialgoogle_test.go index de7158a7bc..0bf3eae9a9 100644 --- a/src/lib/net/dialgoogle_test.go +++ b/src/lib/net/dialgoogle_test.go @@ -50,7 +50,7 @@ func doDialTCP(t *testing.T, network, addr string) { fd.Close() } -var googleaddrs = []string { +var googleaddrs = []string ( "74.125.19.99:80", "www.google.com:80", "74.125.19.99:http", @@ -62,7 +62,7 @@ var googleaddrs = []string { "[0:0:0:0:000000:ffff:74.125.19.99]:80", "[0:0:0:0:0:ffff::74.125.19.99]:80", "[2001:4860:0:2001::68]:80" // ipv6.google.com; removed if ipv6 flag not set -} +) func TestDialGoogle(t *testing.T) { // If no ipv6 tunnel, don't try the last address. diff --git a/src/lib/net/dnsclient.go b/src/lib/net/dnsclient.go index 072ffb3e47..22d2684aa7 100644 --- a/src/lib/net/dnsclient.go +++ b/src/lib/net/dnsclient.go @@ -46,9 +46,9 @@ func _Exchange(cfg *DNS_Config, c Conn, name string) (m *DNS_Msg, err *os.Error) } out := new(DNS_Msg); out.id = 0x1234; - out.question = []DNS_Question{ - DNS_Question{ name, DNS_TypeA, DNS_ClassINET } - }; + out.question = []DNS_Question( + DNS_Question( name, DNS_TypeA, DNS_ClassINET ) + ); out.recursion_desired = true; msg, ok := out.Pack(); if !ok { diff --git a/src/lib/net/dnsmsg.go b/src/lib/net/dnsmsg.go index b93a9c3755..c82f345d26 100644 --- a/src/lib/net/dnsmsg.go +++ b/src/lib/net/dnsmsg.go @@ -197,7 +197,7 @@ type DNS_RR_A struct { // packing sequence. // Map of constructors for each RR wire type. -var rr_mk = map[int] func()DNS_RR { +var rr_mk = map[int] func()DNS_RR ( DNS_TypeCNAME: func() DNS_RR { return new(DNS_RR_CNAME) }, DNS_TypeHINFO: func() DNS_RR { return new(DNS_RR_HINFO) }, DNS_TypeMB: func() DNS_RR { return new(DNS_RR_MB) }, @@ -210,7 +210,7 @@ var rr_mk = map[int] func()DNS_RR { DNS_TypeSOA: func() DNS_RR { return new(DNS_RR_SOA) }, DNS_TypeTXT: func() DNS_RR { return new(DNS_RR_TXT) }, DNS_TypeA: func() DNS_RR { return new(DNS_RR_A) }, -} +) // _Pack a domain name s into msg[off:]. // Domain names are a sequence of counted strings diff --git a/src/lib/net/ip_test.go b/src/lib/net/ip_test.go index 9788db2435..f8d8bd2ba6 100644 --- a/src/lib/net/ip_test.go +++ b/src/lib/net/ip_test.go @@ -10,7 +10,7 @@ import ( ) func _IPv4(a, b, c, d byte) []byte { - return []byte{ 0,0,0,0, 0,0,0,0, 0,0,255,255, a,b,c,d } + return []byte( 0,0,0,0, 0,0,0,0, 0,0,255,255, a,b,c,d ) } func isEqual(a []byte, b []byte) bool { @@ -32,16 +32,16 @@ type parseIPTest struct { in string; out []byte; } -var parseiptests = []parseIPTest { - parseIPTest{"127.0.1.2", _IPv4(127, 0, 1, 2)}, - parseIPTest{"127.0.0.1", _IPv4(127, 0, 0, 1)}, - parseIPTest{"127.0.0.256", nil}, - parseIPTest{"abc", nil}, - parseIPTest{"::ffff:127.0.0.1", _IPv4(127, 0, 0, 1)}, - parseIPTest{"2001:4860:0:2001::68", - []byte{0x20,0x01, 0x48,0x60, 0,0, 0x20,0x01, 0,0, 0,0, 0,0, 0x00,0x68}}, - parseIPTest{"::ffff:4a7d:1363", _IPv4(74, 125, 19, 99)}, -} +var parseiptests = []parseIPTest ( + parseIPTest("127.0.1.2", _IPv4(127, 0, 1, 2)), + parseIPTest("127.0.0.1", _IPv4(127, 0, 0, 1)), + parseIPTest("127.0.0.256", nil), + parseIPTest("abc", nil), + parseIPTest("::ffff:127.0.0.1", _IPv4(127, 0, 0, 1)), + parseIPTest("2001:4860:0:2001::68", + []byte(0x20,0x01, 0x48,0x60, 0,0, 0x20,0x01, 0,0, 0,0, 0,0, 0x00,0x68)), + parseIPTest("::ffff:4a7d:1363", _IPv4(74, 125, 19, 99)), +) func TestParseIP(t *testing.T) { for i := 0; i < len(parseiptests); i++ { diff --git a/src/lib/net/parse.go b/src/lib/net/parse.go index 0477b349fa..a1cf10c4a1 100644 --- a/src/lib/net/parse.go +++ b/src/lib/net/parse.go @@ -60,7 +60,7 @@ func _Open(name string) *_File { if err != nil { return nil } - return &_File{fd, make([]byte, 1024)[0:0]}; + return &_File(fd, make([]byte, 1024)[0:0]); } func _ByteIndex(s string, c byte) int { diff --git a/src/lib/net/port_test.go b/src/lib/net/port_test.go index f6123fd8d5..f48ced0754 100644 --- a/src/lib/net/port_test.go +++ b/src/lib/net/port_test.go @@ -16,37 +16,37 @@ type portTest struct { ok bool; } -var porttests = []portTest { - portTest{ "tcp", "echo", 7, true }, - portTest{ "tcp", "discard", 9, true }, - portTest{ "tcp", "systat", 11, true }, - portTest{ "tcp", "daytime", 13, true }, - portTest{ "tcp", "chargen", 19, true }, - portTest{ "tcp", "ftp-data", 20, true }, - portTest{ "tcp", "ftp", 21, true }, - portTest{ "tcp", "ssh", 22, true }, - portTest{ "tcp", "telnet", 23, true }, - portTest{ "tcp", "smtp", 25, true }, - portTest{ "tcp", "time", 37, true }, - portTest{ "tcp", "domain", 53, true }, - portTest{ "tcp", "gopher", 70, true }, - portTest{ "tcp", "finger", 79, true }, - portTest{ "tcp", "http", 80, true }, +var porttests = []portTest ( + portTest( "tcp", "echo", 7, true ), + portTest( "tcp", "discard", 9, true ), + portTest( "tcp", "systat", 11, true ), + portTest( "tcp", "daytime", 13, true ), + portTest( "tcp", "chargen", 19, true ), + portTest( "tcp", "ftp-data", 20, true ), + portTest( "tcp", "ftp", 21, true ), + portTest( "tcp", "ssh", 22, true ), + portTest( "tcp", "telnet", 23, true ), + portTest( "tcp", "smtp", 25, true ), + portTest( "tcp", "time", 37, true ), + portTest( "tcp", "domain", 53, true ), + portTest( "tcp", "gopher", 70, true ), + portTest( "tcp", "finger", 79, true ), + portTest( "tcp", "http", 80, true ), - portTest{ "udp", "echo", 7, true }, - portTest{ "udp", "tacacs", 49, true }, - portTest{ "udp", "tftp", 69, true }, - portTest{ "udp", "bootpc", 68, true }, - portTest{ "udp", "bootps", 67, true }, - portTest{ "udp", "domain", 53, true }, - portTest{ "udp", "ntp", 123, true }, - portTest{ "udp", "snmp", 161, true }, - portTest{ "udp", "syslog", 514, true }, - portTest{ "udp", "nfs", 2049, true }, + portTest( "udp", "echo", 7, true ), + portTest( "udp", "tacacs", 49, true ), + portTest( "udp", "tftp", 69, true ), + portTest( "udp", "bootpc", 68, true ), + portTest( "udp", "bootps", 67, true ), + portTest( "udp", "domain", 53, true ), + portTest( "udp", "ntp", 123, true ), + portTest( "udp", "snmp", 161, true ), + portTest( "udp", "syslog", 514, true ), + portTest( "udp", "nfs", 2049, true ), - portTest{ "--badnet--", "zzz", 0, false }, - portTest{ "tcp", "--badport--", 0, false }, -} + portTest( "--badnet--", "zzz", 0, false ), + portTest( "tcp", "--badport--", 0, false ), +) func TestLookupPort(t *testing.T) { for i := 0; i < len(porttests); i++ { diff --git a/src/lib/once.go b/src/lib/once.go index e1466ab8eb..8ebddccee6 100644 --- a/src/lib/once.go +++ b/src/lib/once.go @@ -52,7 +52,7 @@ func Do(f func()) { // job, present = jobmap[f] if !present { c := make(chan *_Job); - service <- _Request{f, c}; + service <- _Request(f, c); job = <-c } diff --git a/src/lib/os/error.go b/src/lib/os/error.go index 63b2dbccac..d85d237aa8 100644 --- a/src/lib/os/error.go +++ b/src/lib/os/error.go @@ -33,7 +33,7 @@ func NewError(s string) *Error { if ok { return err } - err = &Error{s}; + err = &Error(s); errorStringTab[s] = err; return err; } diff --git a/src/lib/os/file.go b/src/lib/os/file.go index a0fc4bb679..d4725760de 100644 --- a/src/lib/os/file.go +++ b/src/lib/os/file.go @@ -33,7 +33,7 @@ func NewFD(fd int64, name string) *FD { if fd < 0 { return nil } - return &FD{fd, name, nil} + return &FD(fd, name, nil) } var ( diff --git a/src/lib/os/os_test.go b/src/lib/os/os_test.go index 5c37a6b139..91b401808c 100644 --- a/src/lib/os/os_test.go +++ b/src/lib/os/os_test.go @@ -10,7 +10,7 @@ import ( "testing"; ) -var dot = []string{ +var dot = []string( "dir_amd64_darwin.go", "dir_amd64_linux.go", "os_env.go", @@ -21,13 +21,13 @@ var dot = []string{ "os_types.go", "stat_amd64_darwin.go", "stat_amd64_linux.go" -} +) -var etc = []string{ +var etc = []string( "group", "hosts", "passwd", -} +) func size(file string, t *testing.T) uint64 { fd, err := Open(file, O_RDONLY, 0); diff --git a/src/lib/reflect/all_test.go b/src/lib/reflect/all_test.go index f6428fdf38..828e287aa6 100644 --- a/src/lib/reflect/all_test.go +++ b/src/lib/reflect/all_test.go @@ -168,7 +168,7 @@ func TestAll(tt *testing.T) { // TODO(r): wrap up better } { var i int = 7; - var tmp = &T{123, 456.75, "hello", &i}; + var tmp = &T(123, 456.75, "hello", &i); value := reflect.NewValue(tmp); assert(reflect.ValueToString(value.(reflect.PtrValue).Sub()), "reflect.T{123, 456.75, hello, *int(@)}"); } @@ -188,7 +188,7 @@ func TestAll(tt *testing.T) { // TODO(r): wrap up better // } { type AA []int; - var tmp = AA{1,2,3,4,5,6,7,8,9,10}; + var tmp = AA(1,2,3,4,5,6,7,8,9,10); value := reflect.NewValue(&tmp); // TODO: NewValue(tmp) too assert(reflect.ValueToString(value.(reflect.PtrValue).Sub()), "reflect.AA·all_test{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}"); value.(reflect.PtrValue).Sub().(reflect.ArrayValue).Elem(4).(reflect.IntValue).Set(123); @@ -297,9 +297,9 @@ func TestInterfaceGet(t *testing.T) { } func TestCopyArray(t *testing.T) { - a := []int{ 1, 2, 3, 4, 10, 9, 8, 7 }; - b := []int{ 11, 22, 33, 44, 1010, 99, 88, 77, 66, 55, 44 }; - c := []int{ 11, 22, 33, 44, 1010, 99, 88, 77, 66, 55, 44 }; + a := []int( 1, 2, 3, 4, 10, 9, 8, 7 ); + b := []int( 11, 22, 33, 44, 1010, 99, 88, 77, 66, 55, 44 ); + c := []int( 11, 22, 33, 44, 1010, 99, 88, 77, 66, 55, 44 ); va := NewValue(&a); vb := NewValue(&b); for i := 0; i < len(b); i++ { @@ -332,7 +332,7 @@ func TestCopyArray(t *testing.T) { } func TestBigUnnamedStruct(t *testing.T) { - b := struct{a,b,c,d int64}{1, 2, 3, 4}; + b := struct{a,b,c,d int64}(1, 2, 3, 4); v := NewValue(b); b1 := v.Interface().(struct{a,b,c,d int64}); if b1.a != b.a || b1.b != b.b || b1.c != b.c || b1.d != b.d { @@ -344,7 +344,7 @@ type big struct { a, b, c, d, e int64 } func TestBigStruct(t *testing.T) { - b := big{1, 2, 3, 4, 5}; + b := big(1, 2, 3, 4, 5); v := NewValue(b); b1 := v.Interface().(big); if b1.a != b.a || b1.b != b.b || b1.c != b.c || b1.d != b.d || b1.e != b.e { diff --git a/src/lib/reflect/type.go b/src/lib/reflect/type.go index d949f23f40..6d14e660f3 100644 --- a/src/lib/reflect/type.go +++ b/src/lib/reflect/type.go @@ -101,7 +101,7 @@ type basicType struct { } func newBasicType(name string, kind int, size int) Type { - return &basicType{ commonType{kind, name, name, size} } + return &basicType( commonType(kind, name, name, size) ) } // Prebuilt basic types @@ -136,7 +136,7 @@ type stubType struct { } func newStubType(name string, typ Type) *stubType { - return &stubType{name, typ} + return &stubType(name, typ) } func (t *stubType) Get() Type { @@ -164,7 +164,7 @@ type ptrTypeStruct struct { } func newPtrTypeStruct(name, typestring string, sub *stubType) *ptrTypeStruct { - return &ptrTypeStruct{ commonType{PtrKind, typestring, name, ptrsize}, sub} + return &ptrTypeStruct( commonType(PtrKind, typestring, name, ptrsize), sub) } func (t *ptrTypeStruct) Sub() Type { @@ -193,7 +193,7 @@ type arrayTypeStruct struct { } func newArrayTypeStruct(name, typestring string, open bool, len int, elem *stubType) *arrayTypeStruct { - return &arrayTypeStruct{ commonType{ArrayKind, typestring, name, 0}, elem, open, len} + return &arrayTypeStruct( commonType(ArrayKind, typestring, name, 0), elem, open, len) } func (t *arrayTypeStruct) Size() int { @@ -236,7 +236,7 @@ type mapTypeStruct struct { } func newMapTypeStruct(name, typestring string, key, elem *stubType) *mapTypeStruct { - return &mapTypeStruct{ commonType{MapKind, typestring, name, ptrsize}, key, elem} + return &mapTypeStruct( commonType(MapKind, typestring, name, ptrsize), key, elem) } func (t *mapTypeStruct) Key() Type { @@ -273,7 +273,7 @@ type chanTypeStruct struct { } func newChanTypeStruct(name, typestring string, dir int, elem *stubType) *chanTypeStruct { - return &chanTypeStruct{ commonType{ChanKind, typestring, name, ptrsize}, elem, dir} + return &chanTypeStruct( commonType(ChanKind, typestring, name, ptrsize), elem, dir) } func (t *chanTypeStruct) Dir() int { @@ -311,7 +311,7 @@ type structTypeStruct struct { } func newStructTypeStruct(name, typestring string, field []structField) *structTypeStruct { - return &structTypeStruct{ commonType{StructKind, typestring, name, 0}, field} + return &structTypeStruct( commonType(StructKind, typestring, name, 0), field) } // TODO: not portable; depends on 6g @@ -369,7 +369,7 @@ type interfaceTypeStruct struct { } func newInterfaceTypeStruct(name, typestring string, field []structField) *interfaceTypeStruct { - return &interfaceTypeStruct{ commonType{InterfaceKind, typestring, name, interfacesize}, field } + return &interfaceTypeStruct( commonType(InterfaceKind, typestring, name, interfacesize), field ) } func (t *interfaceTypeStruct) Field(i int) (name string, typ Type, tag string, offset int) { @@ -402,7 +402,7 @@ type funcTypeStruct struct { } func newFuncTypeStruct(name, typestring string, in, out *structTypeStruct) *funcTypeStruct { - return &funcTypeStruct{ commonType{FuncKind, typestring, name, 0}, in, out } + return &funcTypeStruct( commonType(FuncKind, typestring, name, 0), in, out ) } func (t *funcTypeStruct) Size() int { diff --git a/src/lib/reflect/value.go b/src/lib/reflect/value.go index 6464d7e6d2..8d15a8e3d5 100644 --- a/src/lib/reflect/value.go +++ b/src/lib/reflect/value.go @@ -78,7 +78,7 @@ type missingValueStruct struct { } func missingCreator(typ Type, addr Addr) Value { - return &missingValueStruct{ commonValue{MissingKind, typ, addr} } + return &missingValueStruct( commonValue(MissingKind, typ, addr) ) } // -- Int @@ -99,7 +99,7 @@ type intValueStruct struct { } func intCreator(typ Type, addr Addr) Value { - return &intValueStruct{ commonValue{IntKind, typ, addr} } + return &intValueStruct( commonValue(IntKind, typ, addr) ) } func (v *intValueStruct) Get() int { @@ -128,7 +128,7 @@ type int8ValueStruct struct { } func int8Creator(typ Type, addr Addr) Value { - return &int8ValueStruct{ commonValue{Int8Kind, typ, addr} } + return &int8ValueStruct( commonValue(Int8Kind, typ, addr) ) } func (v *int8ValueStruct) Get() int8 { @@ -157,7 +157,7 @@ type int16ValueStruct struct { } func int16Creator(typ Type, addr Addr) Value { - return &int16ValueStruct{ commonValue{Int16Kind, typ, addr} } + return &int16ValueStruct( commonValue(Int16Kind, typ, addr) ) } func (v *int16ValueStruct) Get() int16 { @@ -186,7 +186,7 @@ type int32ValueStruct struct { } func int32Creator(typ Type, addr Addr) Value { - return &int32ValueStruct{ commonValue{Int32Kind, typ, addr} } + return &int32ValueStruct( commonValue(Int32Kind, typ, addr) ) } func (v *int32ValueStruct) Get() int32 { @@ -215,7 +215,7 @@ type int64ValueStruct struct { } func int64Creator(typ Type, addr Addr) Value { - return &int64ValueStruct{ commonValue{Int64Kind, typ, addr} } + return &int64ValueStruct( commonValue(Int64Kind, typ, addr) ) } func (v *int64ValueStruct) Get() int64 { @@ -244,7 +244,7 @@ type uintValueStruct struct { } func uintCreator(typ Type, addr Addr) Value { - return &uintValueStruct{ commonValue{UintKind, typ, addr} } + return &uintValueStruct( commonValue(UintKind, typ, addr) ) } func (v *uintValueStruct) Get() uint { @@ -273,7 +273,7 @@ type uint8ValueStruct struct { } func uint8Creator(typ Type, addr Addr) Value { - return &uint8ValueStruct{ commonValue{Uint8Kind, typ, addr} } + return &uint8ValueStruct( commonValue(Uint8Kind, typ, addr) ) } func (v *uint8ValueStruct) Get() uint8 { @@ -302,7 +302,7 @@ type uint16ValueStruct struct { } func uint16Creator(typ Type, addr Addr) Value { - return &uint16ValueStruct{ commonValue{Uint16Kind, typ, addr} } + return &uint16ValueStruct( commonValue(Uint16Kind, typ, addr) ) } func (v *uint16ValueStruct) Get() uint16 { @@ -331,7 +331,7 @@ type uint32ValueStruct struct { } func uint32Creator(typ Type, addr Addr) Value { - return &uint32ValueStruct{ commonValue{Uint32Kind, typ, addr} } + return &uint32ValueStruct( commonValue(Uint32Kind, typ, addr) ) } func (v *uint32ValueStruct) Get() uint32 { @@ -360,7 +360,7 @@ type uint64ValueStruct struct { } func uint64Creator(typ Type, addr Addr) Value { - return &uint64ValueStruct{ commonValue{Uint64Kind, typ, addr} } + return &uint64ValueStruct( commonValue(Uint64Kind, typ, addr) ) } func (v *uint64ValueStruct) Get() uint64 { @@ -389,7 +389,7 @@ type uintptrValueStruct struct { } func uintptrCreator(typ Type, addr Addr) Value { - return &uintptrValueStruct{ commonValue{UintptrKind, typ, addr} } + return &uintptrValueStruct( commonValue(UintptrKind, typ, addr) ) } func (v *uintptrValueStruct) Get() uintptr { @@ -418,7 +418,7 @@ type floatValueStruct struct { } func floatCreator(typ Type, addr Addr) Value { - return &floatValueStruct{ commonValue{FloatKind, typ, addr} } + return &floatValueStruct( commonValue(FloatKind, typ, addr) ) } func (v *floatValueStruct) Get() float { @@ -447,7 +447,7 @@ type float32ValueStruct struct { } func float32Creator(typ Type, addr Addr) Value { - return &float32ValueStruct{ commonValue{Float32Kind, typ, addr} } + return &float32ValueStruct( commonValue(Float32Kind, typ, addr) ) } func (v *float32ValueStruct) Get() float32 { @@ -476,7 +476,7 @@ type float64ValueStruct struct { } func float64Creator(typ Type, addr Addr) Value { - return &float64ValueStruct{ commonValue{Float64Kind, typ, addr} } + return &float64ValueStruct( commonValue(Float64Kind, typ, addr) ) } func (v *float64ValueStruct) Get() float64 { @@ -505,7 +505,7 @@ type float80ValueStruct struct { } func float80Creator(typ Type, addr Addr) Value { - return &float80ValueStruct{ commonValue{Float80Kind, typ, addr} } + return &float80ValueStruct( commonValue(Float80Kind, typ, addr) ) } /* @@ -537,7 +537,7 @@ type stringValueStruct struct { } func stringCreator(typ Type, addr Addr) Value { - return &stringValueStruct{ commonValue{StringKind, typ, addr} } + return &stringValueStruct( commonValue(StringKind, typ, addr) ) } func (v *stringValueStruct) Get() string { @@ -566,7 +566,7 @@ type boolValueStruct struct { } func boolCreator(typ Type, addr Addr) Value { - return &boolValueStruct{ commonValue{BoolKind, typ, addr} } + return &boolValueStruct( commonValue(BoolKind, typ, addr) ) } func (v *boolValueStruct) Get() bool { @@ -614,7 +614,7 @@ func (v *ptrValueStruct) SetSub(subv Value) { } func ptrCreator(typ Type, addr Addr) Value { - return &ptrValueStruct{ commonValue{PtrKind, typ, addr} }; + return &ptrValueStruct( commonValue(PtrKind, typ, addr) ); } // -- Array @@ -774,7 +774,7 @@ type mapValueStruct struct { } func mapCreator(typ Type, addr Addr) Value { - return &mapValueStruct{ commonValue{MapKind, typ, addr} } + return &mapValueStruct( commonValue(MapKind, typ, addr) ) } func (v *mapValueStruct) Len() int { @@ -801,7 +801,7 @@ type chanValueStruct struct { } func chanCreator(typ Type, addr Addr) Value { - return &chanValueStruct{ commonValue{ChanKind, typ, addr} } + return &chanValueStruct( commonValue(ChanKind, typ, addr) ) } // -- Struct @@ -833,7 +833,7 @@ func (v *structValueStruct) Field(i int) Value { func structCreator(typ Type, addr Addr) Value { t := typ.(StructType); nfield := t.Len(); - v := &structValueStruct{ commonValue{StructKind, typ, addr}, make([]Value, nfield) }; + v := &structValueStruct( commonValue(StructKind, typ, addr), make([]Value, nfield) ); for i := 0; i < nfield; i++ { name, ftype, str, offset := t.Field(i); addr_uint := uintptr(addr) + uintptr(offset); @@ -864,7 +864,7 @@ func (v *interfaceValueStruct) Get() interface{} { } func interfaceCreator(typ Type, addr Addr) Value { - return &interfaceValueStruct{ commonValue{InterfaceKind, typ, addr} } + return &interfaceValueStruct( commonValue(InterfaceKind, typ, addr) ) } // -- Func @@ -882,10 +882,10 @@ type funcValueStruct struct { } func funcCreator(typ Type, addr Addr) Value { - return &funcValueStruct{ commonValue{FuncKind, typ, addr} } + return &funcValueStruct( commonValue(FuncKind, typ, addr) ) } -var creator = map[int] creatorFn { +var creator = map[int] creatorFn ( MissingKind : missingCreator, IntKind : intCreator, Int8Kind : int8Creator, @@ -911,7 +911,7 @@ var creator = map[int] creatorFn { StructKind : structCreator, InterfaceKind : interfaceCreator, FuncKind : funcCreator, -} +) var typecache = make(map[string] Type); diff --git a/src/lib/regexp/all_test.go b/src/lib/regexp/all_test.go index 5e9754934f..3c2e8bacdf 100644 --- a/src/lib/regexp/all_test.go +++ b/src/lib/regexp/all_test.go @@ -10,7 +10,7 @@ import ( "testing"; ) -var good_re = []string{ +var good_re = []string( ``, `.`, `^.$`, @@ -27,27 +27,27 @@ var good_re = []string{ `[]`, `[abc]`, `[^1234]`, -} +) // TODO: nice to do this with a map type stringError struct { re string; err *os.Error; } -var bad_re = []stringError{ - stringError{ `*`, regexp.ErrBareClosure }, - stringError{ `(abc`, regexp.ErrUnmatchedLpar }, - stringError{ `abc)`, regexp.ErrUnmatchedRpar }, - stringError{ `x[a-z`, regexp.ErrUnmatchedLbkt }, - stringError{ `abc]`, regexp.ErrUnmatchedRbkt }, - stringError{ `[z-a]`, regexp.ErrBadRange }, - stringError{ `abc\`, regexp.ErrExtraneousBackslash }, - stringError{ `a**`, regexp.ErrBadClosure }, - stringError{ `a*+`, regexp.ErrBadClosure }, - stringError{ `a??`, regexp.ErrBadClosure }, - stringError{ `*`, regexp.ErrBareClosure }, - stringError{ `\x`, regexp.ErrBadBackslash }, -} +var bad_re = []stringError( + stringError( `*`, regexp.ErrBareClosure ), + stringError( `(abc`, regexp.ErrUnmatchedLpar ), + stringError( `abc)`, regexp.ErrUnmatchedRpar ), + stringError( `x[a-z`, regexp.ErrUnmatchedLbkt ), + stringError( `abc]`, regexp.ErrUnmatchedRbkt ), + stringError( `[z-a]`, regexp.ErrBadRange ), + stringError( `abc\`, regexp.ErrExtraneousBackslash ), + stringError( `a**`, regexp.ErrBadClosure ), + stringError( `a*+`, regexp.ErrBadClosure ), + stringError( `a??`, regexp.ErrBadClosure ), + stringError( `*`, regexp.ErrBareClosure ), + stringError( `\x`, regexp.ErrBadBackslash ), +) type vec []int; @@ -57,33 +57,33 @@ type tester struct { match vec; } -var matches = []tester { - tester{ ``, "", vec{0,0} }, - tester{ `a`, "a", vec{0,1} }, - tester{ `x`, "y", vec{} }, - tester{ `b`, "abc", vec{1,2} }, - tester{ `.`, "a", vec{0,1} }, - tester{ `.*`, "abcdef", vec{0,6} }, - tester{ `^abcd$`, "abcd", vec{0,4} }, - tester{ `^bcd'`, "abcdef", vec{} }, - tester{ `^abcd$`, "abcde", vec{} }, - tester{ `a+`, "baaab", vec{1,4} }, - tester{ `a*`, "baaab", vec{0,0} }, - tester{ `[a-z]+`, "abcd", vec{0,4} }, - tester{ `[^a-z]+`, "ab1234cd", vec{2,6} }, - tester{ `[a\-\]z]+`, "az]-bcz", vec{0,4} }, - tester{ `[日本語]+`, "日本語日本語", vec{0,18} }, - tester{ `()`, "", vec{0,0, 0,0} }, - tester{ `(a)`, "a", vec{0,1, 0,1} }, - tester{ `(.)(.)`, "日a", vec{0,4, 0,3, 3,4} }, - tester{ `(.*)`, "", vec{0,0, 0,0} }, - tester{ `(.*)`, "abcd", vec{0,4, 0,4} }, - tester{ `(..)(..)`, "abcd", vec{0,4, 0,2, 2,4} }, - tester{ `(([^xyz]*)(d))`, "abcd", vec{0,4, 0,4, 0,3, 3,4} }, - tester{ `((a|b|c)*(d))`, "abcd", vec{0,4, 0,4, 2,3, 3,4} }, - tester{ `(((a|b|c)*)(d))`, "abcd", vec{0,4, 0,4, 0,3, 2,3, 3,4} }, - tester{ `a*(|(b))c*`, "aacc", vec{0,4, 2,2, -1,-1} }, -} +var matches = []tester ( + tester( ``, "", vec(0,0) ), + tester( `a`, "a", vec(0,1) ), + tester( `x`, "y", vec() ), + tester( `b`, "abc", vec(1,2) ), + tester( `.`, "a", vec(0,1) ), + tester( `.*`, "abcdef", vec(0,6) ), + tester( `^abcd$`, "abcd", vec(0,4) ), + tester( `^bcd'`, "abcdef", vec() ), + tester( `^abcd$`, "abcde", vec() ), + tester( `a+`, "baaab", vec(1,4) ), + tester( `a*`, "baaab", vec(0,0) ), + tester( `[a-z]+`, "abcd", vec(0,4) ), + tester( `[^a-z]+`, "ab1234cd", vec(2,6) ), + tester( `[a\-\]z]+`, "az]-bcz", vec(0,4) ), + tester( `[日本語]+`, "日本語日本語", vec(0,18) ), + tester( `()`, "", vec(0,0, 0,0) ), + tester( `(a)`, "a", vec(0,1, 0,1) ), + tester( `(.)(.)`, "日a", vec(0,4, 0,3, 3,4) ), + tester( `(.*)`, "", vec(0,0, 0,0) ), + tester( `(.*)`, "abcd", vec(0,4, 0,4) ), + tester( `(..)(..)`, "abcd", vec(0,4, 0,2, 2,4) ), + tester( `(([^xyz]*)(d))`, "abcd", vec(0,4, 0,4, 0,3, 3,4) ), + tester( `((a|b|c)*(d))`, "abcd", vec(0,4, 0,4, 2,3, 3,4) ), + tester( `(((a|b|c)*)(d))`, "abcd", vec(0,4, 0,4, 0,3, 2,3, 3,4) ), + tester( `a*(|(b))c*`, "aacc", vec(0,4, 2,2, -1,-1) ), +) func compileTest(t *testing.T, expr string, error *os.Error) regexp.Regexp { re, err := regexp.Compile(expr); diff --git a/src/lib/sort_test.go b/src/lib/sort_test.go index aa80aa10e3..f9d924c4e8 100644 --- a/src/lib/sort_test.go +++ b/src/lib/sort_test.go @@ -12,9 +12,9 @@ import ( ) -var ints = [...]int{74, 59, 238, -784, 9845, 959, 905, 0, 0, 42, 7586, -5467984, 7586} -var floats = [...]float{74.3, 59.0, 238.2, -784.0, 2.3, 9845.768, -959.7485, 905, 7.8, 7.8} -var strings = [...]string{"", "Hello", "foo", "bar", "foo", "f00", "%*&^*&^&", "***"} +var ints = [...]int(74, 59, 238, -784, 9845, 959, 905, 0, 0, 42, 7586, -5467984, 7586) +var floats = [...]float(74.3, 59.0, 238.2, -784.0, 2.3, 9845.768, -959.7485, 905, 7.8, 7.8) +var strings = [...]string("", "Hello", "foo", "bar", "foo", "f00", "%*&^*&^&", "***") func TestSortIntArray(t *testing.T) { data := ints; @@ -134,9 +134,9 @@ func lg(n int) int { } func TestBentleyMcIlroy(t *testing.T) { - sizes := []int{100, 1023, 1024, 1025}; - dists := []string{"sawtooth", "rand", "stagger", "plateau", "shuffle"}; - modes := []string{"copy", "reverse", "reverse1", "reverse2", "sort", "dither"}; + sizes := []int(100, 1023, 1024, 1025); + dists := []string("sawtooth", "rand", "stagger", "plateau", "shuffle"); + modes := []string("copy", "reverse", "reverse1", "reverse2", "sort", "dither"); var tmp1, tmp2 [1025]int; for ni := 0; ni < len(sizes); ni++ { n := sizes[ni]; @@ -205,7 +205,7 @@ func TestBentleyMcIlroy(t *testing.T) { } desc := fmt.Sprintf("n=%d m=%d dist=%s mode=%s", n, m, dists[dist], modes[mode]); - d := &testingData{desc, t, mdata[0:n], n*lg(n)*12/10, 0}; + d := &testingData(desc, t, mdata[0:n], n*lg(n)*12/10, 0); sort.Sort(d); // If we were testing C qsort, we'd have to make a copy diff --git a/src/lib/strconv/atof.go b/src/lib/strconv/atof.go index 3585944163..d1a0f4a9e7 100644 --- a/src/lib/strconv/atof.go +++ b/src/lib/strconv/atof.go @@ -106,9 +106,9 @@ func stringToDecimal(s string) (neg bool, d *decimal, trunc bool, ok bool) { } // decimal power of ten to binary power of two. -var powtab = []int{ +var powtab = []int( 1, 3, 6, 9, 13, 16, 19, 23, 26 -} +) func decimalToFloatBits(neg bool, d *decimal, trunc bool, flt *floatInfo) (b uint64, overflow bool) { var exp int; @@ -232,14 +232,14 @@ func decimalAtof32Int(neg bool, d *decimal) float32 { } // Exact powers of 10. -var float64pow10 = []float64 { +var float64pow10 = []float64 ( 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22 -} -var float32pow10 = []float32 { +) +var float32pow10 = []float32 ( 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10 -} +) // If possible to convert decimal d to 64-bit float f exactly, // entirely in floating-point math, do so, avoiding the expense of decimalToFloatBits. diff --git a/src/lib/strconv/atof_test.go b/src/lib/strconv/atof_test.go index 7f1f0a1312..abc1998714 100644 --- a/src/lib/strconv/atof_test.go +++ b/src/lib/strconv/atof_test.go @@ -16,80 +16,80 @@ type atofTest struct { err *os.Error; } -var atoftests = []atofTest { - atofTest{ "", "0", os.EINVAL }, - atofTest{ "1", "1", nil }, - atofTest{ "+1", "1", nil }, - atofTest{ "1x", "0", os.EINVAL }, - atofTest{ "1.1.", "0", os.EINVAL }, - atofTest{ "1e23", "1e+23", nil }, - atofTest{ "100000000000000000000000", "1e+23", nil }, - atofTest{ "1e-100", "1e-100", nil }, - atofTest{ "123456700", "1.234567e+08", nil }, - atofTest{ "99999999999999974834176", "9.999999999999997e+22", nil }, - atofTest{ "100000000000000000000001", "1.0000000000000001e+23", nil }, - atofTest{ "100000000000000008388608", "1.0000000000000001e+23", nil }, - atofTest{ "100000000000000016777215", "1.0000000000000001e+23", nil }, - atofTest{ "100000000000000016777216", "1.0000000000000003e+23", nil }, - atofTest{ "-1", "-1", nil }, - atofTest{ "-0", "-0", nil }, - atofTest{ "1e-20", "1e-20", nil }, - atofTest{ "625e-3", "0.625", nil }, +var atoftests = []atofTest ( + atofTest( "", "0", os.EINVAL ), + atofTest( "1", "1", nil ), + atofTest( "+1", "1", nil ), + atofTest( "1x", "0", os.EINVAL ), + atofTest( "1.1.", "0", os.EINVAL ), + atofTest( "1e23", "1e+23", nil ), + atofTest( "100000000000000000000000", "1e+23", nil ), + atofTest( "1e-100", "1e-100", nil ), + atofTest( "123456700", "1.234567e+08", nil ), + atofTest( "99999999999999974834176", "9.999999999999997e+22", nil ), + atofTest( "100000000000000000000001", "1.0000000000000001e+23", nil ), + atofTest( "100000000000000008388608", "1.0000000000000001e+23", nil ), + atofTest( "100000000000000016777215", "1.0000000000000001e+23", nil ), + atofTest( "100000000000000016777216", "1.0000000000000003e+23", nil ), + atofTest( "-1", "-1", nil ), + atofTest( "-0", "-0", nil ), + atofTest( "1e-20", "1e-20", nil ), + atofTest( "625e-3", "0.625", nil ), // largest float64 - atofTest{ "1.7976931348623157e308", "1.7976931348623157e+308", nil }, - atofTest{ "-1.7976931348623157e308", "-1.7976931348623157e+308", nil }, + atofTest( "1.7976931348623157e308", "1.7976931348623157e+308", nil ), + atofTest( "-1.7976931348623157e308", "-1.7976931348623157e+308", nil ), // next float64 - too large - atofTest{ "1.7976931348623159e308", "+Inf", os.ERANGE }, - atofTest{ "-1.7976931348623159e308", "-Inf", os.ERANGE }, + atofTest( "1.7976931348623159e308", "+Inf", os.ERANGE ), + atofTest( "-1.7976931348623159e308", "-Inf", os.ERANGE ), // the border is ...158079 // borderline - okay - atofTest{ "1.7976931348623158e308", "1.7976931348623157e+308", nil }, - atofTest{ "-1.7976931348623158e308", "-1.7976931348623157e+308", nil }, + atofTest( "1.7976931348623158e308", "1.7976931348623157e+308", nil ), + atofTest( "-1.7976931348623158e308", "-1.7976931348623157e+308", nil ), // borderline - too large - atofTest{ "1.797693134862315808e308", "+Inf", os.ERANGE }, - atofTest{ "-1.797693134862315808e308", "-Inf", os.ERANGE }, + atofTest( "1.797693134862315808e308", "+Inf", os.ERANGE ), + atofTest( "-1.797693134862315808e308", "-Inf", os.ERANGE ), // a little too large - atofTest{ "1e308", "1e+308", nil }, - atofTest{ "2e308", "+Inf", os.ERANGE }, - atofTest{ "1e309", "+Inf", os.ERANGE }, + atofTest( "1e308", "1e+308", nil ), + atofTest( "2e308", "+Inf", os.ERANGE ), + atofTest( "1e309", "+Inf", os.ERANGE ), // way too large - atofTest{ "1e310", "+Inf", os.ERANGE }, - atofTest{ "-1e310", "-Inf", os.ERANGE }, - atofTest{ "1e400", "+Inf", os.ERANGE }, - atofTest{ "-1e400", "-Inf", os.ERANGE }, - atofTest{ "1e400000", "+Inf", os.ERANGE }, - atofTest{ "-1e400000", "-Inf", os.ERANGE }, + atofTest( "1e310", "+Inf", os.ERANGE ), + atofTest( "-1e310", "-Inf", os.ERANGE ), + atofTest( "1e400", "+Inf", os.ERANGE ), + atofTest( "-1e400", "-Inf", os.ERANGE ), + atofTest( "1e400000", "+Inf", os.ERANGE ), + atofTest( "-1e400000", "-Inf", os.ERANGE ), // denormalized - atofTest{ "1e-305", "1e-305", nil }, - atofTest{ "1e-306", "1e-306", nil }, - atofTest{ "1e-307", "1e-307", nil }, - atofTest{ "1e-308", "1e-308", nil }, - atofTest{ "1e-309", "1e-309", nil }, - atofTest{ "1e-310", "1e-310", nil }, - atofTest{ "1e-322", "1e-322", nil }, + atofTest( "1e-305", "1e-305", nil ), + atofTest( "1e-306", "1e-306", nil ), + atofTest( "1e-307", "1e-307", nil ), + atofTest( "1e-308", "1e-308", nil ), + atofTest( "1e-309", "1e-309", nil ), + atofTest( "1e-310", "1e-310", nil ), + atofTest( "1e-322", "1e-322", nil ), // smallest denormal - atofTest{ "5e-324", "5e-324", nil }, + atofTest( "5e-324", "5e-324", nil ), // too small - atofTest{ "4e-324", "0", nil }, + atofTest( "4e-324", "0", nil ), // way too small - atofTest{ "1e-350", "0", nil }, - atofTest{ "1e-400000", "0", nil }, + atofTest( "1e-350", "0", nil ), + atofTest( "1e-400000", "0", nil ), // try to overflow exponent - atofTest{ "1e-4294967296", "0", nil }, - atofTest{ "1e+4294967296", "+Inf", os.ERANGE }, - atofTest{ "1e-18446744073709551616", "0", nil }, - atofTest{ "1e+18446744073709551616", "+Inf", os.ERANGE }, + atofTest( "1e-4294967296", "0", nil ), + atofTest( "1e+4294967296", "+Inf", os.ERANGE ), + atofTest( "1e-18446744073709551616", "0", nil ), + atofTest( "1e+18446744073709551616", "+Inf", os.ERANGE ), // Parse errors - atofTest{ "1e", "0", os.EINVAL }, - atofTest{ "1e-", "0", os.EINVAL }, - atofTest{ ".e-1", "0", os.EINVAL }, -} + atofTest( "1e", "0", os.EINVAL ), + atofTest( "1e-", "0", os.EINVAL ), + atofTest( ".e-1", "0", os.EINVAL ), +) func testAtof(t *testing.T, opt bool) { oldopt := strconv.optimize; diff --git a/src/lib/strconv/atoi_test.go b/src/lib/strconv/atoi_test.go index 5ffda142e6..d57846d233 100644 --- a/src/lib/strconv/atoi_test.go +++ b/src/lib/strconv/atoi_test.go @@ -16,18 +16,18 @@ type atoui64Test struct { err *os.Error; } -var atoui64tests = []atoui64Test { - atoui64Test{ "", 0, os.EINVAL }, - atoui64Test{ "0", 0, nil }, - atoui64Test{ "1", 1, nil }, - atoui64Test{ "12345", 12345, nil }, - atoui64Test{ "012345", 0, os.EINVAL }, - atoui64Test{ "12345x", 0, os.EINVAL }, - atoui64Test{ "98765432100", 98765432100, nil }, - atoui64Test{ "18446744073709551615", 1<<64-1, nil }, - atoui64Test{ "18446744073709551616", 1<<64-1, os.ERANGE }, - atoui64Test{ "18446744073709551620", 1<<64-1, os.ERANGE }, -} +var atoui64tests = []atoui64Test ( + atoui64Test( "", 0, os.EINVAL ), + atoui64Test( "0", 0, nil ), + atoui64Test( "1", 1, nil ), + atoui64Test( "12345", 12345, nil ), + atoui64Test( "012345", 0, os.EINVAL ), + atoui64Test( "12345x", 0, os.EINVAL ), + atoui64Test( "98765432100", 98765432100, nil ), + atoui64Test( "18446744073709551615", 1<<64-1, nil ), + atoui64Test( "18446744073709551616", 1<<64-1, os.ERANGE ), + atoui64Test( "18446744073709551620", 1<<64-1, os.ERANGE ), +) type atoi64Test struct { in string; @@ -35,27 +35,27 @@ type atoi64Test struct { err *os.Error; } -var atoi64test = []atoi64Test { - atoi64Test{ "", 0, os.EINVAL }, - atoi64Test{ "0", 0, nil }, - atoi64Test{ "-0", 0, nil }, - atoi64Test{ "1", 1, nil }, - atoi64Test{ "-1", -1, nil }, - atoi64Test{ "12345", 12345, nil }, - atoi64Test{ "-12345", -12345, nil }, - atoi64Test{ "012345", 0, os.EINVAL }, - atoi64Test{ "-012345", 0, os.EINVAL }, - atoi64Test{ "12345x", 0, os.EINVAL }, - atoi64Test{ "-12345x", 0, os.EINVAL }, - atoi64Test{ "98765432100", 98765432100, nil }, - atoi64Test{ "-98765432100", -98765432100, nil }, - atoi64Test{ "9223372036854775807", 1<<63-1, nil }, - atoi64Test{ "-9223372036854775807", -(1<<63-1), nil }, - atoi64Test{ "9223372036854775808", 1<<63-1, os.ERANGE }, - atoi64Test{ "-9223372036854775808", -1<<63, nil }, - atoi64Test{ "9223372036854775809", 1<<63-1, os.ERANGE }, - atoi64Test{ "-9223372036854775809", -1<<63, os.ERANGE }, -} +var atoi64test = []atoi64Test ( + atoi64Test( "", 0, os.EINVAL ), + atoi64Test( "0", 0, nil ), + atoi64Test( "-0", 0, nil ), + atoi64Test( "1", 1, nil ), + atoi64Test( "-1", -1, nil ), + atoi64Test( "12345", 12345, nil ), + atoi64Test( "-12345", -12345, nil ), + atoi64Test( "012345", 0, os.EINVAL ), + atoi64Test( "-012345", 0, os.EINVAL ), + atoi64Test( "12345x", 0, os.EINVAL ), + atoi64Test( "-12345x", 0, os.EINVAL ), + atoi64Test( "98765432100", 98765432100, nil ), + atoi64Test( "-98765432100", -98765432100, nil ), + atoi64Test( "9223372036854775807", 1<<63-1, nil ), + atoi64Test( "-9223372036854775807", -(1<<63-1), nil ), + atoi64Test( "9223372036854775808", 1<<63-1, os.ERANGE ), + atoi64Test( "-9223372036854775808", -1<<63, nil ), + atoi64Test( "9223372036854775809", 1<<63-1, os.ERANGE ), + atoi64Test( "-9223372036854775809", -1<<63, os.ERANGE ), +) type atoui32Test struct { in string; @@ -63,17 +63,17 @@ type atoui32Test struct { err *os.Error; } -var atoui32tests = []atoui32Test { - atoui32Test{ "", 0, os.EINVAL }, - atoui32Test{ "0", 0, nil }, - atoui32Test{ "1", 1, nil }, - atoui32Test{ "12345", 12345, nil }, - atoui32Test{ "012345", 0, os.EINVAL }, - atoui32Test{ "12345x", 0, os.EINVAL }, - atoui32Test{ "987654321", 987654321, nil }, - atoui32Test{ "4294967295", 1<<32-1, nil }, - atoui32Test{ "4294967296", 1<<32-1, os.ERANGE }, -} +var atoui32tests = []atoui32Test ( + atoui32Test( "", 0, os.EINVAL ), + atoui32Test( "0", 0, nil ), + atoui32Test( "1", 1, nil ), + atoui32Test( "12345", 12345, nil ), + atoui32Test( "012345", 0, os.EINVAL ), + atoui32Test( "12345x", 0, os.EINVAL ), + atoui32Test( "987654321", 987654321, nil ), + atoui32Test( "4294967295", 1<<32-1, nil ), + atoui32Test( "4294967296", 1<<32-1, os.ERANGE ), +) type atoi32Test struct { in string; @@ -81,27 +81,27 @@ type atoi32Test struct { err *os.Error; } -var atoi32tests = []atoi32Test { - atoi32Test{ "", 0, os.EINVAL }, - atoi32Test{ "0", 0, nil }, - atoi32Test{ "-0", 0, nil }, - atoi32Test{ "1", 1, nil }, - atoi32Test{ "-1", -1, nil }, - atoi32Test{ "12345", 12345, nil }, - atoi32Test{ "-12345", -12345, nil }, - atoi32Test{ "012345", 0, os.EINVAL }, - atoi32Test{ "-012345", 0, os.EINVAL }, - atoi32Test{ "12345x", 0, os.EINVAL }, - atoi32Test{ "-12345x", 0, os.EINVAL }, - atoi32Test{ "987654321", 987654321, nil }, - atoi32Test{ "-987654321", -987654321, nil }, - atoi32Test{ "2147483647", 1<<31-1, nil }, - atoi32Test{ "-2147483647", -(1<<31-1), nil }, - atoi32Test{ "2147483648", 1<<31-1, os.ERANGE }, - atoi32Test{ "-2147483648", -1<<31, nil }, - atoi32Test{ "2147483649", 1<<31-1, os.ERANGE }, - atoi32Test{ "-2147483649", -1<<31, os.ERANGE }, -} +var atoi32tests = []atoi32Test ( + atoi32Test( "", 0, os.EINVAL ), + atoi32Test( "0", 0, nil ), + atoi32Test( "-0", 0, nil ), + atoi32Test( "1", 1, nil ), + atoi32Test( "-1", -1, nil ), + atoi32Test( "12345", 12345, nil ), + atoi32Test( "-12345", -12345, nil ), + atoi32Test( "012345", 0, os.EINVAL ), + atoi32Test( "-012345", 0, os.EINVAL ), + atoi32Test( "12345x", 0, os.EINVAL ), + atoi32Test( "-12345x", 0, os.EINVAL ), + atoi32Test( "987654321", 987654321, nil ), + atoi32Test( "-987654321", -987654321, nil ), + atoi32Test( "2147483647", 1<<31-1, nil ), + atoi32Test( "-2147483647", -(1<<31-1), nil ), + atoi32Test( "2147483648", 1<<31-1, os.ERANGE ), + atoi32Test( "-2147483648", -1<<31, nil ), + atoi32Test( "2147483649", 1<<31-1, os.ERANGE ), + atoi32Test( "-2147483649", -1<<31, os.ERANGE ), +) func TestAtoui64(t *testing.T) { for i := 0; i < len(atoui64tests); i++ { diff --git a/src/lib/strconv/decimal.go b/src/lib/strconv/decimal.go index 4808e93463..37a5ab9c6b 100644 --- a/src/lib/strconv/decimal.go +++ b/src/lib/strconv/decimal.go @@ -192,7 +192,7 @@ type leftCheat struct { cutoff string; // minus one digit if original < a. } -var leftcheats = []leftCheat { +var leftcheats = []leftCheat ( // Leading digits of 1/2^i = 5^i. // 5^23 is not an exact 64-bit floating point number, // so have to use bc for the math. @@ -205,35 +205,35 @@ var leftcheats = []leftCheat { int(log2*NR+1), $0, 2**NR) }' */ - leftCheat{ 0, "" }, - leftCheat{ 1, "5" }, // * 2 - leftCheat{ 1, "25" }, // * 4 - leftCheat{ 1, "125" }, // * 8 - leftCheat{ 2, "625" }, // * 16 - leftCheat{ 2, "3125" }, // * 32 - leftCheat{ 2, "15625" }, // * 64 - leftCheat{ 3, "78125" }, // * 128 - leftCheat{ 3, "390625" }, // * 256 - leftCheat{ 3, "1953125" }, // * 512 - leftCheat{ 4, "9765625" }, // * 1024 - leftCheat{ 4, "48828125" }, // * 2048 - leftCheat{ 4, "244140625" }, // * 4096 - leftCheat{ 4, "1220703125" }, // * 8192 - leftCheat{ 5, "6103515625" }, // * 16384 - leftCheat{ 5, "30517578125" }, // * 32768 - leftCheat{ 5, "152587890625" }, // * 65536 - leftCheat{ 6, "762939453125" }, // * 131072 - leftCheat{ 6, "3814697265625" }, // * 262144 - leftCheat{ 6, "19073486328125" }, // * 524288 - leftCheat{ 7, "95367431640625" }, // * 1048576 - leftCheat{ 7, "476837158203125" }, // * 2097152 - leftCheat{ 7, "2384185791015625" }, // * 4194304 - leftCheat{ 7, "11920928955078125" }, // * 8388608 - leftCheat{ 8, "59604644775390625" }, // * 16777216 - leftCheat{ 8, "298023223876953125" }, // * 33554432 - leftCheat{ 8, "1490116119384765625" }, // * 67108864 - leftCheat{ 9, "7450580596923828125" }, // * 134217728 -} + leftCheat( 0, "" ), + leftCheat( 1, "5" ), // * 2 + leftCheat( 1, "25" ), // * 4 + leftCheat( 1, "125" ), // * 8 + leftCheat( 2, "625" ), // * 16 + leftCheat( 2, "3125" ), // * 32 + leftCheat( 2, "15625" ), // * 64 + leftCheat( 3, "78125" ), // * 128 + leftCheat( 3, "390625" ), // * 256 + leftCheat( 3, "1953125" ), // * 512 + leftCheat( 4, "9765625" ), // * 1024 + leftCheat( 4, "48828125" ), // * 2048 + leftCheat( 4, "244140625" ), // * 4096 + leftCheat( 4, "1220703125" ), // * 8192 + leftCheat( 5, "6103515625" ), // * 16384 + leftCheat( 5, "30517578125" ), // * 32768 + leftCheat( 5, "152587890625" ), // * 65536 + leftCheat( 6, "762939453125" ), // * 131072 + leftCheat( 6, "3814697265625" ), // * 262144 + leftCheat( 6, "19073486328125" ), // * 524288 + leftCheat( 7, "95367431640625" ), // * 1048576 + leftCheat( 7, "476837158203125" ), // * 2097152 + leftCheat( 7, "2384185791015625" ), // * 4194304 + leftCheat( 7, "11920928955078125" ), // * 8388608 + leftCheat( 8, "59604644775390625" ), // * 16777216 + leftCheat( 8, "298023223876953125" ), // * 33554432 + leftCheat( 8, "1490116119384765625" ), // * 67108864 + leftCheat( 9, "7450580596923828125" ), // * 134217728 +) // Is the leading prefix of b lexicographically less than s? func prefixIsLessThan(b []byte, s string) bool { diff --git a/src/lib/strconv/decimal_test.go b/src/lib/strconv/decimal_test.go index bc82861bdd..7af0d254d0 100644 --- a/src/lib/strconv/decimal_test.go +++ b/src/lib/strconv/decimal_test.go @@ -16,18 +16,18 @@ type shiftTest struct { out string; } -var shifttests = []shiftTest { - shiftTest{ 0, -100, "0" }, - shiftTest{ 0, 100, "0" }, - shiftTest{ 1, 100, "1267650600228229401496703205376" }, - shiftTest{ 1, -100, +var shifttests = []shiftTest ( + shiftTest( 0, -100, "0" ), + shiftTest( 0, 100, "0" ), + shiftTest( 1, 100, "1267650600228229401496703205376" ), + shiftTest( 1, -100, "0.00000000000000000000000000000078886090522101180541" - "17285652827862296732064351090230047702789306640625" }, - shiftTest{ 12345678, 8, "3160493568" }, - shiftTest{ 12345678, -8, "48225.3046875" }, - shiftTest{ 195312, 9, "99999744" }, - shiftTest{ 1953125, 9, "1000000000" }, -} + "17285652827862296732064351090230047702789306640625" ), + shiftTest( 12345678, 8, "3160493568" ), + shiftTest( 12345678, -8, "48225.3046875" ), + shiftTest( 195312, 9, "99999744" ), + shiftTest( 1953125, 9, "1000000000" ), +) func TestDecimalShift(t *testing.T) { ok := true; @@ -48,23 +48,23 @@ type roundTest struct { int uint64; } -var roundtests = []roundTest { - roundTest{ 0, 4, "0", "0", "0", 0 }, - roundTest{ 12344999, 4, "12340000", "12340000", "12350000", 12340000 }, - roundTest{ 12345000, 4, "12340000", "12340000", "12350000", 12340000 }, - roundTest{ 12345001, 4, "12340000", "12350000", "12350000", 12350000 }, - roundTest{ 23454999, 4, "23450000", "23450000", "23460000", 23450000 }, - roundTest{ 23455000, 4, "23450000", "23460000", "23460000", 23460000 }, - roundTest{ 23455001, 4, "23450000", "23460000", "23460000", 23460000 }, +var roundtests = []roundTest ( + roundTest( 0, 4, "0", "0", "0", 0 ), + roundTest( 12344999, 4, "12340000", "12340000", "12350000", 12340000 ), + roundTest( 12345000, 4, "12340000", "12340000", "12350000", 12340000 ), + roundTest( 12345001, 4, "12340000", "12350000", "12350000", 12350000 ), + roundTest( 23454999, 4, "23450000", "23450000", "23460000", 23450000 ), + roundTest( 23455000, 4, "23450000", "23460000", "23460000", 23460000 ), + roundTest( 23455001, 4, "23450000", "23460000", "23460000", 23460000 ), - roundTest{ 99994999, 4, "99990000", "99990000", "100000000", 99990000 }, - roundTest{ 99995000, 4, "99990000", "100000000", "100000000", 100000000 }, - roundTest{ 99999999, 4, "99990000", "100000000", "100000000", 100000000 }, + roundTest( 99994999, 4, "99990000", "99990000", "100000000", 99990000 ), + roundTest( 99995000, 4, "99990000", "100000000", "100000000", 100000000 ), + roundTest( 99999999, 4, "99990000", "100000000", "100000000", 100000000 ), - roundTest{ 12994999, 4, "12990000", "12990000", "13000000", 12990000 }, - roundTest{ 12995000, 4, "12990000", "13000000", "13000000", 13000000 }, - roundTest{ 12999999, 4, "12990000", "13000000", "13000000", 13000000 }, -} + roundTest( 12994999, 4, "12990000", "12990000", "13000000", 12990000 ), + roundTest( 12995000, 4, "12990000", "13000000", "13000000", 13000000 ), + roundTest( 12999999, 4, "12990000", "13000000", "13000000", 13000000 ), +) func TestDecimalRound(t *testing.T) { for i := 0; i < len(roundtests); i++ { @@ -93,18 +93,18 @@ type roundIntTest struct { int uint64; } -var roundinttests = []roundIntTest { - roundIntTest{ 0, 100, 0 }, - roundIntTest{ 512, -8, 2 }, - roundIntTest{ 513, -8, 2 }, - roundIntTest{ 640, -8, 2 }, - roundIntTest{ 641, -8, 3 }, - roundIntTest{ 384, -8, 2 }, - roundIntTest{ 385, -8, 2 }, - roundIntTest{ 383, -8, 1 }, - roundIntTest{ 1, 100, 1<<64-1 }, - roundIntTest{ 1000, 0, 1000 }, -} +var roundinttests = []roundIntTest ( + roundIntTest( 0, 100, 0 ), + roundIntTest( 512, -8, 2 ), + roundIntTest( 513, -8, 2 ), + roundIntTest( 640, -8, 2 ), + roundIntTest( 641, -8, 3 ), + roundIntTest( 384, -8, 2 ), + roundIntTest( 385, -8, 2 ), + roundIntTest( 383, -8, 1 ), + roundIntTest( 1, 100, 1<<64-1 ), + roundIntTest( 1000, 0, 1000 ), +) func TestDecimalRoundedInteger(t *testing.T) { for i := 0; i < len(roundinttests); i++ { diff --git a/src/lib/strconv/ftoa.go b/src/lib/strconv/ftoa.go index 52835c803e..75bb3a21fa 100644 --- a/src/lib/strconv/ftoa.go +++ b/src/lib/strconv/ftoa.go @@ -21,8 +21,8 @@ type floatInfo struct { expbits uint; bias int; } -var float32info = floatInfo{ 23, 8, -127 } -var float64info = floatInfo{ 52, 11, -1023 } +var float32info = floatInfo( 23, 8, -127 ) +var float64info = floatInfo( 52, 11, -1023 ) func fmtB(neg bool, mant uint64, exp int, flt *floatInfo) string func fmtE(neg bool, d *decimal, prec int) string diff --git a/src/lib/strconv/ftoa_test.go b/src/lib/strconv/ftoa_test.go index 0f0baa5145..09fdeaca57 100644 --- a/src/lib/strconv/ftoa_test.go +++ b/src/lib/strconv/ftoa_test.go @@ -24,80 +24,80 @@ const ( above1e23 = 100000000000000008388608; ) -var ftoatests = []ftoaTest { - ftoaTest{ 1, 'e', 5, "1.00000e+00" }, - ftoaTest{ 1, 'f', 5, "1.00000" }, - ftoaTest{ 1, 'g', 5, "1" }, - ftoaTest{ 1, 'g', -1, "1" }, - ftoaTest{ 20, 'g', -1, "20" }, - ftoaTest{ 1234567.8, 'g', -1, "1.2345678e+06" }, - ftoaTest{ 200000, 'g', -1, "200000" }, - ftoaTest{ 2000000, 'g', -1, "2e+06" }, +var ftoatests = []ftoaTest ( + ftoaTest( 1, 'e', 5, "1.00000e+00" ), + ftoaTest( 1, 'f', 5, "1.00000" ), + ftoaTest( 1, 'g', 5, "1" ), + ftoaTest( 1, 'g', -1, "1" ), + ftoaTest( 20, 'g', -1, "20" ), + ftoaTest( 1234567.8, 'g', -1, "1.2345678e+06" ), + ftoaTest( 200000, 'g', -1, "200000" ), + ftoaTest( 2000000, 'g', -1, "2e+06" ), - ftoaTest{ 0, 'e', 5, "0.00000e+00" }, - ftoaTest{ 0, 'f', 5, "0.00000" }, - ftoaTest{ 0, 'g', 5, "0" }, - ftoaTest{ 0, 'g', -1, "0" }, + ftoaTest( 0, 'e', 5, "0.00000e+00" ), + ftoaTest( 0, 'f', 5, "0.00000" ), + ftoaTest( 0, 'g', 5, "0" ), + ftoaTest( 0, 'g', -1, "0" ), - ftoaTest{ -1, 'e', 5, "-1.00000e+00" }, - ftoaTest{ -1, 'f', 5, "-1.00000" }, - ftoaTest{ -1, 'g', 5, "-1" }, - ftoaTest{ -1, 'g', -1, "-1" }, + ftoaTest( -1, 'e', 5, "-1.00000e+00" ), + ftoaTest( -1, 'f', 5, "-1.00000" ), + ftoaTest( -1, 'g', 5, "-1" ), + ftoaTest( -1, 'g', -1, "-1" ), - ftoaTest{ 12, 'e', 5, "1.20000e+01" }, - ftoaTest{ 12, 'f', 5, "12.00000" }, - ftoaTest{ 12, 'g', 5, "12" }, - ftoaTest{ 12, 'g', -1, "12" }, + ftoaTest( 12, 'e', 5, "1.20000e+01" ), + ftoaTest( 12, 'f', 5, "12.00000" ), + ftoaTest( 12, 'g', 5, "12" ), + ftoaTest( 12, 'g', -1, "12" ), - ftoaTest{ 123456700, 'e', 5, "1.23457e+08" }, - ftoaTest{ 123456700, 'f', 5, "123456700.00000" }, - ftoaTest{ 123456700, 'g', 5, "1.2346e+08" }, - ftoaTest{ 123456700, 'g', -1, "1.234567e+08" }, + ftoaTest( 123456700, 'e', 5, "1.23457e+08" ), + ftoaTest( 123456700, 'f', 5, "123456700.00000" ), + ftoaTest( 123456700, 'g', 5, "1.2346e+08" ), + ftoaTest( 123456700, 'g', -1, "1.234567e+08" ), - ftoaTest{ 1.2345e6, 'e', 5, "1.23450e+06" }, - ftoaTest{ 1.2345e6, 'f', 5, "1234500.00000" }, - ftoaTest{ 1.2345e6, 'g', 5, "1.2345e+06" }, + ftoaTest( 1.2345e6, 'e', 5, "1.23450e+06" ), + ftoaTest( 1.2345e6, 'f', 5, "1234500.00000" ), + ftoaTest( 1.2345e6, 'g', 5, "1.2345e+06" ), - ftoaTest{ 1e23, 'e', 17, "9.99999999999999916e+22" }, - ftoaTest{ 1e23, 'f', 17, "99999999999999991611392.00000000000000000" }, - ftoaTest{ 1e23, 'g', 17, "9.9999999999999992e+22" }, + ftoaTest( 1e23, 'e', 17, "9.99999999999999916e+22" ), + ftoaTest( 1e23, 'f', 17, "99999999999999991611392.00000000000000000" ), + ftoaTest( 1e23, 'g', 17, "9.9999999999999992e+22" ), - ftoaTest{ 1e23, 'e', -1, "1e+23" }, - ftoaTest{ 1e23, 'f', -1, "100000000000000000000000" }, - ftoaTest{ 1e23, 'g', -1, "1e+23" }, + ftoaTest( 1e23, 'e', -1, "1e+23" ), + ftoaTest( 1e23, 'f', -1, "100000000000000000000000" ), + ftoaTest( 1e23, 'g', -1, "1e+23" ), - ftoaTest{ below1e23, 'e', 17, "9.99999999999999748e+22" }, - ftoaTest{ below1e23, 'f', 17, "99999999999999974834176.00000000000000000" }, - ftoaTest{ below1e23, 'g', 17, "9.9999999999999975e+22" }, + ftoaTest( below1e23, 'e', 17, "9.99999999999999748e+22" ), + ftoaTest( below1e23, 'f', 17, "99999999999999974834176.00000000000000000" ), + ftoaTest( below1e23, 'g', 17, "9.9999999999999975e+22" ), - ftoaTest{ below1e23, 'e', -1, "9.999999999999997e+22" }, - ftoaTest{ below1e23, 'f', -1, "99999999999999970000000" }, - ftoaTest{ below1e23, 'g', -1, "9.999999999999997e+22" }, + ftoaTest( below1e23, 'e', -1, "9.999999999999997e+22" ), + ftoaTest( below1e23, 'f', -1, "99999999999999970000000" ), + ftoaTest( below1e23, 'g', -1, "9.999999999999997e+22" ), - ftoaTest{ above1e23, 'e', 17, "1.00000000000000008e+23" }, - ftoaTest{ above1e23, 'f', 17, "100000000000000008388608.00000000000000000" }, - ftoaTest{ above1e23, 'g', 17, "1.0000000000000001e+23" }, + ftoaTest( above1e23, 'e', 17, "1.00000000000000008e+23" ), + ftoaTest( above1e23, 'f', 17, "100000000000000008388608.00000000000000000" ), + ftoaTest( above1e23, 'g', 17, "1.0000000000000001e+23" ), - ftoaTest{ above1e23, 'e', -1, "1.0000000000000001e+23" }, - ftoaTest{ above1e23, 'f', -1, "100000000000000010000000" }, - ftoaTest{ above1e23, 'g', -1, "1.0000000000000001e+23" }, + ftoaTest( above1e23, 'e', -1, "1.0000000000000001e+23" ), + ftoaTest( above1e23, 'f', -1, "100000000000000010000000" ), + ftoaTest( above1e23, 'g', -1, "1.0000000000000001e+23" ), - ftoaTest{ fdiv(5e-304, 1e20), 'g', -1, "5e-324" }, - ftoaTest{ fdiv(-5e-304, 1e20), 'g', -1, "-5e-324" }, + ftoaTest( fdiv(5e-304, 1e20), 'g', -1, "5e-324" ), + ftoaTest( fdiv(-5e-304, 1e20), 'g', -1, "-5e-324" ), - ftoaTest{ 32, 'g', -1, "32" }, - ftoaTest{ 32, 'g', 0, "3e+01" }, + ftoaTest( 32, 'g', -1, "32" ), + ftoaTest( 32, 'g', 0, "3e+01" ), - ftoaTest{ 100, 'x', -1, "%x" }, + ftoaTest( 100, 'x', -1, "%x" ), - ftoaTest{ math.NaN(), 'g', -1, "NaN" }, - ftoaTest{ -math.NaN(), 'g', -1, "NaN" }, - ftoaTest{ math.Inf(0), 'g', -1, "+Inf" }, - ftoaTest{ math.Inf(-1), 'g', -1, "-Inf" }, - ftoaTest{ -math.Inf(0), 'g', -1, "-Inf" }, + ftoaTest( math.NaN(), 'g', -1, "NaN" ), + ftoaTest( -math.NaN(), 'g', -1, "NaN" ), + ftoaTest( math.Inf(0), 'g', -1, "+Inf" ), + ftoaTest( math.Inf(-1), 'g', -1, "-Inf" ), + ftoaTest( -math.Inf(0), 'g', -1, "-Inf" ), - ftoaTest{ -1, 'b', -1, "-4503599627370496p-52" }, -} + ftoaTest( -1, 'b', -1, "-4503599627370496p-52" ), +) func TestFtoa(t *testing.T) { if strconv.FloatSize != 32 { diff --git a/src/lib/strconv/itoa_test.go b/src/lib/strconv/itoa_test.go index e965a1c167..7a2f86b6c6 100644 --- a/src/lib/strconv/itoa_test.go +++ b/src/lib/strconv/itoa_test.go @@ -16,29 +16,29 @@ type itoa64Test struct { out string; } -var itoa64tests = []itoa64Test { - itoa64Test{ 0, "0" }, - itoa64Test{ 1, "1" }, - itoa64Test{ -1, "-1" }, - itoa64Test{ 12345678, "12345678" }, - itoa64Test{ -987654321, "-987654321" }, - itoa64Test{ 1<<31-1, "2147483647" }, - itoa64Test{ -1<<31+1, "-2147483647" }, - itoa64Test{ 1<<31, "2147483648" }, - itoa64Test{ -1<<31, "-2147483648" }, - itoa64Test{ 1<<31+1, "2147483649" }, - itoa64Test{ -1<<31-1, "-2147483649" }, - itoa64Test{ 1<<32-1, "4294967295" }, - itoa64Test{ -1<<32+1, "-4294967295" }, - itoa64Test{ 1<<32, "4294967296" }, - itoa64Test{ -1<<32, "-4294967296" }, - itoa64Test{ 1<<32+1, "4294967297" }, - itoa64Test{ -1<<32-1, "-4294967297" }, - itoa64Test{ 1<<50, "1125899906842624" }, - itoa64Test{ 1<<63-1, "9223372036854775807" }, - itoa64Test{ -1<<63+1, "-9223372036854775807" }, - itoa64Test{ -1<<63, "-9223372036854775808" }, -} +var itoa64tests = []itoa64Test ( + itoa64Test( 0, "0" ), + itoa64Test( 1, "1" ), + itoa64Test( -1, "-1" ), + itoa64Test( 12345678, "12345678" ), + itoa64Test( -987654321, "-987654321" ), + itoa64Test( 1<<31-1, "2147483647" ), + itoa64Test( -1<<31+1, "-2147483647" ), + itoa64Test( 1<<31, "2147483648" ), + itoa64Test( -1<<31, "-2147483648" ), + itoa64Test( 1<<31+1, "2147483649" ), + itoa64Test( -1<<31-1, "-2147483649" ), + itoa64Test( 1<<32-1, "4294967295" ), + itoa64Test( -1<<32+1, "-4294967295" ), + itoa64Test( 1<<32, "4294967296" ), + itoa64Test( -1<<32, "-4294967296" ), + itoa64Test( 1<<32+1, "4294967297" ), + itoa64Test( -1<<32-1, "-4294967297" ), + itoa64Test( 1<<50, "1125899906842624" ), + itoa64Test( 1<<63-1, "9223372036854775807" ), + itoa64Test( -1<<63+1, "-9223372036854775807" ), + itoa64Test( -1<<63, "-9223372036854775808" ), +) func TestItoa(t *testing.T) { for i := 0; i < len(itoa64tests); i++ { @@ -65,11 +65,11 @@ type uitoa64Test struct { } // TODO: should be able to call this atoui64tests. -var uitoa64tests = []uitoa64Test { - uitoa64Test{ 1<<63-1, "9223372036854775807" }, - uitoa64Test{ 1<<63, "9223372036854775808" }, - uitoa64Test{ 1<<63+1, "9223372036854775809" }, - uitoa64Test{ 1<<64-2, "18446744073709551614" }, - uitoa64Test{ 1<<64-1, "18446744073709551615" }, -} +var uitoa64tests = []uitoa64Test ( + uitoa64Test( 1<<63-1, "9223372036854775807" ), + uitoa64Test( 1<<63, "9223372036854775808" ), + uitoa64Test( 1<<63+1, "9223372036854775809" ), + uitoa64Test( 1<<64-2, "18446744073709551614" ), + uitoa64Test( 1<<64-1, "18446744073709551615" ), +) diff --git a/src/lib/strconv/quote_test.go b/src/lib/strconv/quote_test.go index 8421fcde49..06d72f7537 100644 --- a/src/lib/strconv/quote_test.go +++ b/src/lib/strconv/quote_test.go @@ -14,14 +14,14 @@ type quoteTest struct { out string; } -var quotetests = []quoteTest { - quoteTest{ "\a\b\f\r\n\t\v", `"\a\b\f\r\n\t\v"` }, - quoteTest{ "\\", `"\\"` }, - quoteTest{ "abc\xffdef", `"abc\xffdef"` }, - quoteTest{ "\u263a", `"\u263a"` }, - quoteTest{ "\U0010ffff", `"\U0010ffff"` }, - quoteTest{ "\x04", `"\x04"` }, -} +var quotetests = []quoteTest ( + quoteTest( "\a\b\f\r\n\t\v", `"\a\b\f\r\n\t\v"` ), + quoteTest( "\\", `"\\"` ), + quoteTest( "abc\xffdef", `"abc\xffdef"` ), + quoteTest( "\u263a", `"\u263a"` ), + quoteTest( "\U0010ffff", `"\U0010ffff"` ), + quoteTest( "\x04", `"\x04"` ), +) func TestQuote(t *testing.T) { for i := 0; i < len(quotetests); i++ { @@ -37,46 +37,46 @@ type canBackquoteTest struct { out bool; } -var canbackquotetests = []canBackquoteTest { - canBackquoteTest{ "`", false }, - canBackquoteTest{ string(0), false }, - canBackquoteTest{ string(1), false }, - canBackquoteTest{ string(2), false }, - canBackquoteTest{ string(3), false }, - canBackquoteTest{ string(4), false }, - canBackquoteTest{ string(5), false }, - canBackquoteTest{ string(6), false }, - canBackquoteTest{ string(7), false }, - canBackquoteTest{ string(8), false }, - canBackquoteTest{ string(9), false }, - canBackquoteTest{ string(10), false }, - canBackquoteTest{ string(11), false }, - canBackquoteTest{ string(12), false }, - canBackquoteTest{ string(13), false }, - canBackquoteTest{ string(14), false }, - canBackquoteTest{ string(15), false }, - canBackquoteTest{ string(16), false }, - canBackquoteTest{ string(17), false }, - canBackquoteTest{ string(18), false }, - canBackquoteTest{ string(19), false }, - canBackquoteTest{ string(20), false }, - canBackquoteTest{ string(21), false }, - canBackquoteTest{ string(22), false }, - canBackquoteTest{ string(23), false }, - canBackquoteTest{ string(24), false }, - canBackquoteTest{ string(25), false }, - canBackquoteTest{ string(26), false }, - canBackquoteTest{ string(27), false }, - canBackquoteTest{ string(28), false }, - canBackquoteTest{ string(29), false }, - canBackquoteTest{ string(30), false }, - canBackquoteTest{ string(31), false }, - canBackquoteTest{ `' !"#$%&'()*+,-./:;<=>?@[\]^_{|}~`, true }, - canBackquoteTest{ `0123456789`, true }, - canBackquoteTest{ `ABCDEFGHIJKLMNOPQRSTUVWXYZ`, true }, - canBackquoteTest{ `abcdefghijklmnopqrstuvwxyz`, true }, - canBackquoteTest{ `☺`, true }, -} +var canbackquotetests = []canBackquoteTest ( + canBackquoteTest( "`", false ), + canBackquoteTest( string(0), false ), + canBackquoteTest( string(1), false ), + canBackquoteTest( string(2), false ), + canBackquoteTest( string(3), false ), + canBackquoteTest( string(4), false ), + canBackquoteTest( string(5), false ), + canBackquoteTest( string(6), false ), + canBackquoteTest( string(7), false ), + canBackquoteTest( string(8), false ), + canBackquoteTest( string(9), false ), + canBackquoteTest( string(10), false ), + canBackquoteTest( string(11), false ), + canBackquoteTest( string(12), false ), + canBackquoteTest( string(13), false ), + canBackquoteTest( string(14), false ), + canBackquoteTest( string(15), false ), + canBackquoteTest( string(16), false ), + canBackquoteTest( string(17), false ), + canBackquoteTest( string(18), false ), + canBackquoteTest( string(19), false ), + canBackquoteTest( string(20), false ), + canBackquoteTest( string(21), false ), + canBackquoteTest( string(22), false ), + canBackquoteTest( string(23), false ), + canBackquoteTest( string(24), false ), + canBackquoteTest( string(25), false ), + canBackquoteTest( string(26), false ), + canBackquoteTest( string(27), false ), + canBackquoteTest( string(28), false ), + canBackquoteTest( string(29), false ), + canBackquoteTest( string(30), false ), + canBackquoteTest( string(31), false ), + canBackquoteTest( `' !"#$%&'()*+,-./:;<=>?@[\]^_{|}~`, true ), + canBackquoteTest( `0123456789`, true ), + canBackquoteTest( `ABCDEFGHIJKLMNOPQRSTUVWXYZ`, true ), + canBackquoteTest( `abcdefghijklmnopqrstuvwxyz`, true ), + canBackquoteTest( `☺`, true ), +) func TestCanBackquote(t *testing.T) { for i := 0; i < len(canbackquotetests); i++ { diff --git a/src/lib/strings_test.go b/src/lib/strings_test.go index 2cbf70b93b..0efe254ce5 100644 --- a/src/lib/strings_test.go +++ b/src/lib/strings_test.go @@ -30,10 +30,10 @@ type ExplodeTest struct { s string; a []string; } -var explodetests = []ExplodeTest { - ExplodeTest{ abcd, []string{"a", "b", "c", "d"} }, - ExplodeTest{ faces, []string{"☺", "☻", "☹" } }, -} +var explodetests = []ExplodeTest ( + ExplodeTest( abcd, []string("a", "b", "c", "d") ), + ExplodeTest( faces, []string("☺", "☻", "☹" ) ), +) func TestExplode(t *testing.T) { for i := 0; i < len(explodetests); i++ { tt := explodetests[i]; @@ -54,16 +54,16 @@ type SplitTest struct { sep string; a []string; } -var splittests = []SplitTest { - SplitTest{ abcd, "a", []string{"", "bcd"} }, - SplitTest{ abcd, "z", []string{"abcd"} }, - SplitTest{ abcd, "", []string{"a", "b", "c", "d"} }, - SplitTest{ commas, ",", []string{"1", "2", "3", "4"} }, - SplitTest{ dots, "...", []string{"1", ".2", ".3", ".4"} }, - SplitTest{ faces, "☹", []string{"☺☻", ""} }, - SplitTest{ faces, "~", []string{faces} }, - SplitTest{ faces, "", []string{"☺", "☻", "☹"} }, -} +var splittests = []SplitTest ( + SplitTest( abcd, "a", []string("", "bcd") ), + SplitTest( abcd, "z", []string("abcd") ), + SplitTest( abcd, "", []string("a", "b", "c", "d") ), + SplitTest( commas, ",", []string("1", "2", "3", "4") ), + SplitTest( dots, "...", []string("1", ".2", ".3", ".4") ), + SplitTest( faces, "☹", []string("☺☻", "") ), + SplitTest( faces, "~", []string(faces) ), + SplitTest( faces, "", []string("☺", "☻", "☹") ), +) func TestSplit(t *testing.T) { for i := 0; i < len(splittests); i++ { tt := splittests[i]; diff --git a/src/lib/tabwriter/tabwriter.go b/src/lib/tabwriter/tabwriter.go index 21aca62d6f..6fea62ebae 100644 --- a/src/lib/tabwriter/tabwriter.go +++ b/src/lib/tabwriter/tabwriter.go @@ -202,7 +202,7 @@ func (b *Writer) write0(buf []byte) *os.Error { } -var newline = []byte{'\n'} +var newline = []byte('\n') func (b *Writer) writePadding(textw, cellw int) (err *os.Error) { if b.padbytes[0] == '\t' { diff --git a/src/lib/time/time.go b/src/lib/time/time.go index 28607daa97..27db87ff3d 100644 --- a/src/lib/time/time.go +++ b/src/lib/time/time.go @@ -46,12 +46,12 @@ type Time struct { Zone string; } -var nonleapyear = []int{ +var nonleapyear = []int( 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 -} -var leapyear = []int{ +) +var leapyear = []int( 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 -} +) func months(year int64) []int { if year%4 == 0 && (year%100 != 0 || year%400 == 0) { @@ -221,7 +221,7 @@ func (t *Time) Seconds() int64 { return sec } -var _LongDayNames = []string{ +var _LongDayNames = []string( "Sunday", "Monday", "Tuesday", @@ -229,9 +229,9 @@ var _LongDayNames = []string{ "Thursday", "Friday", "Saturday" -} +) -var _ShortDayNames = []string{ +var _ShortDayNames = []string( "Sun", "Mon", "Tue", @@ -239,9 +239,9 @@ var _ShortDayNames = []string{ "Thu", "Fri", "Sat" -} +) -var _ShortMonthNames = []string{ +var _ShortMonthNames = []string( "Jan", "Feb", "Mar", @@ -254,7 +254,7 @@ var _ShortMonthNames = []string{ "Oct", "Nov", "Dec" -} +) func _Copy(dst []byte, s string) { for i := 0; i < len(s); i++ { diff --git a/src/lib/time/time_test.go b/src/lib/time/time_test.go index 730b7862f0..453c34e962 100644 --- a/src/lib/time/time_test.go +++ b/src/lib/time/time_test.go @@ -14,20 +14,20 @@ type _TimeTest struct { golden Time; } -var utctests = []_TimeTest { - _TimeTest{0, Time{1970, 1, 1, 0, 0, 0, Thursday, 0, "GMT"}}, - _TimeTest{1221681866, Time{2008, 9, 17, 20, 4, 26, Wednesday, 0, "GMT"}}, - _TimeTest{-1221681866, Time{1931, 4, 16, 3, 55, 34, Thursday, 0, "GMT"}}, - _TimeTest{1e18, Time{31688740476, 10, 23, 1, 46, 40, Friday, 0, "GMT"}}, - _TimeTest{-1e18, Time{-31688736537, 3, 10, 22, 13, 20, Tuesday, 0, "GMT"}}, - _TimeTest{0x7fffffffffffffff, Time{292277026596, 12, 4, 15, 30, 7, Sunday, 0, "GMT"}}, - _TimeTest{-0x8000000000000000, Time{-292277022657, 1, 27, 8, 29, 52, Sunday, 0, "GMT"}} -} +var utctests = []_TimeTest ( + _TimeTest(0, Time(1970, 1, 1, 0, 0, 0, Thursday, 0, "GMT")), + _TimeTest(1221681866, Time(2008, 9, 17, 20, 4, 26, Wednesday, 0, "GMT")), + _TimeTest(-1221681866, Time(1931, 4, 16, 3, 55, 34, Thursday, 0, "GMT")), + _TimeTest(1e18, Time(31688740476, 10, 23, 1, 46, 40, Friday, 0, "GMT")), + _TimeTest(-1e18, Time(-31688736537, 3, 10, 22, 13, 20, Tuesday, 0, "GMT")), + _TimeTest(0x7fffffffffffffff, Time(292277026596, 12, 4, 15, 30, 7, Sunday, 0, "GMT")), + _TimeTest(-0x8000000000000000, Time(-292277022657, 1, 27, 8, 29, 52, Sunday, 0, "GMT")) +) -var localtests = []_TimeTest { - _TimeTest{0, Time{1969, 12, 31, 16, 0, 0, Wednesday, -8*60*60, "PST"}}, - _TimeTest{1221681866, Time{2008, 9, 17, 13, 4, 26, Wednesday, -7*60*60, "PDT"}} -} +var localtests = []_TimeTest ( + _TimeTest(0, Time(1969, 12, 31, 16, 0, 0, Wednesday, -8*60*60, "PST")), + _TimeTest(1221681866, Time(2008, 9, 17, 13, 4, 26, Wednesday, -7*60*60, "PDT")) +) func _Same(t, u *Time) bool { return t.Year == u.Year diff --git a/src/lib/time/zoneinfo.go b/src/lib/time/zoneinfo.go index 9f7499c3da..5dc74d4ee1 100644 --- a/src/lib/time/zoneinfo.go +++ b/src/lib/time/zoneinfo.go @@ -87,7 +87,7 @@ type _Zonetime struct { func parseinfo(bytes []byte) (zt []_Zonetime, err *os.Error) { - data1 := _Data{bytes, false}; + data1 := _Data(bytes, false); data := &data1; // 4-byte magic "TZif" @@ -127,21 +127,21 @@ func parseinfo(bytes []byte) (zt []_Zonetime, err *os.Error) { } // Transition times. - txtimes1 := _Data{data.Read(n[NTime]*4), false}; + txtimes1 := _Data(data.Read(n[NTime]*4), false); txtimes := &txtimes1; // Time zone indices for transition times. txzones := data.Read(n[NTime]); // Zone info structures - zonedata1 := _Data{data.Read(n[NZone]*6), false}; + zonedata1 := _Data(data.Read(n[NZone]*6), false); zonedata := &zonedata1; // Time zone abbreviations. abbrev := data.Read(n[NChar]); // Leap-second time pairs - leapdata1 := _Data{data.Read(n[NLeap]*8), false}; + leapdata1 := _Data(data.Read(n[NLeap]*8), false); leapdata := &leapdata1; // Whether tx times associated with local time types diff --git a/src/lib/unicode/letter.go b/src/lib/unicode/letter.go index 3b1221b87b..61310bca91 100644 --- a/src/lib/unicode/letter.go +++ b/src/lib/unicode/letter.go @@ -18,512 +18,512 @@ type Range struct { stride int; } -var Upper = []Range{ - Range{0x0041, 0x005a, 1}, - Range{0x00c0, 0x00d6, 1}, - Range{0x00d8, 0x00de, 1}, - Range{0x0100, 0x0136, 2}, - Range{0x0139, 0x0147, 2}, - Range{0x014a, 0x0176, 2}, - Range{0x0178, 0x0179, 1}, - Range{0x017b, 0x017d, 2}, - Range{0x0181, 0x0182, 1}, - Range{0x0184, 0x0184, 1}, - Range{0x0186, 0x0187, 1}, - Range{0x0189, 0x018b, 1}, - Range{0x018e, 0x0191, 1}, - Range{0x0193, 0x0194, 1}, - Range{0x0196, 0x0198, 1}, - Range{0x019c, 0x019d, 1}, - Range{0x019f, 0x01a0, 1}, - Range{0x01a2, 0x01a4, 2}, - Range{0x01a6, 0x01a7, 1}, - Range{0x01a9, 0x01ac, 3}, - Range{0x01ae, 0x01af, 1}, - Range{0x01b1, 0x01b3, 1}, - Range{0x01b5, 0x01b5, 1}, - Range{0x01b7, 0x01b8, 1}, - Range{0x01bc, 0x01c4, 8}, - Range{0x01c7, 0x01cd, 3}, - Range{0x01cf, 0x01db, 2}, - Range{0x01de, 0x01ee, 2}, - Range{0x01f1, 0x01f4, 3}, - Range{0x01f6, 0x01f8, 1}, - Range{0x01fa, 0x0232, 2}, - Range{0x023a, 0x023b, 1}, - Range{0x023d, 0x023e, 1}, - Range{0x0241, 0x0241, 1}, - Range{0x0243, 0x0246, 1}, - Range{0x0248, 0x024e, 2}, - Range{0x0370, 0x0372, 2}, - Range{0x0376, 0x0386, 16}, - Range{0x0388, 0x038a, 1}, - Range{0x038c, 0x038c, 1}, - Range{0x038e, 0x038f, 1}, - Range{0x0391, 0x03a1, 1}, - Range{0x03a3, 0x03ab, 1}, - Range{0x03cf, 0x03cf, 1}, - Range{0x03d2, 0x03d4, 1}, - Range{0x03d8, 0x03ee, 2}, - Range{0x03f4, 0x03f7, 3}, - Range{0x03f9, 0x03fa, 1}, - Range{0x03fd, 0x042f, 1}, - Range{0x0460, 0x0480, 2}, - Range{0x048a, 0x04be, 2}, - Range{0x04c0, 0x04c1, 1}, - Range{0x04c3, 0x04cd, 2}, - Range{0x04d0, 0x0522, 2}, - Range{0x0531, 0x0556, 1}, - Range{0x10a0, 0x10c5, 1}, - Range{0x1e00, 0x1e94, 2}, - Range{0x1e9e, 0x1efe, 2}, - Range{0x1f08, 0x1f0f, 1}, - Range{0x1f18, 0x1f1d, 1}, - Range{0x1f28, 0x1f2f, 1}, - Range{0x1f38, 0x1f3f, 1}, - Range{0x1f48, 0x1f4d, 1}, - Range{0x1f59, 0x1f5f, 2}, - Range{0x1f68, 0x1f6f, 1}, - Range{0x1fb8, 0x1fbb, 1}, - Range{0x1fc8, 0x1fcb, 1}, - Range{0x1fd8, 0x1fdb, 1}, - Range{0x1fe8, 0x1fec, 1}, - Range{0x1ff8, 0x1ffb, 1}, - Range{0x2102, 0x2107, 5}, - Range{0x210b, 0x210d, 1}, - Range{0x2110, 0x2112, 1}, - Range{0x2115, 0x2115, 1}, - Range{0x2119, 0x211d, 1}, - Range{0x2124, 0x2128, 2}, - Range{0x212a, 0x212d, 1}, - Range{0x2130, 0x2133, 1}, - Range{0x213e, 0x213f, 1}, - Range{0x2145, 0x2183, 62}, - Range{0x2c00, 0x2c2e, 1}, - Range{0x2c60, 0x2c60, 1}, - Range{0x2c62, 0x2c64, 1}, - Range{0x2c67, 0x2c6b, 2}, - Range{0x2c6d, 0x2c6f, 1}, - Range{0x2c72, 0x2c75, 3}, - Range{0x2c80, 0x2ce2, 2}, - Range{0xa640, 0xa65e, 2}, - Range{0xa662, 0xa66c, 2}, - Range{0xa680, 0xa696, 2}, - Range{0xa722, 0xa72e, 2}, - Range{0xa732, 0xa76e, 2}, - Range{0xa779, 0xa77b, 2}, - Range{0xa77d, 0xa77e, 1}, - Range{0xa780, 0xa786, 2}, - Range{0xa78b, 0xa78b, 1}, - Range{0xff21, 0xff3a, 1}, - Range{0x10400, 0x10427, 1}, - Range{0x1d400, 0x1d419, 1}, - Range{0x1d434, 0x1d44d, 1}, - Range{0x1d468, 0x1d481, 1}, - Range{0x1d49c, 0x1d49c, 1}, - Range{0x1d49e, 0x1d49f, 1}, - Range{0x1d4a2, 0x1d4a2, 1}, - Range{0x1d4a5, 0x1d4a6, 1}, - Range{0x1d4a9, 0x1d4ac, 1}, - Range{0x1d4ae, 0x1d4b5, 1}, - Range{0x1d4d0, 0x1d4e9, 1}, - Range{0x1d504, 0x1d505, 1}, - Range{0x1d507, 0x1d50a, 1}, - Range{0x1d50d, 0x1d514, 1}, - Range{0x1d516, 0x1d51c, 1}, - Range{0x1d538, 0x1d539, 1}, - Range{0x1d53b, 0x1d53e, 1}, - Range{0x1d540, 0x1d544, 1}, - Range{0x1d546, 0x1d546, 1}, - Range{0x1d54a, 0x1d550, 1}, - Range{0x1d56c, 0x1d585, 1}, - Range{0x1d5a0, 0x1d5b9, 1}, - Range{0x1d5d4, 0x1d5ed, 1}, - Range{0x1d608, 0x1d621, 1}, - Range{0x1d63c, 0x1d655, 1}, - Range{0x1d670, 0x1d689, 1}, - Range{0x1d6a8, 0x1d6c0, 1}, - Range{0x1d6e2, 0x1d6fa, 1}, - Range{0x1d71c, 0x1d734, 1}, - Range{0x1d756, 0x1d76e, 1}, - Range{0x1d790, 0x1d7a8, 1}, - Range{0x1d7ca, 0x1d7ca, 1}, -} +var Upper = []Range( + Range(0x0041, 0x005a, 1), + Range(0x00c0, 0x00d6, 1), + Range(0x00d8, 0x00de, 1), + Range(0x0100, 0x0136, 2), + Range(0x0139, 0x0147, 2), + Range(0x014a, 0x0176, 2), + Range(0x0178, 0x0179, 1), + Range(0x017b, 0x017d, 2), + Range(0x0181, 0x0182, 1), + Range(0x0184, 0x0184, 1), + Range(0x0186, 0x0187, 1), + Range(0x0189, 0x018b, 1), + Range(0x018e, 0x0191, 1), + Range(0x0193, 0x0194, 1), + Range(0x0196, 0x0198, 1), + Range(0x019c, 0x019d, 1), + Range(0x019f, 0x01a0, 1), + Range(0x01a2, 0x01a4, 2), + Range(0x01a6, 0x01a7, 1), + Range(0x01a9, 0x01ac, 3), + Range(0x01ae, 0x01af, 1), + Range(0x01b1, 0x01b3, 1), + Range(0x01b5, 0x01b5, 1), + Range(0x01b7, 0x01b8, 1), + Range(0x01bc, 0x01c4, 8), + Range(0x01c7, 0x01cd, 3), + Range(0x01cf, 0x01db, 2), + Range(0x01de, 0x01ee, 2), + Range(0x01f1, 0x01f4, 3), + Range(0x01f6, 0x01f8, 1), + Range(0x01fa, 0x0232, 2), + Range(0x023a, 0x023b, 1), + Range(0x023d, 0x023e, 1), + Range(0x0241, 0x0241, 1), + Range(0x0243, 0x0246, 1), + Range(0x0248, 0x024e, 2), + Range(0x0370, 0x0372, 2), + Range(0x0376, 0x0386, 16), + Range(0x0388, 0x038a, 1), + Range(0x038c, 0x038c, 1), + Range(0x038e, 0x038f, 1), + Range(0x0391, 0x03a1, 1), + Range(0x03a3, 0x03ab, 1), + Range(0x03cf, 0x03cf, 1), + Range(0x03d2, 0x03d4, 1), + Range(0x03d8, 0x03ee, 2), + Range(0x03f4, 0x03f7, 3), + Range(0x03f9, 0x03fa, 1), + Range(0x03fd, 0x042f, 1), + Range(0x0460, 0x0480, 2), + Range(0x048a, 0x04be, 2), + Range(0x04c0, 0x04c1, 1), + Range(0x04c3, 0x04cd, 2), + Range(0x04d0, 0x0522, 2), + Range(0x0531, 0x0556, 1), + Range(0x10a0, 0x10c5, 1), + Range(0x1e00, 0x1e94, 2), + Range(0x1e9e, 0x1efe, 2), + Range(0x1f08, 0x1f0f, 1), + Range(0x1f18, 0x1f1d, 1), + Range(0x1f28, 0x1f2f, 1), + Range(0x1f38, 0x1f3f, 1), + Range(0x1f48, 0x1f4d, 1), + Range(0x1f59, 0x1f5f, 2), + Range(0x1f68, 0x1f6f, 1), + Range(0x1fb8, 0x1fbb, 1), + Range(0x1fc8, 0x1fcb, 1), + Range(0x1fd8, 0x1fdb, 1), + Range(0x1fe8, 0x1fec, 1), + Range(0x1ff8, 0x1ffb, 1), + Range(0x2102, 0x2107, 5), + Range(0x210b, 0x210d, 1), + Range(0x2110, 0x2112, 1), + Range(0x2115, 0x2115, 1), + Range(0x2119, 0x211d, 1), + Range(0x2124, 0x2128, 2), + Range(0x212a, 0x212d, 1), + Range(0x2130, 0x2133, 1), + Range(0x213e, 0x213f, 1), + Range(0x2145, 0x2183, 62), + Range(0x2c00, 0x2c2e, 1), + Range(0x2c60, 0x2c60, 1), + Range(0x2c62, 0x2c64, 1), + Range(0x2c67, 0x2c6b, 2), + Range(0x2c6d, 0x2c6f, 1), + Range(0x2c72, 0x2c75, 3), + Range(0x2c80, 0x2ce2, 2), + Range(0xa640, 0xa65e, 2), + Range(0xa662, 0xa66c, 2), + Range(0xa680, 0xa696, 2), + Range(0xa722, 0xa72e, 2), + Range(0xa732, 0xa76e, 2), + Range(0xa779, 0xa77b, 2), + Range(0xa77d, 0xa77e, 1), + Range(0xa780, 0xa786, 2), + Range(0xa78b, 0xa78b, 1), + Range(0xff21, 0xff3a, 1), + Range(0x10400, 0x10427, 1), + Range(0x1d400, 0x1d419, 1), + Range(0x1d434, 0x1d44d, 1), + Range(0x1d468, 0x1d481, 1), + Range(0x1d49c, 0x1d49c, 1), + Range(0x1d49e, 0x1d49f, 1), + Range(0x1d4a2, 0x1d4a2, 1), + Range(0x1d4a5, 0x1d4a6, 1), + Range(0x1d4a9, 0x1d4ac, 1), + Range(0x1d4ae, 0x1d4b5, 1), + Range(0x1d4d0, 0x1d4e9, 1), + Range(0x1d504, 0x1d505, 1), + Range(0x1d507, 0x1d50a, 1), + Range(0x1d50d, 0x1d514, 1), + Range(0x1d516, 0x1d51c, 1), + Range(0x1d538, 0x1d539, 1), + Range(0x1d53b, 0x1d53e, 1), + Range(0x1d540, 0x1d544, 1), + Range(0x1d546, 0x1d546, 1), + Range(0x1d54a, 0x1d550, 1), + Range(0x1d56c, 0x1d585, 1), + Range(0x1d5a0, 0x1d5b9, 1), + Range(0x1d5d4, 0x1d5ed, 1), + Range(0x1d608, 0x1d621, 1), + Range(0x1d63c, 0x1d655, 1), + Range(0x1d670, 0x1d689, 1), + Range(0x1d6a8, 0x1d6c0, 1), + Range(0x1d6e2, 0x1d6fa, 1), + Range(0x1d71c, 0x1d734, 1), + Range(0x1d756, 0x1d76e, 1), + Range(0x1d790, 0x1d7a8, 1), + Range(0x1d7ca, 0x1d7ca, 1), +) -var Letter = []Range { - Range{0x0041, 0x005a, 1}, - Range{0x0061, 0x007a, 1}, - Range{0x00aa, 0x00b5, 11}, - Range{0x00ba, 0x00ba, 1}, - Range{0x00c0, 0x00d6, 1}, - Range{0x00d8, 0x00f6, 1}, - Range{0x00f8, 0x02c1, 1}, - Range{0x02c6, 0x02d1, 1}, - Range{0x02e0, 0x02e4, 1}, - Range{0x02ec, 0x02ee, 2}, - Range{0x0370, 0x0374, 1}, - Range{0x0376, 0x0377, 1}, - Range{0x037a, 0x037d, 1}, - Range{0x0386, 0x0386, 1}, - Range{0x0388, 0x038a, 1}, - Range{0x038c, 0x038c, 1}, - Range{0x038e, 0x03a1, 1}, - Range{0x03a3, 0x03f5, 1}, - Range{0x03f7, 0x0481, 1}, - Range{0x048a, 0x0523, 1}, - Range{0x0531, 0x0556, 1}, - Range{0x0559, 0x0559, 1}, - Range{0x0561, 0x0587, 1}, - Range{0x05d0, 0x05ea, 1}, - Range{0x05f0, 0x05f2, 1}, - Range{0x0621, 0x064a, 1}, - Range{0x066e, 0x066f, 1}, - Range{0x0671, 0x06d3, 1}, - Range{0x06d5, 0x06d5, 1}, - Range{0x06e5, 0x06e6, 1}, - Range{0x06ee, 0x06ef, 1}, - Range{0x06fa, 0x06fc, 1}, - Range{0x06ff, 0x0710, 17}, - Range{0x0712, 0x072f, 1}, - Range{0x074d, 0x07a5, 1}, - Range{0x07b1, 0x07b1, 1}, - Range{0x07ca, 0x07ea, 1}, - Range{0x07f4, 0x07f5, 1}, - Range{0x07fa, 0x07fa, 1}, - Range{0x0904, 0x0939, 1}, - Range{0x093d, 0x0950, 19}, - Range{0x0958, 0x0961, 1}, - Range{0x0971, 0x0972, 1}, - Range{0x097b, 0x097f, 1}, - Range{0x0985, 0x098c, 1}, - Range{0x098f, 0x0990, 1}, - Range{0x0993, 0x09a8, 1}, - Range{0x09aa, 0x09b0, 1}, - Range{0x09b2, 0x09b2, 1}, - Range{0x09b6, 0x09b9, 1}, - Range{0x09bd, 0x09ce, 17}, - Range{0x09dc, 0x09dd, 1}, - Range{0x09df, 0x09e1, 1}, - Range{0x09f0, 0x09f1, 1}, - Range{0x0a05, 0x0a0a, 1}, - Range{0x0a0f, 0x0a10, 1}, - Range{0x0a13, 0x0a28, 1}, - Range{0x0a2a, 0x0a30, 1}, - Range{0x0a32, 0x0a33, 1}, - Range{0x0a35, 0x0a36, 1}, - Range{0x0a38, 0x0a39, 1}, - Range{0x0a59, 0x0a5c, 1}, - Range{0x0a5e, 0x0a5e, 1}, - Range{0x0a72, 0x0a74, 1}, - Range{0x0a85, 0x0a8d, 1}, - Range{0x0a8f, 0x0a91, 1}, - Range{0x0a93, 0x0aa8, 1}, - Range{0x0aaa, 0x0ab0, 1}, - Range{0x0ab2, 0x0ab3, 1}, - Range{0x0ab5, 0x0ab9, 1}, - Range{0x0abd, 0x0ad0, 19}, - Range{0x0ae0, 0x0ae1, 1}, - Range{0x0b05, 0x0b0c, 1}, - Range{0x0b0f, 0x0b10, 1}, - Range{0x0b13, 0x0b28, 1}, - Range{0x0b2a, 0x0b30, 1}, - Range{0x0b32, 0x0b33, 1}, - Range{0x0b35, 0x0b39, 1}, - Range{0x0b3d, 0x0b3d, 1}, - Range{0x0b5c, 0x0b5d, 1}, - Range{0x0b5f, 0x0b61, 1}, - Range{0x0b71, 0x0b83, 18}, - Range{0x0b85, 0x0b8a, 1}, - Range{0x0b8e, 0x0b90, 1}, - Range{0x0b92, 0x0b95, 1}, - Range{0x0b99, 0x0b9a, 1}, - Range{0x0b9c, 0x0b9c, 1}, - Range{0x0b9e, 0x0b9f, 1}, - Range{0x0ba3, 0x0ba4, 1}, - Range{0x0ba8, 0x0baa, 1}, - Range{0x0bae, 0x0bb9, 1}, - Range{0x0bd0, 0x0bd0, 1}, - Range{0x0c05, 0x0c0c, 1}, - Range{0x0c0e, 0x0c10, 1}, - Range{0x0c12, 0x0c28, 1}, - Range{0x0c2a, 0x0c33, 1}, - Range{0x0c35, 0x0c39, 1}, - Range{0x0c3d, 0x0c3d, 1}, - Range{0x0c58, 0x0c59, 1}, - Range{0x0c60, 0x0c61, 1}, - Range{0x0c85, 0x0c8c, 1}, - Range{0x0c8e, 0x0c90, 1}, - Range{0x0c92, 0x0ca8, 1}, - Range{0x0caa, 0x0cb3, 1}, - Range{0x0cb5, 0x0cb9, 1}, - Range{0x0cbd, 0x0cde, 33}, - Range{0x0ce0, 0x0ce1, 1}, - Range{0x0d05, 0x0d0c, 1}, - Range{0x0d0e, 0x0d10, 1}, - Range{0x0d12, 0x0d28, 1}, - Range{0x0d2a, 0x0d39, 1}, - Range{0x0d3d, 0x0d3d, 1}, - Range{0x0d60, 0x0d61, 1}, - Range{0x0d7a, 0x0d7f, 1}, - Range{0x0d85, 0x0d96, 1}, - Range{0x0d9a, 0x0db1, 1}, - Range{0x0db3, 0x0dbb, 1}, - Range{0x0dbd, 0x0dbd, 1}, - Range{0x0dc0, 0x0dc6, 1}, - Range{0x0e01, 0x0e30, 1}, - Range{0x0e32, 0x0e33, 1}, - Range{0x0e40, 0x0e46, 1}, - Range{0x0e81, 0x0e82, 1}, - Range{0x0e84, 0x0e84, 1}, - Range{0x0e87, 0x0e88, 1}, - Range{0x0e8a, 0x0e8d, 3}, - Range{0x0e94, 0x0e97, 1}, - Range{0x0e99, 0x0e9f, 1}, - Range{0x0ea1, 0x0ea3, 1}, - Range{0x0ea5, 0x0ea7, 2}, - Range{0x0eaa, 0x0eab, 1}, - Range{0x0ead, 0x0eb0, 1}, - Range{0x0eb2, 0x0eb3, 1}, - Range{0x0ebd, 0x0ebd, 1}, - Range{0x0ec0, 0x0ec4, 1}, - Range{0x0ec6, 0x0ec6, 1}, - Range{0x0edc, 0x0edd, 1}, - Range{0x0f00, 0x0f00, 1}, - Range{0x0f40, 0x0f47, 1}, - Range{0x0f49, 0x0f6c, 1}, - Range{0x0f88, 0x0f8b, 1}, - Range{0x1000, 0x102a, 1}, - Range{0x103f, 0x103f, 1}, - Range{0x1050, 0x1055, 1}, - Range{0x105a, 0x105d, 1}, - Range{0x1061, 0x1061, 1}, - Range{0x1065, 0x1066, 1}, - Range{0x106e, 0x1070, 1}, - Range{0x1075, 0x1081, 1}, - Range{0x108e, 0x108e, 1}, - Range{0x10a0, 0x10c5, 1}, - Range{0x10d0, 0x10fa, 1}, - Range{0x10fc, 0x10fc, 1}, - Range{0x1100, 0x1159, 1}, - Range{0x115f, 0x11a2, 1}, - Range{0x11a8, 0x11f9, 1}, - Range{0x1200, 0x1248, 1}, - Range{0x124a, 0x124d, 1}, - Range{0x1250, 0x1256, 1}, - Range{0x1258, 0x1258, 1}, - Range{0x125a, 0x125d, 1}, - Range{0x1260, 0x1288, 1}, - Range{0x128a, 0x128d, 1}, - Range{0x1290, 0x12b0, 1}, - Range{0x12b2, 0x12b5, 1}, - Range{0x12b8, 0x12be, 1}, - Range{0x12c0, 0x12c0, 1}, - Range{0x12c2, 0x12c5, 1}, - Range{0x12c8, 0x12d6, 1}, - Range{0x12d8, 0x1310, 1}, - Range{0x1312, 0x1315, 1}, - Range{0x1318, 0x135a, 1}, - Range{0x1380, 0x138f, 1}, - Range{0x13a0, 0x13f4, 1}, - Range{0x1401, 0x166c, 1}, - Range{0x166f, 0x1676, 1}, - Range{0x1681, 0x169a, 1}, - Range{0x16a0, 0x16ea, 1}, - Range{0x1700, 0x170c, 1}, - Range{0x170e, 0x1711, 1}, - Range{0x1720, 0x1731, 1}, - Range{0x1740, 0x1751, 1}, - Range{0x1760, 0x176c, 1}, - Range{0x176e, 0x1770, 1}, - Range{0x1780, 0x17b3, 1}, - Range{0x17d7, 0x17dc, 5}, - Range{0x1820, 0x1877, 1}, - Range{0x1880, 0x18a8, 1}, - Range{0x18aa, 0x18aa, 1}, - Range{0x1900, 0x191c, 1}, - Range{0x1950, 0x196d, 1}, - Range{0x1970, 0x1974, 1}, - Range{0x1980, 0x19a9, 1}, - Range{0x19c1, 0x19c7, 1}, - Range{0x1a00, 0x1a16, 1}, - Range{0x1b05, 0x1b33, 1}, - Range{0x1b45, 0x1b4b, 1}, - Range{0x1b83, 0x1ba0, 1}, - Range{0x1bae, 0x1baf, 1}, - Range{0x1c00, 0x1c23, 1}, - Range{0x1c4d, 0x1c4f, 1}, - Range{0x1c5a, 0x1c7d, 1}, - Range{0x1d00, 0x1dbf, 1}, - Range{0x1e00, 0x1f15, 1}, - Range{0x1f18, 0x1f1d, 1}, - Range{0x1f20, 0x1f45, 1}, - Range{0x1f48, 0x1f4d, 1}, - Range{0x1f50, 0x1f57, 1}, - Range{0x1f59, 0x1f5d, 2}, - Range{0x1f5f, 0x1f7d, 1}, - Range{0x1f80, 0x1fb4, 1}, - Range{0x1fb6, 0x1fbc, 1}, - Range{0x1fbe, 0x1fbe, 1}, - Range{0x1fc2, 0x1fc4, 1}, - Range{0x1fc6, 0x1fcc, 1}, - Range{0x1fd0, 0x1fd3, 1}, - Range{0x1fd6, 0x1fdb, 1}, - Range{0x1fe0, 0x1fec, 1}, - Range{0x1ff2, 0x1ff4, 1}, - Range{0x1ff6, 0x1ffc, 1}, - Range{0x2071, 0x207f, 14}, - Range{0x2090, 0x2094, 1}, - Range{0x2102, 0x2107, 5}, - Range{0x210a, 0x2113, 1}, - Range{0x2115, 0x2115, 1}, - Range{0x2119, 0x211d, 1}, - Range{0x2124, 0x2128, 2}, - Range{0x212a, 0x212d, 1}, - Range{0x212f, 0x2139, 1}, - Range{0x213c, 0x213f, 1}, - Range{0x2145, 0x2149, 1}, - Range{0x214e, 0x214e, 1}, - Range{0x2183, 0x2184, 1}, - Range{0x2c00, 0x2c2e, 1}, - Range{0x2c30, 0x2c5e, 1}, - Range{0x2c60, 0x2c6f, 1}, - Range{0x2c71, 0x2c7d, 1}, - Range{0x2c80, 0x2ce4, 1}, - Range{0x2d00, 0x2d25, 1}, - Range{0x2d30, 0x2d65, 1}, - Range{0x2d6f, 0x2d6f, 1}, - Range{0x2d80, 0x2d96, 1}, - Range{0x2da0, 0x2da6, 1}, - Range{0x2da8, 0x2dae, 1}, - Range{0x2db0, 0x2db6, 1}, - Range{0x2db8, 0x2dbe, 1}, - Range{0x2dc0, 0x2dc6, 1}, - Range{0x2dc8, 0x2dce, 1}, - Range{0x2dd0, 0x2dd6, 1}, - Range{0x2dd8, 0x2dde, 1}, - Range{0x2e2f, 0x2e2f, 1}, - Range{0x3005, 0x3006, 1}, - Range{0x3031, 0x3035, 1}, - Range{0x303b, 0x303c, 1}, - Range{0x3041, 0x3096, 1}, - Range{0x309d, 0x309f, 1}, - Range{0x30a1, 0x30fa, 1}, - Range{0x30fc, 0x30ff, 1}, - Range{0x3105, 0x312d, 1}, - Range{0x3131, 0x318e, 1}, - Range{0x31a0, 0x31b7, 1}, - Range{0x31f0, 0x31ff, 1}, - Range{0x3400, 0x4db5, 1}, - Range{0x4e00, 0x9fc3, 1}, - Range{0xa000, 0xa48c, 1}, - Range{0xa500, 0xa60c, 1}, - Range{0xa610, 0xa61f, 1}, - Range{0xa62a, 0xa62b, 1}, - Range{0xa640, 0xa65f, 1}, - Range{0xa662, 0xa66e, 1}, - Range{0xa67f, 0xa697, 1}, - Range{0xa717, 0xa71f, 1}, - Range{0xa722, 0xa788, 1}, - Range{0xa78b, 0xa78c, 1}, - Range{0xa7fb, 0xa801, 1}, - Range{0xa803, 0xa805, 1}, - Range{0xa807, 0xa80a, 1}, - Range{0xa80c, 0xa822, 1}, - Range{0xa840, 0xa873, 1}, - Range{0xa882, 0xa8b3, 1}, - Range{0xa90a, 0xa925, 1}, - Range{0xa930, 0xa946, 1}, - Range{0xaa00, 0xaa28, 1}, - Range{0xaa40, 0xaa42, 1}, - Range{0xaa44, 0xaa4b, 1}, - Range{0xac00, 0xd7a3, 1}, - Range{0xf900, 0xfa2d, 1}, - Range{0xfa30, 0xfa6a, 1}, - Range{0xfa70, 0xfad9, 1}, - Range{0xfb00, 0xfb06, 1}, - Range{0xfb13, 0xfb17, 1}, - Range{0xfb1d, 0xfb1d, 1}, - Range{0xfb1f, 0xfb28, 1}, - Range{0xfb2a, 0xfb36, 1}, - Range{0xfb38, 0xfb3c, 1}, - Range{0xfb3e, 0xfb3e, 1}, - Range{0xfb40, 0xfb41, 1}, - Range{0xfb43, 0xfb44, 1}, - Range{0xfb46, 0xfbb1, 1}, - Range{0xfbd3, 0xfd3d, 1}, - Range{0xfd50, 0xfd8f, 1}, - Range{0xfd92, 0xfdc7, 1}, - Range{0xfdf0, 0xfdfb, 1}, - Range{0xfe70, 0xfe74, 1}, - Range{0xfe76, 0xfefc, 1}, - Range{0xff21, 0xff3a, 1}, - Range{0xff41, 0xff5a, 1}, - Range{0xff66, 0xffbe, 1}, - Range{0xffc2, 0xffc7, 1}, - Range{0xffca, 0xffcf, 1}, - Range{0xffd2, 0xffd7, 1}, - Range{0xffda, 0xffdc, 1}, - Range{0x10000, 0x1000b, 1}, - Range{0x1000d, 0x10026, 1}, - Range{0x10028, 0x1003a, 1}, - Range{0x1003c, 0x1003d, 1}, - Range{0x1003f, 0x1004d, 1}, - Range{0x10050, 0x1005d, 1}, - Range{0x10080, 0x100fa, 1}, - Range{0x10280, 0x1029c, 1}, - Range{0x102a0, 0x102d0, 1}, - Range{0x10300, 0x1031e, 1}, - Range{0x10330, 0x10340, 1}, - Range{0x10342, 0x10349, 1}, - Range{0x10380, 0x1039d, 1}, - Range{0x103a0, 0x103c3, 1}, - Range{0x103c8, 0x103cf, 1}, - Range{0x10400, 0x1049d, 1}, - Range{0x10800, 0x10805, 1}, - Range{0x10808, 0x10808, 1}, - Range{0x1080a, 0x10835, 1}, - Range{0x10837, 0x10838, 1}, - Range{0x1083c, 0x1083f, 3}, - Range{0x10900, 0x10915, 1}, - Range{0x10920, 0x10939, 1}, - Range{0x10a00, 0x10a00, 1}, - Range{0x10a10, 0x10a13, 1}, - Range{0x10a15, 0x10a17, 1}, - Range{0x10a19, 0x10a33, 1}, - Range{0x12000, 0x1236e, 1}, - Range{0x1d400, 0x1d454, 1}, - Range{0x1d456, 0x1d49c, 1}, - Range{0x1d49e, 0x1d49f, 1}, - Range{0x1d4a2, 0x1d4a2, 1}, - Range{0x1d4a5, 0x1d4a6, 1}, - Range{0x1d4a9, 0x1d4ac, 1}, - Range{0x1d4ae, 0x1d4b9, 1}, - Range{0x1d4bb, 0x1d4bb, 1}, - Range{0x1d4bd, 0x1d4c3, 1}, - Range{0x1d4c5, 0x1d505, 1}, - Range{0x1d507, 0x1d50a, 1}, - Range{0x1d50d, 0x1d514, 1}, - Range{0x1d516, 0x1d51c, 1}, - Range{0x1d51e, 0x1d539, 1}, - Range{0x1d53b, 0x1d53e, 1}, - Range{0x1d540, 0x1d544, 1}, - Range{0x1d546, 0x1d546, 1}, - Range{0x1d54a, 0x1d550, 1}, - Range{0x1d552, 0x1d6a5, 1}, - Range{0x1d6a8, 0x1d6c0, 1}, - Range{0x1d6c2, 0x1d6da, 1}, - Range{0x1d6dc, 0x1d6fa, 1}, - Range{0x1d6fc, 0x1d714, 1}, - Range{0x1d716, 0x1d734, 1}, - Range{0x1d736, 0x1d74e, 1}, - Range{0x1d750, 0x1d76e, 1}, - Range{0x1d770, 0x1d788, 1}, - Range{0x1d78a, 0x1d7a8, 1}, - Range{0x1d7aa, 0x1d7c2, 1}, - Range{0x1d7c4, 0x1d7cb, 1}, - Range{0x20000, 0x2a6d6, 1}, - Range{0x2f800, 0x2fa1d, 1}, -} +var Letter = []Range ( + Range(0x0041, 0x005a, 1), + Range(0x0061, 0x007a, 1), + Range(0x00aa, 0x00b5, 11), + Range(0x00ba, 0x00ba, 1), + Range(0x00c0, 0x00d6, 1), + Range(0x00d8, 0x00f6, 1), + Range(0x00f8, 0x02c1, 1), + Range(0x02c6, 0x02d1, 1), + Range(0x02e0, 0x02e4, 1), + Range(0x02ec, 0x02ee, 2), + Range(0x0370, 0x0374, 1), + Range(0x0376, 0x0377, 1), + Range(0x037a, 0x037d, 1), + Range(0x0386, 0x0386, 1), + Range(0x0388, 0x038a, 1), + Range(0x038c, 0x038c, 1), + Range(0x038e, 0x03a1, 1), + Range(0x03a3, 0x03f5, 1), + Range(0x03f7, 0x0481, 1), + Range(0x048a, 0x0523, 1), + Range(0x0531, 0x0556, 1), + Range(0x0559, 0x0559, 1), + Range(0x0561, 0x0587, 1), + Range(0x05d0, 0x05ea, 1), + Range(0x05f0, 0x05f2, 1), + Range(0x0621, 0x064a, 1), + Range(0x066e, 0x066f, 1), + Range(0x0671, 0x06d3, 1), + Range(0x06d5, 0x06d5, 1), + Range(0x06e5, 0x06e6, 1), + Range(0x06ee, 0x06ef, 1), + Range(0x06fa, 0x06fc, 1), + Range(0x06ff, 0x0710, 17), + Range(0x0712, 0x072f, 1), + Range(0x074d, 0x07a5, 1), + Range(0x07b1, 0x07b1, 1), + Range(0x07ca, 0x07ea, 1), + Range(0x07f4, 0x07f5, 1), + Range(0x07fa, 0x07fa, 1), + Range(0x0904, 0x0939, 1), + Range(0x093d, 0x0950, 19), + Range(0x0958, 0x0961, 1), + Range(0x0971, 0x0972, 1), + Range(0x097b, 0x097f, 1), + Range(0x0985, 0x098c, 1), + Range(0x098f, 0x0990, 1), + Range(0x0993, 0x09a8, 1), + Range(0x09aa, 0x09b0, 1), + Range(0x09b2, 0x09b2, 1), + Range(0x09b6, 0x09b9, 1), + Range(0x09bd, 0x09ce, 17), + Range(0x09dc, 0x09dd, 1), + Range(0x09df, 0x09e1, 1), + Range(0x09f0, 0x09f1, 1), + Range(0x0a05, 0x0a0a, 1), + Range(0x0a0f, 0x0a10, 1), + Range(0x0a13, 0x0a28, 1), + Range(0x0a2a, 0x0a30, 1), + Range(0x0a32, 0x0a33, 1), + Range(0x0a35, 0x0a36, 1), + Range(0x0a38, 0x0a39, 1), + Range(0x0a59, 0x0a5c, 1), + Range(0x0a5e, 0x0a5e, 1), + Range(0x0a72, 0x0a74, 1), + Range(0x0a85, 0x0a8d, 1), + Range(0x0a8f, 0x0a91, 1), + Range(0x0a93, 0x0aa8, 1), + Range(0x0aaa, 0x0ab0, 1), + Range(0x0ab2, 0x0ab3, 1), + Range(0x0ab5, 0x0ab9, 1), + Range(0x0abd, 0x0ad0, 19), + Range(0x0ae0, 0x0ae1, 1), + Range(0x0b05, 0x0b0c, 1), + Range(0x0b0f, 0x0b10, 1), + Range(0x0b13, 0x0b28, 1), + Range(0x0b2a, 0x0b30, 1), + Range(0x0b32, 0x0b33, 1), + Range(0x0b35, 0x0b39, 1), + Range(0x0b3d, 0x0b3d, 1), + Range(0x0b5c, 0x0b5d, 1), + Range(0x0b5f, 0x0b61, 1), + Range(0x0b71, 0x0b83, 18), + Range(0x0b85, 0x0b8a, 1), + Range(0x0b8e, 0x0b90, 1), + Range(0x0b92, 0x0b95, 1), + Range(0x0b99, 0x0b9a, 1), + Range(0x0b9c, 0x0b9c, 1), + Range(0x0b9e, 0x0b9f, 1), + Range(0x0ba3, 0x0ba4, 1), + Range(0x0ba8, 0x0baa, 1), + Range(0x0bae, 0x0bb9, 1), + Range(0x0bd0, 0x0bd0, 1), + Range(0x0c05, 0x0c0c, 1), + Range(0x0c0e, 0x0c10, 1), + Range(0x0c12, 0x0c28, 1), + Range(0x0c2a, 0x0c33, 1), + Range(0x0c35, 0x0c39, 1), + Range(0x0c3d, 0x0c3d, 1), + Range(0x0c58, 0x0c59, 1), + Range(0x0c60, 0x0c61, 1), + Range(0x0c85, 0x0c8c, 1), + Range(0x0c8e, 0x0c90, 1), + Range(0x0c92, 0x0ca8, 1), + Range(0x0caa, 0x0cb3, 1), + Range(0x0cb5, 0x0cb9, 1), + Range(0x0cbd, 0x0cde, 33), + Range(0x0ce0, 0x0ce1, 1), + Range(0x0d05, 0x0d0c, 1), + Range(0x0d0e, 0x0d10, 1), + Range(0x0d12, 0x0d28, 1), + Range(0x0d2a, 0x0d39, 1), + Range(0x0d3d, 0x0d3d, 1), + Range(0x0d60, 0x0d61, 1), + Range(0x0d7a, 0x0d7f, 1), + Range(0x0d85, 0x0d96, 1), + Range(0x0d9a, 0x0db1, 1), + Range(0x0db3, 0x0dbb, 1), + Range(0x0dbd, 0x0dbd, 1), + Range(0x0dc0, 0x0dc6, 1), + Range(0x0e01, 0x0e30, 1), + Range(0x0e32, 0x0e33, 1), + Range(0x0e40, 0x0e46, 1), + Range(0x0e81, 0x0e82, 1), + Range(0x0e84, 0x0e84, 1), + Range(0x0e87, 0x0e88, 1), + Range(0x0e8a, 0x0e8d, 3), + Range(0x0e94, 0x0e97, 1), + Range(0x0e99, 0x0e9f, 1), + Range(0x0ea1, 0x0ea3, 1), + Range(0x0ea5, 0x0ea7, 2), + Range(0x0eaa, 0x0eab, 1), + Range(0x0ead, 0x0eb0, 1), + Range(0x0eb2, 0x0eb3, 1), + Range(0x0ebd, 0x0ebd, 1), + Range(0x0ec0, 0x0ec4, 1), + Range(0x0ec6, 0x0ec6, 1), + Range(0x0edc, 0x0edd, 1), + Range(0x0f00, 0x0f00, 1), + Range(0x0f40, 0x0f47, 1), + Range(0x0f49, 0x0f6c, 1), + Range(0x0f88, 0x0f8b, 1), + Range(0x1000, 0x102a, 1), + Range(0x103f, 0x103f, 1), + Range(0x1050, 0x1055, 1), + Range(0x105a, 0x105d, 1), + Range(0x1061, 0x1061, 1), + Range(0x1065, 0x1066, 1), + Range(0x106e, 0x1070, 1), + Range(0x1075, 0x1081, 1), + Range(0x108e, 0x108e, 1), + Range(0x10a0, 0x10c5, 1), + Range(0x10d0, 0x10fa, 1), + Range(0x10fc, 0x10fc, 1), + Range(0x1100, 0x1159, 1), + Range(0x115f, 0x11a2, 1), + Range(0x11a8, 0x11f9, 1), + Range(0x1200, 0x1248, 1), + Range(0x124a, 0x124d, 1), + Range(0x1250, 0x1256, 1), + Range(0x1258, 0x1258, 1), + Range(0x125a, 0x125d, 1), + Range(0x1260, 0x1288, 1), + Range(0x128a, 0x128d, 1), + Range(0x1290, 0x12b0, 1), + Range(0x12b2, 0x12b5, 1), + Range(0x12b8, 0x12be, 1), + Range(0x12c0, 0x12c0, 1), + Range(0x12c2, 0x12c5, 1), + Range(0x12c8, 0x12d6, 1), + Range(0x12d8, 0x1310, 1), + Range(0x1312, 0x1315, 1), + Range(0x1318, 0x135a, 1), + Range(0x1380, 0x138f, 1), + Range(0x13a0, 0x13f4, 1), + Range(0x1401, 0x166c, 1), + Range(0x166f, 0x1676, 1), + Range(0x1681, 0x169a, 1), + Range(0x16a0, 0x16ea, 1), + Range(0x1700, 0x170c, 1), + Range(0x170e, 0x1711, 1), + Range(0x1720, 0x1731, 1), + Range(0x1740, 0x1751, 1), + Range(0x1760, 0x176c, 1), + Range(0x176e, 0x1770, 1), + Range(0x1780, 0x17b3, 1), + Range(0x17d7, 0x17dc, 5), + Range(0x1820, 0x1877, 1), + Range(0x1880, 0x18a8, 1), + Range(0x18aa, 0x18aa, 1), + Range(0x1900, 0x191c, 1), + Range(0x1950, 0x196d, 1), + Range(0x1970, 0x1974, 1), + Range(0x1980, 0x19a9, 1), + Range(0x19c1, 0x19c7, 1), + Range(0x1a00, 0x1a16, 1), + Range(0x1b05, 0x1b33, 1), + Range(0x1b45, 0x1b4b, 1), + Range(0x1b83, 0x1ba0, 1), + Range(0x1bae, 0x1baf, 1), + Range(0x1c00, 0x1c23, 1), + Range(0x1c4d, 0x1c4f, 1), + Range(0x1c5a, 0x1c7d, 1), + Range(0x1d00, 0x1dbf, 1), + Range(0x1e00, 0x1f15, 1), + Range(0x1f18, 0x1f1d, 1), + Range(0x1f20, 0x1f45, 1), + Range(0x1f48, 0x1f4d, 1), + Range(0x1f50, 0x1f57, 1), + Range(0x1f59, 0x1f5d, 2), + Range(0x1f5f, 0x1f7d, 1), + Range(0x1f80, 0x1fb4, 1), + Range(0x1fb6, 0x1fbc, 1), + Range(0x1fbe, 0x1fbe, 1), + Range(0x1fc2, 0x1fc4, 1), + Range(0x1fc6, 0x1fcc, 1), + Range(0x1fd0, 0x1fd3, 1), + Range(0x1fd6, 0x1fdb, 1), + Range(0x1fe0, 0x1fec, 1), + Range(0x1ff2, 0x1ff4, 1), + Range(0x1ff6, 0x1ffc, 1), + Range(0x2071, 0x207f, 14), + Range(0x2090, 0x2094, 1), + Range(0x2102, 0x2107, 5), + Range(0x210a, 0x2113, 1), + Range(0x2115, 0x2115, 1), + Range(0x2119, 0x211d, 1), + Range(0x2124, 0x2128, 2), + Range(0x212a, 0x212d, 1), + Range(0x212f, 0x2139, 1), + Range(0x213c, 0x213f, 1), + Range(0x2145, 0x2149, 1), + Range(0x214e, 0x214e, 1), + Range(0x2183, 0x2184, 1), + Range(0x2c00, 0x2c2e, 1), + Range(0x2c30, 0x2c5e, 1), + Range(0x2c60, 0x2c6f, 1), + Range(0x2c71, 0x2c7d, 1), + Range(0x2c80, 0x2ce4, 1), + Range(0x2d00, 0x2d25, 1), + Range(0x2d30, 0x2d65, 1), + Range(0x2d6f, 0x2d6f, 1), + Range(0x2d80, 0x2d96, 1), + Range(0x2da0, 0x2da6, 1), + Range(0x2da8, 0x2dae, 1), + Range(0x2db0, 0x2db6, 1), + Range(0x2db8, 0x2dbe, 1), + Range(0x2dc0, 0x2dc6, 1), + Range(0x2dc8, 0x2dce, 1), + Range(0x2dd0, 0x2dd6, 1), + Range(0x2dd8, 0x2dde, 1), + Range(0x2e2f, 0x2e2f, 1), + Range(0x3005, 0x3006, 1), + Range(0x3031, 0x3035, 1), + Range(0x303b, 0x303c, 1), + Range(0x3041, 0x3096, 1), + Range(0x309d, 0x309f, 1), + Range(0x30a1, 0x30fa, 1), + Range(0x30fc, 0x30ff, 1), + Range(0x3105, 0x312d, 1), + Range(0x3131, 0x318e, 1), + Range(0x31a0, 0x31b7, 1), + Range(0x31f0, 0x31ff, 1), + Range(0x3400, 0x4db5, 1), + Range(0x4e00, 0x9fc3, 1), + Range(0xa000, 0xa48c, 1), + Range(0xa500, 0xa60c, 1), + Range(0xa610, 0xa61f, 1), + Range(0xa62a, 0xa62b, 1), + Range(0xa640, 0xa65f, 1), + Range(0xa662, 0xa66e, 1), + Range(0xa67f, 0xa697, 1), + Range(0xa717, 0xa71f, 1), + Range(0xa722, 0xa788, 1), + Range(0xa78b, 0xa78c, 1), + Range(0xa7fb, 0xa801, 1), + Range(0xa803, 0xa805, 1), + Range(0xa807, 0xa80a, 1), + Range(0xa80c, 0xa822, 1), + Range(0xa840, 0xa873, 1), + Range(0xa882, 0xa8b3, 1), + Range(0xa90a, 0xa925, 1), + Range(0xa930, 0xa946, 1), + Range(0xaa00, 0xaa28, 1), + Range(0xaa40, 0xaa42, 1), + Range(0xaa44, 0xaa4b, 1), + Range(0xac00, 0xd7a3, 1), + Range(0xf900, 0xfa2d, 1), + Range(0xfa30, 0xfa6a, 1), + Range(0xfa70, 0xfad9, 1), + Range(0xfb00, 0xfb06, 1), + Range(0xfb13, 0xfb17, 1), + Range(0xfb1d, 0xfb1d, 1), + Range(0xfb1f, 0xfb28, 1), + Range(0xfb2a, 0xfb36, 1), + Range(0xfb38, 0xfb3c, 1), + Range(0xfb3e, 0xfb3e, 1), + Range(0xfb40, 0xfb41, 1), + Range(0xfb43, 0xfb44, 1), + Range(0xfb46, 0xfbb1, 1), + Range(0xfbd3, 0xfd3d, 1), + Range(0xfd50, 0xfd8f, 1), + Range(0xfd92, 0xfdc7, 1), + Range(0xfdf0, 0xfdfb, 1), + Range(0xfe70, 0xfe74, 1), + Range(0xfe76, 0xfefc, 1), + Range(0xff21, 0xff3a, 1), + Range(0xff41, 0xff5a, 1), + Range(0xff66, 0xffbe, 1), + Range(0xffc2, 0xffc7, 1), + Range(0xffca, 0xffcf, 1), + Range(0xffd2, 0xffd7, 1), + Range(0xffda, 0xffdc, 1), + Range(0x10000, 0x1000b, 1), + Range(0x1000d, 0x10026, 1), + Range(0x10028, 0x1003a, 1), + Range(0x1003c, 0x1003d, 1), + Range(0x1003f, 0x1004d, 1), + Range(0x10050, 0x1005d, 1), + Range(0x10080, 0x100fa, 1), + Range(0x10280, 0x1029c, 1), + Range(0x102a0, 0x102d0, 1), + Range(0x10300, 0x1031e, 1), + Range(0x10330, 0x10340, 1), + Range(0x10342, 0x10349, 1), + Range(0x10380, 0x1039d, 1), + Range(0x103a0, 0x103c3, 1), + Range(0x103c8, 0x103cf, 1), + Range(0x10400, 0x1049d, 1), + Range(0x10800, 0x10805, 1), + Range(0x10808, 0x10808, 1), + Range(0x1080a, 0x10835, 1), + Range(0x10837, 0x10838, 1), + Range(0x1083c, 0x1083f, 3), + Range(0x10900, 0x10915, 1), + Range(0x10920, 0x10939, 1), + Range(0x10a00, 0x10a00, 1), + Range(0x10a10, 0x10a13, 1), + Range(0x10a15, 0x10a17, 1), + Range(0x10a19, 0x10a33, 1), + Range(0x12000, 0x1236e, 1), + Range(0x1d400, 0x1d454, 1), + Range(0x1d456, 0x1d49c, 1), + Range(0x1d49e, 0x1d49f, 1), + Range(0x1d4a2, 0x1d4a2, 1), + Range(0x1d4a5, 0x1d4a6, 1), + Range(0x1d4a9, 0x1d4ac, 1), + Range(0x1d4ae, 0x1d4b9, 1), + Range(0x1d4bb, 0x1d4bb, 1), + Range(0x1d4bd, 0x1d4c3, 1), + Range(0x1d4c5, 0x1d505, 1), + Range(0x1d507, 0x1d50a, 1), + Range(0x1d50d, 0x1d514, 1), + Range(0x1d516, 0x1d51c, 1), + Range(0x1d51e, 0x1d539, 1), + Range(0x1d53b, 0x1d53e, 1), + Range(0x1d540, 0x1d544, 1), + Range(0x1d546, 0x1d546, 1), + Range(0x1d54a, 0x1d550, 1), + Range(0x1d552, 0x1d6a5, 1), + Range(0x1d6a8, 0x1d6c0, 1), + Range(0x1d6c2, 0x1d6da, 1), + Range(0x1d6dc, 0x1d6fa, 1), + Range(0x1d6fc, 0x1d714, 1), + Range(0x1d716, 0x1d734, 1), + Range(0x1d736, 0x1d74e, 1), + Range(0x1d750, 0x1d76e, 1), + Range(0x1d770, 0x1d788, 1), + Range(0x1d78a, 0x1d7a8, 1), + Range(0x1d7aa, 0x1d7c2, 1), + Range(0x1d7c4, 0x1d7cb, 1), + Range(0x20000, 0x2a6d6, 1), + Range(0x2f800, 0x2fa1d, 1), +) func Is(ranges []Range, rune int) bool { // common case: rune is ASCII or Latin-1 diff --git a/src/lib/unicode/letter_test.go b/src/lib/unicode/letter_test.go index d39d74e6b9..7ff5546e1b 100644 --- a/src/lib/unicode/letter_test.go +++ b/src/lib/unicode/letter_test.go @@ -9,7 +9,7 @@ import ( "unicode"; ) -var upper = []int{ +var upper = []int( 0x41, 0xc0, 0xd8, @@ -31,9 +31,9 @@ var upper = []int{ 0x10400, 0x1d400, 0x1d7ca, -} +) -var notupper = []int{ +var notupper = []int( 0x40, 0x5b, 0x61, @@ -44,9 +44,9 @@ var notupper = []int{ 0x2150, 0xffff, 0x10000, -} +) -var letter = []int{ +var letter = []int( 0x41, 0x61, 0xaa, @@ -79,9 +79,9 @@ var letter = []int{ 0x20000, 0x2f800, 0x2fa1d, -} +) -var notletter = []int{ +var notletter = []int( 0x20, 0x35, 0x375, @@ -90,7 +90,7 @@ var notletter = []int{ 0xfffe, 0x1ffff, 0x10ffff, -} +) func TestIsLetter(t *testing.T) { for i, r := range(upper) { diff --git a/src/lib/utf8_test.go b/src/lib/utf8_test.go index 7999afd2ee..5499263ae6 100644 --- a/src/lib/utf8_test.go +++ b/src/lib/utf8_test.go @@ -17,33 +17,33 @@ type Utf8Map struct { str string; } -var utf8map = []Utf8Map { - Utf8Map{ 0x0000, "\x00" }, - Utf8Map{ 0x0001, "\x01" }, - Utf8Map{ 0x007e, "\x7e" }, - Utf8Map{ 0x007f, "\x7f" }, - Utf8Map{ 0x0080, "\xc2\x80" }, - Utf8Map{ 0x0081, "\xc2\x81" }, - Utf8Map{ 0x00bf, "\xc2\xbf" }, - Utf8Map{ 0x00c0, "\xc3\x80" }, - Utf8Map{ 0x00c1, "\xc3\x81" }, - Utf8Map{ 0x00c8, "\xc3\x88" }, - Utf8Map{ 0x00d0, "\xc3\x90" }, - Utf8Map{ 0x00e0, "\xc3\xa0" }, - Utf8Map{ 0x00f0, "\xc3\xb0" }, - Utf8Map{ 0x00f8, "\xc3\xb8" }, - Utf8Map{ 0x00ff, "\xc3\xbf" }, - Utf8Map{ 0x0100, "\xc4\x80" }, - Utf8Map{ 0x07ff, "\xdf\xbf" }, - Utf8Map{ 0x0800, "\xe0\xa0\x80" }, - Utf8Map{ 0x0801, "\xe0\xa0\x81" }, - Utf8Map{ 0xfffe, "\xef\xbf\xbe" }, - Utf8Map{ 0xffff, "\xef\xbf\xbf" }, - Utf8Map{ 0x10000, "\xf0\x90\x80\x80" }, - Utf8Map{ 0x10001, "\xf0\x90\x80\x81" }, - Utf8Map{ 0x10fffe, "\xf4\x8f\xbf\xbe" }, - Utf8Map{ 0x10ffff, "\xf4\x8f\xbf\xbf" }, -} +var utf8map = []Utf8Map ( + Utf8Map( 0x0000, "\x00" ), + Utf8Map( 0x0001, "\x01" ), + Utf8Map( 0x007e, "\x7e" ), + Utf8Map( 0x007f, "\x7f" ), + Utf8Map( 0x0080, "\xc2\x80" ), + Utf8Map( 0x0081, "\xc2\x81" ), + Utf8Map( 0x00bf, "\xc2\xbf" ), + Utf8Map( 0x00c0, "\xc3\x80" ), + Utf8Map( 0x00c1, "\xc3\x81" ), + Utf8Map( 0x00c8, "\xc3\x88" ), + Utf8Map( 0x00d0, "\xc3\x90" ), + Utf8Map( 0x00e0, "\xc3\xa0" ), + Utf8Map( 0x00f0, "\xc3\xb0" ), + Utf8Map( 0x00f8, "\xc3\xb8" ), + Utf8Map( 0x00ff, "\xc3\xbf" ), + Utf8Map( 0x0100, "\xc4\x80" ), + Utf8Map( 0x07ff, "\xdf\xbf" ), + Utf8Map( 0x0800, "\xe0\xa0\x80" ), + Utf8Map( 0x0801, "\xe0\xa0\x81" ), + Utf8Map( 0xfffe, "\xef\xbf\xbe" ), + Utf8Map( 0xffff, "\xef\xbf\xbf" ), + Utf8Map( 0x10000, "\xf0\x90\x80\x80" ), + Utf8Map( 0x10001, "\xf0\x90\x80\x81" ), + Utf8Map( 0x10fffe, "\xf4\x8f\xbf\xbe" ), + Utf8Map( 0x10ffff, "\xf4\x8f\xbf\xbf" ), +) // io.StringBytes with one extra byte at end func bytes(s string) []byte { @@ -161,12 +161,12 @@ type RuneCountTest struct { in string; out int; } -var runecounttests = []RuneCountTest { - RuneCountTest{ "abcd", 4 }, - RuneCountTest{ "☺☻☹", 3 }, - RuneCountTest{ "1,2,3,4", 7 }, - RuneCountTest{ "\xe2\x00", 2 }, -} +var runecounttests = []RuneCountTest ( + RuneCountTest( "abcd", 4 ), + RuneCountTest( "☺☻☹", 3 ), + RuneCountTest( "1,2,3,4", 7 ), + RuneCountTest( "\xe2\x00", 2 ), +) func TestRuneCount(t *testing.T) { for i := 0; i < len(runecounttests); i++ { tt := runecounttests[i]; diff --git a/test/235.go b/test/235.go index e24106dd00..26ed16ff27 100644 --- a/test/235.go +++ b/test/235.go @@ -32,16 +32,16 @@ func min(xs []uint64) uint64 { func main() { - F := []uint64{2, 3, 5}; + F := []uint64(2, 3, 5); var n = len(F); - OUT := []uint64{ + OUT := []uint64( 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24, 25, 27, 30, 32, 36, 40, 45, 48, 50, 54, 60, 64, 72, 75, 80, 81, 90, 96, 100, 108, 120, 125, 128, 135, 144, 150, 160, 162, 180, 192, 200, 216, 225, 240, 243, 250, 256, 270, 288, 300, 320, 324, 360, 375, 384, 400, 405, 432, 450, 480, 486, 500, 512, 540, 576, 600, 625, 640, 648, 675, 720, 729, 750, 768, 800, 810, 864, 900, 960, 972, 1000, 1024, 1080, 1125, 1152, 1200, 1215, - 1250, 1280, 1296, 1350, 1440, 1458, 1500, 1536, 1600 }; + 1250, 1280, 1296, 1350, 1440, 1458, 1500, 1536, 1600 ); x := uint64(1); ins := make([]T, n); diff --git a/test/bigalg.go b/test/bigalg.go index afeccdf8f0..5ac60cc0c5 100644 --- a/test/bigalg.go +++ b/test/bigalg.go @@ -18,7 +18,7 @@ type T struct { d byte; } -var a = []int{ 1, 2, 3 } +var a = []int( 1, 2, 3 ) var NIL []int; func arraycmptest() { @@ -44,7 +44,7 @@ func SameArray(a, b []int) bool { return true; } -var t = T{1.5, 123, "hello", 255} +var t = T(1.5, 123, "hello", 255) var mt = make(map[int]T) var ma = make(map[int][]int) diff --git a/test/bugs/bug117.go b/test/bugs/bug117.go index a18e68849a..acb45e4a92 100644 --- a/test/bugs/bug117.go +++ b/test/bugs/bug117.go @@ -14,7 +14,7 @@ func fn(p PS) int { return p.get() } func main() { - s := S{1}; + s := S(1); if s.get() != 1 { panic() } diff --git a/test/bugs/bug130.go b/test/bugs/bug130.go index aa3f0dd70e..fc18b7e966 100644 --- a/test/bugs/bug130.go +++ b/test/bugs/bug130.go @@ -12,7 +12,7 @@ type S struct { v int } func (p *S) send(c chan <- int) { c <- p.v } func main() { - s := S{0}; + s := S(0); var i I = &s; c := make(chan int); go i.send(c); diff --git a/test/chan/powser1.go b/test/chan/powser1.go index c167da1927..501a252310 100644 --- a/test/chan/powser1.go +++ b/test/chan/powser1.go @@ -158,7 +158,7 @@ func getn(in []*dch) []rat { // Get one rat from each of 2 demand channels func get2(in0 *dch, in1 *dch) []rat { - return getn([]*dch{in0, in1}); + return getn([]*dch(in0, in1)); } func copy(in *dch, out *dch) { diff --git a/test/chan/powser2.go b/test/chan/powser2.go index b48110819b..bf798b3fa7 100644 --- a/test/chan/powser2.go +++ b/test/chan/powser2.go @@ -167,7 +167,7 @@ func getn(in []*dch) []item { // Get one item from each of 2 demand channels func get2(in0 *dch, in1 *dch) []item { - return getn([]*dch{in0, in1}); + return getn([]*dch(in0, in1)); } func copy(in *dch, out *dch){ diff --git a/test/chan/sieve.go b/test/chan/sieve.go index 0cebdc6412..2cde55e64b 100644 --- a/test/chan/sieve.go +++ b/test/chan/sieve.go @@ -43,7 +43,7 @@ func Sieve(primes chan<- int) { func main() { primes := make(chan int); go Sieve(primes); - a := []int{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97}; + a := []int(2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97); for i := 0; i < len(a); i++ { if <-primes != a[i] { panic(a[i])} } diff --git a/test/closure.go b/test/closure.go index 97361a1dfd..1bd0ef202e 100644 --- a/test/closure.go +++ b/test/closure.go @@ -76,13 +76,13 @@ func h() { func main() { go f(); - check([]int{1,4,5,4}); + check([]int(1,4,5,4)); a := accum(0); b := accum(1); go g(a, b); - check([]int{2,4,6,9}); + check([]int(2,4,6,9)); go h(); - check([]int{100,200,101,201,500,101,201,500}); + check([]int(100,200,101,201,500,101,201,500)); } diff --git a/test/complit.go b/test/complit.go index d9b9488519..f2dc91d108 100644 --- a/test/complit.go +++ b/test/complit.go @@ -24,45 +24,45 @@ func eq(a []*R) { type P struct { a, b int }; func NewP(a, b int) *P { - return &P{a, b} + return &P(a, b) } func main() { var t T; - t = T{0, 7.2, "hi", &t}; + t = T(0, 7.2, "hi", &t); var tp *T; - tp = &T{0, 7.2, "hi", &t}; + tp = &T(0, 7.2, "hi", &t); - a1 := []int{1,2,3}; + a1 := []int(1,2,3); if len(a1) != 3 { panic("a1") } - a2 := [10]int{1,2,3}; + a2 := [10]int(1,2,3); if len(a2) != 10 || cap(a2) != 10 { panic("a2") } - a3 := [10]int{1,2,3,}; + a3 := [10]int(1,2,3,); if len(a3) != 10 || a2[3] != 0 { panic("a3") } var oai []int; - oai = []int{1,2,3}; + oai = []int(1,2,3); if len(oai) != 3 { panic("oai") } - at := [...]*T{&t, &t, &t}; + at := [...]*T(&t, &t, &t); if len(at) != 3 { panic("at") } c := make(chan int); - ac := []chan int{c, c, c}; + ac := []chan int(c, c, c); if len(ac) != 3 { panic("ac") } - aat := [][len(at)]*T{at, at}; + aat := [][len(at)]*T(at, at); if len(aat) != 2 || len(aat[1]) != 3 { panic("aat") } - s := string([]byte{'h', 'e', 'l', 'l', 'o'}); + s := string([]byte('h', 'e', 'l', 'l', 'o')); if s != "hello" { panic("s") } - m := map[string]float{"one":1.0, "two":2.0, "pi":22./7.}; + m := map[string]float("one":1.0, "two":2.0, "pi":22./7.); if len(m) != 3 { panic("m") } - eq([]*R{itor(0), itor(1), itor(2), itor(3), itor(4), itor(5)}); + eq([]*R(itor(0), itor(1), itor(2), itor(3), itor(4), itor(5))); p1 := NewP(1, 2); p2 := NewP(1, 2); diff --git a/test/convlit1.go b/test/convlit1.go index 94d28969b7..19f98efbd7 100644 --- a/test/convlit1.go +++ b/test/convlit1.go @@ -6,8 +6,7 @@ package main -var a = []int { "a" }; // ERROR "conver|incompatible" -var b = int { 1 }; // ERROR "compos" +var a = []int ( "a" ); // ERROR "conver|incompatible" func f() int diff --git a/test/fixedbugs/bug047.go b/test/fixedbugs/bug047.go index 805647b3d9..61b4255b0c 100644 --- a/test/fixedbugs/bug047.go +++ b/test/fixedbugs/bug047.go @@ -14,8 +14,8 @@ func main() { }; var s string = "hello"; var f float = 0.2; - t := T{s, f}; + t := T(s, f); type M map[int] int; - m0 := M{7:8}; + m0 := M(7:8); } diff --git a/test/fixedbugs/bug048.go b/test/fixedbugs/bug048.go index fbfc120131..30a015cc26 100644 --- a/test/fixedbugs/bug048.go +++ b/test/fixedbugs/bug048.go @@ -8,5 +8,5 @@ package main func main() { type M map[int] int; - m1 := M{7 : 8}; + m1 := M(7 : 8); } diff --git a/test/fixedbugs/bug096.go b/test/fixedbugs/bug096.go index 81d6c4aada..34673f7230 100644 --- a/test/fixedbugs/bug096.go +++ b/test/fixedbugs/bug096.go @@ -9,8 +9,8 @@ package main type A []int; func main() { - a := &A{0}; - b := &A{0, 1}; + a := &A(0); + b := &A(0, 1); } /* diff --git a/test/fixedbugs/bug097.go b/test/fixedbugs/bug097.go index 70bd6e2b47..9286b06738 100644 --- a/test/fixedbugs/bug097.go +++ b/test/fixedbugs/bug097.go @@ -11,7 +11,7 @@ type A []int; func main() { var a [3]A; for i := 0; i < 3; i++ { - a[i] = A{i}; + a[i] = A(i); } if a[0][0] != 0 { panic(); } if a[1][0] != 1 { panic(); } diff --git a/test/fixedbugs/bug098.go b/test/fixedbugs/bug098.go index 8e790a709a..09daf3f890 100644 --- a/test/fixedbugs/bug098.go +++ b/test/fixedbugs/bug098.go @@ -10,8 +10,8 @@ type A []int; type M map[int] int; func main() { - var a *A = &A{0}; - var m *M = &M{0 : 0}; // should be legal to use & here for consistency with other composite constructors (prev. line) + var a *A = &A(0); + var m *M = &M(0 : 0); // should be legal to use & here for consistency with other composite constructors (prev. line) } /* diff --git a/test/fixedbugs/bug101.go b/test/fixedbugs/bug101.go index 92487deaac..a87eea1990 100644 --- a/test/fixedbugs/bug101.go +++ b/test/fixedbugs/bug101.go @@ -6,7 +6,7 @@ package main -var a = []int { 1, 2, 3 } +var a = []int ( 1, 2, 3 ) func main() { if len(a) != 3 { panic("array len") } diff --git a/test/fixedbugs/bug102.go b/test/fixedbugs/bug102.go index 58480974ba..87ec65ee3c 100644 --- a/test/fixedbugs/bug102.go +++ b/test/fixedbugs/bug102.go @@ -12,7 +12,7 @@ func main() { if s != "" { panic("bad convert") } - var b1 = [5]byte{'h', 'e', 'l', 'l', 'o'}; + var b1 = [5]byte('h', 'e', 'l', 'l', 'o'); if string(b1) != "hello" { panic("bad convert 1") } diff --git a/test/fixedbugs/bug112.go b/test/fixedbugs/bug112.go index 3c932843c7..61f4d00cc2 100644 --- a/test/fixedbugs/bug112.go +++ b/test/fixedbugs/bug112.go @@ -7,7 +7,7 @@ package main type T struct { s string } -var t = T{"hi"} +var t = T("hi") func main() {} diff --git a/test/fixedbugs/bug119.go b/test/fixedbugs/bug119.go index 8e51ef2cec..c74d8bb77e 100644 --- a/test/fixedbugs/bug119.go +++ b/test/fixedbugs/bug119.go @@ -11,7 +11,7 @@ func foo(a []int) int { } func main() { - a := &[]int{12}; + a := &[]int(12); if x := a[0] ; x != 12 { panicln(1) } if x := (*a)[0]; x != 12 { panicln(2) } if x := foo(*a) ; x != 12 { panicln(3) } // fails (x is incorrect) @@ -28,5 +28,5 @@ panic on line 83 PC=0x14d6 0x52bb?zi mainstart(1, 0, 1606416432, ...) mainstart(0x1, 0x7fff5fbff830, 0x0, ...) -uetli:~/Source/go1/test/bugs gri$ +uetli:~/Source/go1/test/bugs gri$ */ diff --git a/test/fixedbugs/bug120.go b/test/fixedbugs/bug120.go index 10e28034dc..e633024f07 100644 --- a/test/fixedbugs/bug120.go +++ b/test/fixedbugs/bug120.go @@ -14,12 +14,12 @@ type Test struct { out string; } -var tests = []Test { - Test{ 123.5, "123.5", "123.5" }, - Test{ 456.7, "456.7", "456.7" }, - Test{ 1e23+8.5e6, "1e23+8.5e6", "1.0000000000000001e+23" }, - Test{ 100000000000000008388608, "100000000000000008388608", "1.0000000000000001e+23" }, - Test{ 1e23+8388609, "1e23+8388609", "1.0000000000000001e+23" }, +var tests = []Test ( + Test( 123.5, "123.5", "123.5" ), + Test( 456.7, "456.7", "456.7" ), + Test( 1e23+8.5e6, "1e23+8.5e6", "1.0000000000000001e+23" ), + Test( 100000000000000008388608, "100000000000000008388608", "1.0000000000000001e+23" ), + Test( 1e23+8388609, "1e23+8388609", "1.0000000000000001e+23" ), // "x" = the floating point value from converting the string x. // These are exactly representable in 64-bit floating point: @@ -32,9 +32,9 @@ var tests = []Test { // The correct answer, of course, would be "1e23+8388608" = 1e23+8388608. // This is not going to be correct until 6g has multiprecision floating point. // A simpler case is "1e23+1", which should also round to 1e23+8388608. - Test{ 1e23+8.388608e6, "1e23+8.388608e6", "1.0000000000000001e+23" }, - Test{ 1e23+1, "1e23+1", "1.0000000000000001e+23" }, -} + Test( 1e23+8.388608e6, "1e23+8.388608e6", "1.0000000000000001e+23" ), + Test( 1e23+1, "1e23+1", "1.0000000000000001e+23" ), +) func main() { ok := true; diff --git a/test/golden.out b/test/golden.out index 128c71f4df..89df568b89 100644 --- a/test/golden.out +++ b/test/golden.out @@ -244,9 +244,8 @@ fixedbugs/bug073.go:9: illegal types for operand: RSH int =========== fixedbugs/bug074.go -fixedbugs/bug074.go:6: syntax error near string -fixedbugs/bug074.go:6: syntax error near string -fixedbugs/bug074.go:7: x: undefined +fixedbugs/bug074.go:6: invalid type for composite literal: string +fixedbugs/bug074.go:6: invalid type for composite literal: string =========== fixedbugs/bug081.go fixedbugs/bug081.go:5: no type x diff --git a/test/indirect.go b/test/indirect.go index 4200d382ae..4bf50ded3a 100644 --- a/test/indirect.go +++ b/test/indirect.go @@ -9,7 +9,7 @@ package main var m0 map[string]int var m1 *map[string]int var m2 *map[string]int = &m0 -var m3 map[string]int = map[string]int{"a": 1} +var m3 map[string]int = map[string]int("a": 1) var m4 *map[string]int = &m3 var s0 string @@ -25,7 +25,7 @@ var a2 *[10]int = &a0 var b0 []int var b1 *[]int var b2 *[]int = &b0 -var b3 []int = []int{1, 2, 3} +var b3 []int = []int(1, 2, 3) var b4 *[]int = &b3 func crash() diff --git a/test/initcomma.go b/test/initcomma.go index 44053f1459..f28c4a60fc 100644 --- a/test/initcomma.go +++ b/test/initcomma.go @@ -6,10 +6,10 @@ package main -var a = []int { 1,2, } -var b = [5]int { 1,2,3 } -var c = []int { 1 } -var d = [...]int { 1,2,3 } +var a = []int ( 1,2, ) +var b = [5]int ( 1,2,3 ) +var c = []int ( 1 ) +var d = [...]int ( 1,2,3 ) func main() { if len(a) != 2 { panicln("len a", len(a)) } diff --git a/test/interface4.go b/test/interface4.go index a55936df84..3e8a41b099 100644 --- a/test/interface4.go +++ b/test/interface4.go @@ -31,8 +31,8 @@ func test(name string, i I) { } func ptrs() { - var bigptr BigPtr = BigPtr{ 10000, 2000, 300, 45 }; - var smallptr SmallPtr = SmallPtr{ 12345 }; + var bigptr BigPtr = BigPtr( 10000, 2000, 300, 45 ); + var smallptr SmallPtr = SmallPtr( 12345 ); var intptr IntPtr = 12345; test("bigptr", bigptr); @@ -53,8 +53,8 @@ type Int int32 func (z Int) M() int64 { return int64(z) } func nonptrs() { - var big Big = Big{ 10000, 2000, 300, 45 }; - var small Small = Small{ 12345 }; + var big Big = Big( 10000, 2000, 300, 45 ); + var small Small = Small( 12345 ); var int Int = 12345; test("big", big); diff --git a/test/interface6.go b/test/interface6.go index 6053e51d64..0af6247d1b 100644 --- a/test/interface6.go +++ b/test/interface6.go @@ -22,7 +22,7 @@ func (p S1) Get() int { return p.i } func (p S1) Put(i int) { p.i = i } func f1() { - s := S1{1}; + s := S1(1); var i I1 = s; i.Put(2); check(i.Get() == 1, "f1 i"); @@ -30,7 +30,7 @@ func f1() { } func f2() { - s := S1{1}; + s := S1(1); var i I1 = &s; i.Put(2); check(i.Get() == 1, "f2 i"); @@ -38,7 +38,7 @@ func f2() { } func f3() { - s := &S1{1}; + s := &S1(1); var i I1 = s; i.Put(2); check(i.Get() == 1, "f3 i"); @@ -50,7 +50,7 @@ func (p *S2) Get() int { return p.i } func (p *S2) Put(i int) { p.i = i } func f4() { - s := S2{1}; + s := S2(1); var i I1 = s; i.Put(2); check(i.Get() == 2, "f4 i"); @@ -58,7 +58,7 @@ func f4() { } func f5() { - s := S2{1}; + s := S2(1); var i I1 = &s; i.Put(2); check(i.Get() == 2, "f5 i"); @@ -66,7 +66,7 @@ func f5() { } func f6() { - s := &S2{1}; + s := &S2(1); var i I1 = s; i.Put(2); check(i.Get() == 2, "f6 i"); @@ -80,7 +80,7 @@ func (p S3) Get() int64 { return p.l } func (p S3) Put(i int64) { p.l = i } func f7() { - s := S3{1, 2, 3, 4}; + s := S3(1, 2, 3, 4); var i I2 = s; i.Put(5); check(i.Get() == 4, "f7 i"); @@ -88,7 +88,7 @@ func f7() { } func f8() { - s := S3{1, 2, 3, 4}; + s := S3(1, 2, 3, 4); var i I2 = &s; i.Put(5); check(i.Get() == 4, "f8 i"); @@ -96,7 +96,7 @@ func f8() { } func f9() { - s := &S3{1, 2, 3, 4}; + s := &S3(1, 2, 3, 4); var i I2 = s; i.Put(5); check(i.Get() == 4, "f9 i"); @@ -108,7 +108,7 @@ func (p *S4) Get() int64 { return p.l } func (p *S4) Put(i int64) { p.l = i } func f10() { - s := S4{1, 2, 3, 4}; + s := S4(1, 2, 3, 4); var i I2 = s; i.Put(5); check(i.Get() == 5, "f10 i"); @@ -116,7 +116,7 @@ func f10() { } func f11() { - s := S4{1, 2, 3, 4}; + s := S4(1, 2, 3, 4); var i I2 = &s; i.Put(5); check(i.Get() == 5, "f11 i"); @@ -124,7 +124,7 @@ func f11() { } func f12() { - s := &S4{1, 2, 3, 4}; + s := &S4(1, 2, 3, 4); var i I2 = s; i.Put(5); check(i.Get() == 5, "f12 i"); diff --git a/test/map.go b/test/map.go index 085502bf52..f0b7b9b00b 100644 --- a/test/map.go +++ b/test/map.go @@ -27,9 +27,9 @@ func P(a []string) string { func main() { // Test a map literal. - mlit := map[string] int { "0":0, "1":1, "2":2, "3":3, "4":4 }; + mlit := map[string] int ( "0":0, "1":1, "2":2, "3":3, "4":4 ); for i := 0; i < len(mlit); i++ { - s := string([]byte{byte(i)+'0'}); + s := string([]byte(byte(i)+'0')); if mlit[s] != i { fmt.Printf("mlit[%s] = %d\n", s, mlit[s]) } @@ -64,14 +64,14 @@ func main() { s := strconv.Itoa(i); s10 := strconv.Itoa(i*10); f := float(i); - t := T{int64(i),f}; + t := T(int64(i),f); apT[i] = new(T); apT[i].i = int64(i); apT[i].f = f; apT[2*i] = new(T); // need twice as many entries as we use, for the nonexistence check apT[2*i].i = int64(i); apT[2*i].f = f; - m := M{i: i+1}; + m := M(i: i+1); mib[i] = (i != 0); mii[i] = 10*i; mfi[float(i)] = 10*i; @@ -140,7 +140,7 @@ func main() { s := strconv.Itoa(i); s10 := strconv.Itoa(i*10); f := float(i); - t := T{int64(i), f}; + t := T(int64(i), f); // BUG m := M(i, i+1); if mib[i] != (i != 0) { fmt.Printf("mib[%d] = %t\n", i, mib[i]); @@ -193,7 +193,7 @@ func main() { for i := 0; i < count; i++ { s := strconv.Itoa(i); f := float(i); - t := T{int64(i), f}; + t := T(int64(i), f); { a, b := mib[i]; if !b { @@ -331,7 +331,7 @@ func main() { for i := count; i < 2*count; i++ { s := strconv.Itoa(i); f := float(i); - t := T{int64(i),f}; + t := T(int64(i),f); { a, b := mib[i]; if b { diff --git a/test/method3.go b/test/method3.go index 491bcdad33..5191c7f1cb 100644 --- a/test/method3.go +++ b/test/method3.go @@ -16,7 +16,7 @@ type I interface { } func main() { - var t T = T{0,1,2,3,4}; + var t T = T(0,1,2,3,4); var i I; i = t; if i.Len() != 5 { diff --git a/usr/gri/pretty/parser.go b/usr/gri/pretty/parser.go index 5543d9eeb3..7f1f887b80 100644 --- a/usr/gri/pretty/parser.go +++ b/usr/gri/pretty/parser.go @@ -236,7 +236,7 @@ func (P *Parser) noType(x AST.Expr) AST.Expr { lit, ok := x.(*AST.TypeLit); if ok { P.error(lit.Typ.Pos, "expected expression, found type"); - x = &AST.BasicLit{lit.Typ.Pos, Scanner.STRING, ""}; + x = &AST.BasicLit(lit.Typ.Pos, Scanner.STRING, ""); } } return x; @@ -244,7 +244,7 @@ func (P *Parser) noType(x AST.Expr) AST.Expr { func (P *Parser) newBinaryExpr(pos, tok int, x, y AST.Expr) *AST.BinaryExpr { - return &AST.BinaryExpr{pos, tok, P.noType(x), P.noType(y)}; + return &AST.BinaryExpr(pos, tok, P.noType(x), P.noType(y)); } @@ -273,13 +273,13 @@ func (P *Parser) parseIdent(scope *SymbolTable.Scope) *AST.Ident { } else { assert(obj.Kind != SymbolTable.NONE); } - x := &AST.Ident{P.pos, obj}; + x := &AST.Ident(P.pos, obj); P.next(); return x; } - + P.expect(Scanner.IDENT); // use expect() error handling - return &AST.Ident{P.pos, nil}; + return &AST.Ident(P.pos, nil); } @@ -344,7 +344,7 @@ func (P *Parser) parseQualifiedIdent() AST.Expr { pos := P.pos; P.next(); y := P.parseIdent(nil); - x = &AST.Selector{pos, x, y}; + x = &AST.Selector(pos, x, y); } return x; @@ -465,18 +465,18 @@ func (P *Parser) parseVarList(list *array.Array, ellipsis_ok bool) { continue; } } - list.Set(i, &AST.BadExpr{0}); + list.Set(i, &AST.BadExpr(0)); P.error(t.Pos, "identifier expected"); } // add type - list.Push(&AST.TypeLit{typ}); + list.Push(&AST.TypeLit(typ)); } else { // all list entries are types // convert all type entries into type expressions for i, n := i0, list.Len(); i < n; i++ { t := list.At(i).(*AST.Type); - list.Set(i, &AST.TypeLit{t}); + list.Set(i, &AST.TypeLit(t)); } } } @@ -544,7 +544,7 @@ func (P *Parser) parseResult(ftyp *AST.Type) *AST.Type { if typ != nil { t = AST.NewType(P.pos, AST.STRUCT); t.List = array.New(0); - t.List.Push(&AST.TypeLit{typ}); + t.List.Push(&AST.TypeLit(typ)); t.End = P.pos; } } @@ -597,7 +597,7 @@ func (P *Parser) parseMethodSpec(list *array.Array) { list.Push(P.parseIdentList()); t := P.parseSignature(); - list.Push(&AST.TypeLit{t}); + list.Push(&AST.TypeLit(t)); } @@ -677,7 +677,7 @@ func (P *Parser) parseStructType() *AST.Type { t.End = P.pos; P.expect(Scanner.RBRACE); - + // enter fields into struct scope for i, n := 0, t.List.Len(); i < n; i++ { if x, ok := t.List.At(i).(*AST.Ident); ok { @@ -826,7 +826,7 @@ func (P *Parser) parseFunctionLit() AST.Expr { P.scope_lev--; P.expr_lev--; - return &AST.FunctionLit{pos, typ, body}; + return &AST.FunctionLit(pos, typ, body); } @@ -848,7 +848,7 @@ func (P *Parser) parseOperand() AST.Expr { return x; case Scanner.INT, Scanner.FLOAT, Scanner.STRING: - x := &AST.BasicLit{P.pos, P.tok, P.val}; + x := &AST.BasicLit(P.pos, P.tok, P.val); P.next(); if x.Tok == Scanner.STRING { // TODO should remember the list instead of @@ -865,14 +865,14 @@ func (P *Parser) parseOperand() AST.Expr { default: t := P.tryType(); if t != nil { - return &AST.TypeLit{t}; + return &AST.TypeLit(t); } else { P.error(P.pos, "operand expected"); P.next(); // make progress } } - return &AST.BadExpr{P.pos}; + return &AST.BadExpr(P.pos); } @@ -885,11 +885,11 @@ func (P *Parser) parseSelectorOrTypeGuard(x AST.Expr) AST.Expr { P.expect(Scanner.PERIOD); if P.tok == Scanner.IDENT { - x = &AST.Selector{pos, x, P.parseIdent(nil)}; + x = &AST.Selector(pos, x, P.parseIdent(nil)); } else { P.expect(Scanner.LPAREN); - x = &AST.TypeGuard{pos, x, P.parseType()}; + x = &AST.TypeGuard(pos, x, P.parseType()); P.expect(Scanner.RPAREN); } @@ -909,7 +909,7 @@ func (P *Parser) parseIndex(x AST.Expr) AST.Expr { P.expr_lev--; P.expect(Scanner.RBRACK); - return &AST.Index{pos, x, i}; + return &AST.Index(pos, x, i); } @@ -920,7 +920,7 @@ func (P *Parser) parseCall(f AST.Expr) AST.Expr { defer un(trace(P, "Call")); } - call := &AST.Call{P.pos, f, nil}; + call := &AST.Call(P.pos, f, nil); P.expect(Scanner.LPAREN); if P.tok != Scanner.RPAREN { P.expr_lev++; @@ -931,13 +931,13 @@ func (P *Parser) parseCall(f AST.Expr) AST.Expr { } if t != nil { // we found a type - args := &AST.TypeLit{t}; + args := &AST.TypeLit(t); if P.tok == Scanner.COMMA { pos := P.pos; P.next(); y := P.parseExpressionList(); // create list manually because NewExpr checks for type expressions - args := &AST.BinaryExpr{pos, Scanner.COMMA, args, y}; + args := &AST.BinaryExpr(pos, Scanner.COMMA, args, y); } call.Args = args; } else { @@ -1012,7 +1012,7 @@ func (P *Parser) parseCompositeLit(t *AST.Type) AST.Expr { } P.expect(Scanner.RBRACE); - return &AST.CompositeLit{pos, t, elts}; + return &AST.CompositeLit(pos, t, elts); } @@ -1064,9 +1064,9 @@ func (P *Parser) parseUnaryExpr() AST.Expr { // pointer type t := AST.NewType(pos, AST.POINTER); t.Elt = lit.Typ; - return &AST.TypeLit{t}; + return &AST.TypeLit(t); } else { - return &AST.UnaryExpr{pos, tok, y}; + return &AST.UnaryExpr(pos, tok, y); } } @@ -1124,12 +1124,12 @@ func (P *Parser) parseSimpleStat(range_ok bool) AST.Stat { P.opt_semi = true; if AST.ExprLen(x) == 1 { if label, is_ident := x.(*AST.Ident); is_ident { - return &AST.LabelDecl{pos, label}; + return &AST.LabelDecl(pos, label); } } P.error(x.Pos(), "illegal label declaration"); return nil; - + case Scanner.DEFINE, Scanner.ASSIGN, Scanner.ADD_ASSIGN, Scanner.SUB_ASSIGN, Scanner.MUL_ASSIGN, Scanner.QUO_ASSIGN, @@ -1142,7 +1142,7 @@ func (P *Parser) parseSimpleStat(range_ok bool) AST.Stat { if range_ok && P.tok == Scanner.RANGE { range_pos := P.pos; P.next(); - y = &AST.UnaryExpr{range_pos, Scanner.RANGE, P.parseExpression(1)}; + y = &AST.UnaryExpr(range_pos, Scanner.RANGE, P.parseExpression(1)); if tok != Scanner.DEFINE && tok != Scanner.ASSIGN { P.error(pos, "expected '=' or ':=', found '" + Scanner.TokenString(tok) + "'"); } @@ -1153,21 +1153,21 @@ func (P *Parser) parseSimpleStat(range_ok bool) AST.Stat { } } // TODO changed ILLEGAL -> NONE - return &AST.ExpressionStat{x.Pos(), Scanner.ILLEGAL, P.newBinaryExpr(pos, tok, x, y)}; - + return &AST.ExpressionStat(x.Pos(), Scanner.ILLEGAL, P.newBinaryExpr(pos, tok, x, y)); + default: if AST.ExprLen(x) != 1 { P.error(x.Pos(), "only one expression allowed"); } - + if P.tok == Scanner.INC || P.tok == Scanner.DEC { - s := &AST.ExpressionStat{P.pos, P.tok, x}; + s := &AST.ExpressionStat(P.pos, P.tok, x); P.next(); // consume "++" or "--" return s; } - + // TODO changed ILLEGAL -> NONE - return &AST.ExpressionStat{x.Pos(), Scanner.ILLEGAL, x}; + return &AST.ExpressionStat(x.Pos(), Scanner.ILLEGAL, x); } unreachable(); @@ -1182,7 +1182,7 @@ func (P *Parser) parseInvocationStat(keyword int) *AST.ExpressionStat { pos := P.pos; P.expect(keyword); - return &AST.ExpressionStat{pos, keyword, P.parseExpression(1)}; + return &AST.ExpressionStat(pos, keyword, P.parseExpression(1)); } @@ -1198,7 +1198,7 @@ func (P *Parser) parseReturnStat() *AST.ExpressionStat { x = P.parseExpressionList(); } - return &AST.ExpressionStat{pos, Scanner.RETURN, x}; + return &AST.ExpressionStat(pos, Scanner.RETURN, x); } @@ -1207,7 +1207,7 @@ func (P *Parser) parseControlFlowStat(tok int) *AST.ControlFlowStat { defer un(trace(P, "ControlFlowStat")); } - s := &AST.ControlFlowStat{P.pos, tok, nil}; + s := &AST.ControlFlowStat(P.pos, tok, nil); P.expect(tok); if tok != Scanner.FALLTHROUGH && P.tok == Scanner.IDENT { s.Label = P.parseIdent(P.top_scope); @@ -1275,7 +1275,7 @@ func (P *Parser) parseIfStat() *AST.IfStat { // wrap in a block since we don't have one body := AST.NewBlock(0, Scanner.LBRACE); body.List.Push(else_); - else_ = &AST.CompositeStat{body}; + else_ = &AST.CompositeStat(body); } } else { P.error(P.pos, "'if' or '{' expected - illegal 'else' branch"); @@ -1283,7 +1283,7 @@ func (P *Parser) parseIfStat() *AST.IfStat { } P.closeScope(); - return &AST.IfStat{pos, init, cond, body, else_}; + return &AST.IfStat(pos, init, cond, body, else_); } @@ -1299,7 +1299,7 @@ func (P *Parser) parseForStat() *AST.ForStat { body := P.parseBlock(nil, Scanner.LBRACE); P.closeScope(); - return &AST.ForStat{pos, init, cond, post, body}; + return &AST.ForStat(pos, init, cond, post, body); } @@ -1318,7 +1318,7 @@ func (P *Parser) parseCaseClause() *AST.CaseClause { P.expect(Scanner.DEFAULT); } - return &AST.CaseClause{pos, expr, P.parseBlock(nil, Scanner.COLON)}; + return &AST.CaseClause(pos, expr, P.parseBlock(nil, Scanner.COLON)); } @@ -1341,7 +1341,7 @@ func (P *Parser) parseSwitchStat() *AST.SwitchStat { P.opt_semi = true; P.closeScope(); - return &AST.SwitchStat{pos, init, tag, body}; + return &AST.SwitchStat(pos, init, tag, body); } @@ -1371,7 +1371,7 @@ func (P *Parser) parseCommClause() *AST.CaseClause { P.expect(Scanner.DEFAULT); } - return &AST.CaseClause{pos, expr, P.parseBlock(nil, Scanner.COLON)}; + return &AST.CaseClause(pos, expr, P.parseBlock(nil, Scanner.COLON)); } @@ -1393,7 +1393,7 @@ func (P *Parser) parseSelectStat() *AST.SelectStat { P.opt_semi = true; P.closeScope(); - return &AST.SelectStat{pos, body}; + return &AST.SelectStat(pos, body); } @@ -1404,7 +1404,7 @@ func (P *Parser) parseStatement() AST.Stat { switch P.tok { case Scanner.CONST, Scanner.TYPE, Scanner.VAR: - return &AST.DeclarationStat{P.parseDeclaration()}; + return &AST.DeclarationStat(P.parseDeclaration()); case Scanner.FUNC: // for now we do not allow local function declarations, // instead we assume this starts a function literal @@ -1422,7 +1422,7 @@ func (P *Parser) parseStatement() AST.Stat { case Scanner.BREAK, Scanner.CONTINUE, Scanner.GOTO, Scanner.FALLTHROUGH: return P.parseControlFlowStat(P.tok); case Scanner.LBRACE: - return &AST.CompositeStat{P.parseBlock(nil, Scanner.LBRACE)}; + return &AST.CompositeStat(P.parseBlock(nil, Scanner.LBRACE)); case Scanner.IF: return P.parseIfStat(); case Scanner.FOR: @@ -1433,12 +1433,12 @@ func (P *Parser) parseStatement() AST.Stat { return P.parseSelectStat(); case Scanner.SEMICOLON: // don't consume the ";", it is the separator following the empty statement - return &AST.EmptyStat{P.pos}; + return &AST.EmptyStat(P.pos); } // no statement found P.error(P.pos, "statement expected"); - return &AST.BadStat{P.pos}; + return &AST.BadStat(P.pos); } @@ -1459,7 +1459,7 @@ func (P *Parser) parseImportSpec(d *AST.Decl) { if P.tok == Scanner.STRING { // TODO eventually the scanner should strip the quotes - d.Val = &AST.BasicLit{P.pos, Scanner.STRING, P.val}; + d.Val = &AST.BasicLit(P.pos, Scanner.STRING, P.val); P.next(); } else { P.expect(Scanner.STRING); // use expect() error handling @@ -1513,7 +1513,7 @@ func (P *Parser) parseVarSpec(d *AST.Decl) { func (P *Parser) parseSpec(d *AST.Decl) { kind := SymbolTable.NONE; - + switch d.Tok { case Scanner.IMPORT: P.parseImportSpec(d); kind = SymbolTable.PACKAGE; case Scanner.CONST: P.parseConstSpec(d); kind = SymbolTable.CONST; diff --git a/usr/gri/pretty/selftest1.go b/usr/gri/pretty/selftest1.go index 4365df6073..dff19ca53e 100644 --- a/usr/gri/pretty/selftest1.go +++ b/usr/gri/pretty/selftest1.go @@ -26,10 +26,10 @@ func f1() { func CompositeLiterals() { - a1 := []int{}; - a2 := []int{0, 1, 2, }; - a3 := []int{0, 1, 2, /* ERROR single value expected */ 3 : 4, 5}; /* SYNC */ - a1 := []int{0 : 1, 2 : 3, /* ERROR key:value pair expected */ 4, }; /* SYNC */ + a1 := []int(); + a2 := []int(0, 1, 2, ); + a3 := []int(0, 1, 2, /* ERROR single value expected */ 3 : 4, 5); /* SYNC */ + a1 := []int(0 : 1, 2 : 3, /* ERROR key:value pair expected */ 4, ); /* SYNC */ } diff --git a/usr/gri/pretty/selftest2.go b/usr/gri/pretty/selftest2.go index 8fa907462d..3fc3bacc17 100644 --- a/usr/gri/pretty/selftest2.go +++ b/usr/gri/pretty/selftest2.go @@ -46,9 +46,9 @@ var ( aa = 5; u, v, w int = 0, 0, 0; foo = "foo"; - fixed_array0 = [10]int{}; - fixed_array1 = [10]int{0, 1, 2}; - fixed_array2 = [...]string{"foo", "bar"}; + fixed_array0 = [10]int(); + fixed_array1 = [10]int(0, 1, 2); + fixed_array2 = [...]string("foo", "bar"); ) @@ -136,7 +136,7 @@ func main() { println(i + 1000); // the index + 1000 println(); } - f3(&[]int{2, 3, 5, 7}, map[string]int{"two":2, "three":3, "five":5, "seven":7}); + f3(&[]int(2, 3, 5, 7), map[string]int("two":2, "three":3, "five":5, "seven":7)); // the epilogue println("foo"); // foo println("foobar"); // foobar