Commit 9f8f2e61 authored by Russ Cox's avatar Russ Cox

convert composite literals from { } to ( ).

only non-trivial changes are in
	convlit1.go
	golden.out

R=gri
OCL=25019
CL=25024
parent 07244f7c
......@@ -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) {
......
......@@ -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 (
......
......@@ -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 {
......
......@@ -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);
......
......@@ -13,6 +13,6 @@ func (t *testType) String() string {
}
func main() {
t := &testType{77, "Sunset Strip"};
t := &testType(77, "Sunset Strip");
fmt.Println(t)
}
......@@ -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()
......
......@@ -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");
}
......@@ -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() {'
......
......@@ -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);
}
......
......@@ -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);
......
......@@ -477,6 +477,6 @@ type BufReadWrite struct {
}
func NewBufReadWrite(r *BufRead, w *BufWrite) *BufReadWrite {
return &BufReadWrite{r, w}
return &BufReadWrite(r, w)
}
......@@ -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%('~'-' '));
......
......@@ -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 {
......
This diff is collapsed.
......@@ -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) {
......
......@@ -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++ {
......
......@@ -52,7 +52,7 @@ type Digest struct {
}
func NewDigest(tab Table) *Digest {
return &Digest{0, tab};
return &Digest(0, tab);
}
func NewIEEEDigest() *Digest {
......
......@@ -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++ {
......
......@@ -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++ {
......
......@@ -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];
......
......@@ -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++ {
......
......@@ -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();
......
......@@ -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",
}
)
......@@ -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.
......
......@@ -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 {
......
......@@ -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++ {
......
......@@ -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
......
......@@ -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 (
......
......@@ -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) {
......
......@@ -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;
......
......@@ -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.
......
......@@ -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 {
......
......@@ -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
......
......@@ -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++ {
......
......@@ -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 {
......
......@@ -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++ {
......
......@@ -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
}
......
......@@ -33,7 +33,7 @@ func NewError(s string) *Error {
if ok {
return err
}
err = &Error{s};
err = &Error(s);
errorStringTab[s] = err;
return err;
}
......
......@@ -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 (
......
......@@ -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);
......
......@@ -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 {
......
......@@ -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 {
......
......@@ -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);
......
......@@ -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);
......
......@@ -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
......
......@@ -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.
......
......@@ -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;
......
......@@ -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++ {
......
......@@ -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 {
......
......@@ -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++ {
......
......@@ -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
......
......@@ -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" },
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{ 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{ 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', -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', -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', -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{ 32, 'g', -1, "32" },
ftoaTest{ 32, 'g', 0, "3e+01" },
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{ -1, 'b', -1, "-4503599627370496p-52" },
}
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( -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( 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( 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( 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( 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( 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( 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( -1, 'b', -1, "-4503599627370496p-52" ),
)
func TestFtoa(t *testing.T) {
if strconv.FloatSize != 32 {
......
......@@ -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" ),
)
......@@ -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++ {
......
......@@ -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];
......
......@@ -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' {
......
......@@ -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++ {
......
......@@ -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
......
......@@ -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
......
This diff is collapsed.
......@@ -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) {
......
......@@ -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];
......
......@@ -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);
......
......@@ -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)
......
......@@ -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()
}
......
......@@ -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);
......
......@@ -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) {
......
......@@ -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){
......
......@@ -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])}
}
......
......@@ -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));
}
......@@ -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);
......
......@@ -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
......
......@@ -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);
}
......@@ -8,5 +8,5 @@ package main
func main() {
type M map[int] int;
m1 := M{7 : 8};
m1 := M(7 : 8);
}
......@@ -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);
}
/*
......
......@@ -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(); }
......
......@@ -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)
}
/*
......
......@@ -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") }
......
......@@ -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")
}
......
......@@ -7,7 +7,7 @@
package main
type T struct { s string }
var t = T{"hi"}
var t = T("hi")
func main() {}
......
......@@ -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$
*/
......@@ -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;
......
......@@ -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
......
......@@ -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()
......
......@@ -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)) }
......
......@@ -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);
......
......@@ -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");
......
......@@ -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 {
......
......@@ -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 {
......
This diff is collapsed.
......@@ -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 */
}
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment