diff options
author | Russ Cox <rsc@golang.org> | 2009-02-13 14:48:32 -0800 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2009-02-13 14:48:32 -0800 |
commit | a193f430ba881e07e25325a55fa4f8c47bd4c9e5 (patch) | |
tree | a3b6c6ab9f68981976738f0efc7988353d5a0d82 /test | |
parent | d513b8157d41f0cd240cc6ad74925702c74fc73e (diff) | |
download | go-a193f430ba881e07e25325a55fa4f8c47bd4c9e5.tar.gz |
convert composite literals from { } to ( ).
only non-trivial changes are in
convlit1.go
golden.out
R=gri
OCL=25019
CL=25024
Diffstat (limited to 'test')
-rw-r--r-- | test/235.go | 6 | ||||
-rw-r--r-- | test/bigalg.go | 4 | ||||
-rw-r--r-- | test/bugs/bug117.go | 2 | ||||
-rw-r--r-- | test/bugs/bug130.go | 2 | ||||
-rw-r--r-- | test/chan/powser1.go | 2 | ||||
-rw-r--r-- | test/chan/powser2.go | 2 | ||||
-rw-r--r-- | test/chan/sieve.go | 2 | ||||
-rw-r--r-- | test/closure.go | 6 | ||||
-rw-r--r-- | test/complit.go | 26 | ||||
-rw-r--r-- | test/convlit1.go | 3 | ||||
-rw-r--r-- | test/fixedbugs/bug047.go | 4 | ||||
-rw-r--r-- | test/fixedbugs/bug048.go | 2 | ||||
-rw-r--r-- | test/fixedbugs/bug096.go | 4 | ||||
-rw-r--r-- | test/fixedbugs/bug097.go | 2 | ||||
-rw-r--r-- | test/fixedbugs/bug098.go | 4 | ||||
-rw-r--r-- | test/fixedbugs/bug101.go | 2 | ||||
-rw-r--r-- | test/fixedbugs/bug102.go | 2 | ||||
-rw-r--r-- | test/fixedbugs/bug112.go | 2 | ||||
-rw-r--r-- | test/fixedbugs/bug119.go | 4 | ||||
-rw-r--r-- | test/fixedbugs/bug120.go | 18 | ||||
-rw-r--r-- | test/golden.out | 5 | ||||
-rw-r--r-- | test/indirect.go | 4 | ||||
-rw-r--r-- | test/initcomma.go | 8 | ||||
-rw-r--r-- | test/interface4.go | 8 | ||||
-rw-r--r-- | test/interface6.go | 24 | ||||
-rw-r--r-- | test/map.go | 14 | ||||
-rw-r--r-- | test/method3.go | 2 |
27 files changed, 81 insertions, 83 deletions
diff --git a/test/235.go b/test/235.go index e24106dd0..26ed16ff2 100644 --- a/test/235.go +++ b/test/235.go @@ -32,16 +32,16 @@ func min(xs []uint64) uint64 { func main() { - F := []uint64{2, 3, 5}; + F := []uint64(2, 3, 5); var n = len(F); - OUT := []uint64{ + OUT := []uint64( 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24, 25, 27, 30, 32, 36, 40, 45, 48, 50, 54, 60, 64, 72, 75, 80, 81, 90, 96, 100, 108, 120, 125, 128, 135, 144, 150, 160, 162, 180, 192, 200, 216, 225, 240, 243, 250, 256, 270, 288, 300, 320, 324, 360, 375, 384, 400, 405, 432, 450, 480, 486, 500, 512, 540, 576, 600, 625, 640, 648, 675, 720, 729, 750, 768, 800, 810, 864, 900, 960, 972, 1000, 1024, 1080, 1125, 1152, 1200, 1215, - 1250, 1280, 1296, 1350, 1440, 1458, 1500, 1536, 1600 }; + 1250, 1280, 1296, 1350, 1440, 1458, 1500, 1536, 1600 ); x := uint64(1); ins := make([]T, n); diff --git a/test/bigalg.go b/test/bigalg.go index afeccdf8f..5ac60cc0c 100644 --- a/test/bigalg.go +++ b/test/bigalg.go @@ -18,7 +18,7 @@ type T struct { d byte; } -var a = []int{ 1, 2, 3 } +var a = []int( 1, 2, 3 ) var NIL []int; func arraycmptest() { @@ -44,7 +44,7 @@ func SameArray(a, b []int) bool { return true; } -var t = T{1.5, 123, "hello", 255} +var t = T(1.5, 123, "hello", 255) var mt = make(map[int]T) var ma = make(map[int][]int) diff --git a/test/bugs/bug117.go b/test/bugs/bug117.go index a18e68849..acb45e4a9 100644 --- a/test/bugs/bug117.go +++ b/test/bugs/bug117.go @@ -14,7 +14,7 @@ func fn(p PS) int { return p.get() } func main() { - s := S{1}; + s := S(1); if s.get() != 1 { panic() } diff --git a/test/bugs/bug130.go b/test/bugs/bug130.go index aa3f0dd70..fc18b7e96 100644 --- a/test/bugs/bug130.go +++ b/test/bugs/bug130.go @@ -12,7 +12,7 @@ type S struct { v int } func (p *S) send(c chan <- int) { c <- p.v } func main() { - s := S{0}; + s := S(0); var i I = &s; c := make(chan int); go i.send(c); diff --git a/test/chan/powser1.go b/test/chan/powser1.go index c167da192..501a25231 100644 --- a/test/chan/powser1.go +++ b/test/chan/powser1.go @@ -158,7 +158,7 @@ func getn(in []*dch) []rat { // Get one rat from each of 2 demand channels func get2(in0 *dch, in1 *dch) []rat { - return getn([]*dch{in0, in1}); + return getn([]*dch(in0, in1)); } func copy(in *dch, out *dch) { diff --git a/test/chan/powser2.go b/test/chan/powser2.go index b48110819..bf798b3fa 100644 --- a/test/chan/powser2.go +++ b/test/chan/powser2.go @@ -167,7 +167,7 @@ func getn(in []*dch) []item { // Get one item from each of 2 demand channels func get2(in0 *dch, in1 *dch) []item { - return getn([]*dch{in0, in1}); + return getn([]*dch(in0, in1)); } func copy(in *dch, out *dch){ diff --git a/test/chan/sieve.go b/test/chan/sieve.go index 0cebdc641..2cde55e64 100644 --- a/test/chan/sieve.go +++ b/test/chan/sieve.go @@ -43,7 +43,7 @@ func Sieve(primes chan<- int) { func main() { primes := make(chan int); go Sieve(primes); - a := []int{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97}; + a := []int(2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97); for i := 0; i < len(a); i++ { if <-primes != a[i] { panic(a[i])} } diff --git a/test/closure.go b/test/closure.go index 97361a1df..1bd0ef202 100644 --- a/test/closure.go +++ b/test/closure.go @@ -76,13 +76,13 @@ func h() { func main() { go f(); - check([]int{1,4,5,4}); + check([]int(1,4,5,4)); a := accum(0); b := accum(1); go g(a, b); - check([]int{2,4,6,9}); + check([]int(2,4,6,9)); go h(); - check([]int{100,200,101,201,500,101,201,500}); + check([]int(100,200,101,201,500,101,201,500)); } diff --git a/test/complit.go b/test/complit.go index d9b948851..f2dc91d10 100644 --- a/test/complit.go +++ b/test/complit.go @@ -24,45 +24,45 @@ func eq(a []*R) { type P struct { a, b int }; func NewP(a, b int) *P { - return &P{a, b} + return &P(a, b) } func main() { var t T; - t = T{0, 7.2, "hi", &t}; + t = T(0, 7.2, "hi", &t); var tp *T; - tp = &T{0, 7.2, "hi", &t}; + tp = &T(0, 7.2, "hi", &t); - a1 := []int{1,2,3}; + a1 := []int(1,2,3); if len(a1) != 3 { panic("a1") } - a2 := [10]int{1,2,3}; + a2 := [10]int(1,2,3); if len(a2) != 10 || cap(a2) != 10 { panic("a2") } - a3 := [10]int{1,2,3,}; + a3 := [10]int(1,2,3,); if len(a3) != 10 || a2[3] != 0 { panic("a3") } var oai []int; - oai = []int{1,2,3}; + oai = []int(1,2,3); if len(oai) != 3 { panic("oai") } - at := [...]*T{&t, &t, &t}; + at := [...]*T(&t, &t, &t); if len(at) != 3 { panic("at") } c := make(chan int); - ac := []chan int{c, c, c}; + ac := []chan int(c, c, c); if len(ac) != 3 { panic("ac") } - aat := [][len(at)]*T{at, at}; + aat := [][len(at)]*T(at, at); if len(aat) != 2 || len(aat[1]) != 3 { panic("aat") } - s := string([]byte{'h', 'e', 'l', 'l', 'o'}); + s := string([]byte('h', 'e', 'l', 'l', 'o')); if s != "hello" { panic("s") } - m := map[string]float{"one":1.0, "two":2.0, "pi":22./7.}; + m := map[string]float("one":1.0, "two":2.0, "pi":22./7.); if len(m) != 3 { panic("m") } - eq([]*R{itor(0), itor(1), itor(2), itor(3), itor(4), itor(5)}); + eq([]*R(itor(0), itor(1), itor(2), itor(3), itor(4), itor(5))); p1 := NewP(1, 2); p2 := NewP(1, 2); diff --git a/test/convlit1.go b/test/convlit1.go index 94d28969b..19f98efbd 100644 --- a/test/convlit1.go +++ b/test/convlit1.go @@ -6,8 +6,7 @@ package main -var a = []int { "a" }; // ERROR "conver|incompatible" -var b = int { 1 }; // ERROR "compos" +var a = []int ( "a" ); // ERROR "conver|incompatible" func f() int diff --git a/test/fixedbugs/bug047.go b/test/fixedbugs/bug047.go index 805647b3d..61b4255b0 100644 --- a/test/fixedbugs/bug047.go +++ b/test/fixedbugs/bug047.go @@ -14,8 +14,8 @@ func main() { }; var s string = "hello"; var f float = 0.2; - t := T{s, f}; + t := T(s, f); type M map[int] int; - m0 := M{7:8}; + m0 := M(7:8); } diff --git a/test/fixedbugs/bug048.go b/test/fixedbugs/bug048.go index fbfc12013..30a015cc2 100644 --- a/test/fixedbugs/bug048.go +++ b/test/fixedbugs/bug048.go @@ -8,5 +8,5 @@ package main func main() { type M map[int] int; - m1 := M{7 : 8}; + m1 := M(7 : 8); } diff --git a/test/fixedbugs/bug096.go b/test/fixedbugs/bug096.go index 81d6c4aad..34673f723 100644 --- a/test/fixedbugs/bug096.go +++ b/test/fixedbugs/bug096.go @@ -9,8 +9,8 @@ package main type A []int; func main() { - a := &A{0}; - b := &A{0, 1}; + a := &A(0); + b := &A(0, 1); } /* diff --git a/test/fixedbugs/bug097.go b/test/fixedbugs/bug097.go index 70bd6e2b4..9286b0673 100644 --- a/test/fixedbugs/bug097.go +++ b/test/fixedbugs/bug097.go @@ -11,7 +11,7 @@ type A []int; func main() { var a [3]A; for i := 0; i < 3; i++ { - a[i] = A{i}; + a[i] = A(i); } if a[0][0] != 0 { panic(); } if a[1][0] != 1 { panic(); } diff --git a/test/fixedbugs/bug098.go b/test/fixedbugs/bug098.go index 8e790a709..09daf3f89 100644 --- a/test/fixedbugs/bug098.go +++ b/test/fixedbugs/bug098.go @@ -10,8 +10,8 @@ type A []int; type M map[int] int; func main() { - var a *A = &A{0}; - var m *M = &M{0 : 0}; // should be legal to use & here for consistency with other composite constructors (prev. line) + var a *A = &A(0); + var m *M = &M(0 : 0); // should be legal to use & here for consistency with other composite constructors (prev. line) } /* diff --git a/test/fixedbugs/bug101.go b/test/fixedbugs/bug101.go index 92487deaa..a87eea199 100644 --- a/test/fixedbugs/bug101.go +++ b/test/fixedbugs/bug101.go @@ -6,7 +6,7 @@ package main -var a = []int { 1, 2, 3 } +var a = []int ( 1, 2, 3 ) func main() { if len(a) != 3 { panic("array len") } diff --git a/test/fixedbugs/bug102.go b/test/fixedbugs/bug102.go index 58480974b..87ec65ee3 100644 --- a/test/fixedbugs/bug102.go +++ b/test/fixedbugs/bug102.go @@ -12,7 +12,7 @@ func main() { if s != "" { panic("bad convert") } - var b1 = [5]byte{'h', 'e', 'l', 'l', 'o'}; + var b1 = [5]byte('h', 'e', 'l', 'l', 'o'); if string(b1) != "hello" { panic("bad convert 1") } diff --git a/test/fixedbugs/bug112.go b/test/fixedbugs/bug112.go index 3c932843c..61f4d00cc 100644 --- a/test/fixedbugs/bug112.go +++ b/test/fixedbugs/bug112.go @@ -7,7 +7,7 @@ package main type T struct { s string } -var t = T{"hi"} +var t = T("hi") func main() {} diff --git a/test/fixedbugs/bug119.go b/test/fixedbugs/bug119.go index 8e51ef2ce..c74d8bb77 100644 --- a/test/fixedbugs/bug119.go +++ b/test/fixedbugs/bug119.go @@ -11,7 +11,7 @@ func foo(a []int) int { } func main() { - a := &[]int{12}; + a := &[]int(12); if x := a[0] ; x != 12 { panicln(1) } if x := (*a)[0]; x != 12 { panicln(2) } if x := foo(*a) ; x != 12 { panicln(3) } // fails (x is incorrect) @@ -28,5 +28,5 @@ panic on line 83 PC=0x14d6 0x52bb?zi mainstart(1, 0, 1606416432, ...) mainstart(0x1, 0x7fff5fbff830, 0x0, ...) -uetli:~/Source/go1/test/bugs gri$ +uetli:~/Source/go1/test/bugs gri$ */ diff --git a/test/fixedbugs/bug120.go b/test/fixedbugs/bug120.go index 10e28034d..e633024f0 100644 --- a/test/fixedbugs/bug120.go +++ b/test/fixedbugs/bug120.go @@ -14,12 +14,12 @@ type Test struct { out string; } -var tests = []Test { - Test{ 123.5, "123.5", "123.5" }, - Test{ 456.7, "456.7", "456.7" }, - Test{ 1e23+8.5e6, "1e23+8.5e6", "1.0000000000000001e+23" }, - Test{ 100000000000000008388608, "100000000000000008388608", "1.0000000000000001e+23" }, - Test{ 1e23+8388609, "1e23+8388609", "1.0000000000000001e+23" }, +var tests = []Test ( + Test( 123.5, "123.5", "123.5" ), + Test( 456.7, "456.7", "456.7" ), + Test( 1e23+8.5e6, "1e23+8.5e6", "1.0000000000000001e+23" ), + Test( 100000000000000008388608, "100000000000000008388608", "1.0000000000000001e+23" ), + Test( 1e23+8388609, "1e23+8388609", "1.0000000000000001e+23" ), // "x" = the floating point value from converting the string x. // These are exactly representable in 64-bit floating point: @@ -32,9 +32,9 @@ var tests = []Test { // The correct answer, of course, would be "1e23+8388608" = 1e23+8388608. // This is not going to be correct until 6g has multiprecision floating point. // A simpler case is "1e23+1", which should also round to 1e23+8388608. - Test{ 1e23+8.388608e6, "1e23+8.388608e6", "1.0000000000000001e+23" }, - Test{ 1e23+1, "1e23+1", "1.0000000000000001e+23" }, -} + Test( 1e23+8.388608e6, "1e23+8.388608e6", "1.0000000000000001e+23" ), + Test( 1e23+1, "1e23+1", "1.0000000000000001e+23" ), +) func main() { ok := true; diff --git a/test/golden.out b/test/golden.out index 128c71f4d..89df568b8 100644 --- a/test/golden.out +++ b/test/golden.out @@ -244,9 +244,8 @@ fixedbugs/bug073.go:9: illegal types for operand: RSH int =========== fixedbugs/bug074.go -fixedbugs/bug074.go:6: syntax error near string -fixedbugs/bug074.go:6: syntax error near string -fixedbugs/bug074.go:7: x: undefined +fixedbugs/bug074.go:6: invalid type for composite literal: string +fixedbugs/bug074.go:6: invalid type for composite literal: string =========== fixedbugs/bug081.go fixedbugs/bug081.go:5: no type x diff --git a/test/indirect.go b/test/indirect.go index 4200d382a..4bf50ded3 100644 --- a/test/indirect.go +++ b/test/indirect.go @@ -9,7 +9,7 @@ package main var m0 map[string]int var m1 *map[string]int var m2 *map[string]int = &m0 -var m3 map[string]int = map[string]int{"a": 1} +var m3 map[string]int = map[string]int("a": 1) var m4 *map[string]int = &m3 var s0 string @@ -25,7 +25,7 @@ var a2 *[10]int = &a0 var b0 []int var b1 *[]int var b2 *[]int = &b0 -var b3 []int = []int{1, 2, 3} +var b3 []int = []int(1, 2, 3) var b4 *[]int = &b3 func crash() diff --git a/test/initcomma.go b/test/initcomma.go index 44053f145..f28c4a60f 100644 --- a/test/initcomma.go +++ b/test/initcomma.go @@ -6,10 +6,10 @@ package main -var a = []int { 1,2, } -var b = [5]int { 1,2,3 } -var c = []int { 1 } -var d = [...]int { 1,2,3 } +var a = []int ( 1,2, ) +var b = [5]int ( 1,2,3 ) +var c = []int ( 1 ) +var d = [...]int ( 1,2,3 ) func main() { if len(a) != 2 { panicln("len a", len(a)) } diff --git a/test/interface4.go b/test/interface4.go index a55936df8..3e8a41b09 100644 --- a/test/interface4.go +++ b/test/interface4.go @@ -31,8 +31,8 @@ func test(name string, i I) { } func ptrs() { - var bigptr BigPtr = BigPtr{ 10000, 2000, 300, 45 }; - var smallptr SmallPtr = SmallPtr{ 12345 }; + var bigptr BigPtr = BigPtr( 10000, 2000, 300, 45 ); + var smallptr SmallPtr = SmallPtr( 12345 ); var intptr IntPtr = 12345; test("bigptr", bigptr); @@ -53,8 +53,8 @@ type Int int32 func (z Int) M() int64 { return int64(z) } func nonptrs() { - var big Big = Big{ 10000, 2000, 300, 45 }; - var small Small = Small{ 12345 }; + var big Big = Big( 10000, 2000, 300, 45 ); + var small Small = Small( 12345 ); var int Int = 12345; test("big", big); diff --git a/test/interface6.go b/test/interface6.go index 6053e51d6..0af6247d1 100644 --- a/test/interface6.go +++ b/test/interface6.go @@ -22,7 +22,7 @@ func (p S1) Get() int { return p.i } func (p S1) Put(i int) { p.i = i } func f1() { - s := S1{1}; + s := S1(1); var i I1 = s; i.Put(2); check(i.Get() == 1, "f1 i"); @@ -30,7 +30,7 @@ func f1() { } func f2() { - s := S1{1}; + s := S1(1); var i I1 = &s; i.Put(2); check(i.Get() == 1, "f2 i"); @@ -38,7 +38,7 @@ func f2() { } func f3() { - s := &S1{1}; + s := &S1(1); var i I1 = s; i.Put(2); check(i.Get() == 1, "f3 i"); @@ -50,7 +50,7 @@ func (p *S2) Get() int { return p.i } func (p *S2) Put(i int) { p.i = i } func f4() { - s := S2{1}; + s := S2(1); var i I1 = s; i.Put(2); check(i.Get() == 2, "f4 i"); @@ -58,7 +58,7 @@ func f4() { } func f5() { - s := S2{1}; + s := S2(1); var i I1 = &s; i.Put(2); check(i.Get() == 2, "f5 i"); @@ -66,7 +66,7 @@ func f5() { } func f6() { - s := &S2{1}; + s := &S2(1); var i I1 = s; i.Put(2); check(i.Get() == 2, "f6 i"); @@ -80,7 +80,7 @@ func (p S3) Get() int64 { return p.l } func (p S3) Put(i int64) { p.l = i } func f7() { - s := S3{1, 2, 3, 4}; + s := S3(1, 2, 3, 4); var i I2 = s; i.Put(5); check(i.Get() == 4, "f7 i"); @@ -88,7 +88,7 @@ func f7() { } func f8() { - s := S3{1, 2, 3, 4}; + s := S3(1, 2, 3, 4); var i I2 = &s; i.Put(5); check(i.Get() == 4, "f8 i"); @@ -96,7 +96,7 @@ func f8() { } func f9() { - s := &S3{1, 2, 3, 4}; + s := &S3(1, 2, 3, 4); var i I2 = s; i.Put(5); check(i.Get() == 4, "f9 i"); @@ -108,7 +108,7 @@ func (p *S4) Get() int64 { return p.l } func (p *S4) Put(i int64) { p.l = i } func f10() { - s := S4{1, 2, 3, 4}; + s := S4(1, 2, 3, 4); var i I2 = s; i.Put(5); check(i.Get() == 5, "f10 i"); @@ -116,7 +116,7 @@ func f10() { } func f11() { - s := S4{1, 2, 3, 4}; + s := S4(1, 2, 3, 4); var i I2 = &s; i.Put(5); check(i.Get() == 5, "f11 i"); @@ -124,7 +124,7 @@ func f11() { } func f12() { - s := &S4{1, 2, 3, 4}; + s := &S4(1, 2, 3, 4); var i I2 = s; i.Put(5); check(i.Get() == 5, "f12 i"); diff --git a/test/map.go b/test/map.go index 085502bf5..f0b7b9b00 100644 --- a/test/map.go +++ b/test/map.go @@ -27,9 +27,9 @@ func P(a []string) string { func main() { // Test a map literal. - mlit := map[string] int { "0":0, "1":1, "2":2, "3":3, "4":4 }; + mlit := map[string] int ( "0":0, "1":1, "2":2, "3":3, "4":4 ); for i := 0; i < len(mlit); i++ { - s := string([]byte{byte(i)+'0'}); + s := string([]byte(byte(i)+'0')); if mlit[s] != i { fmt.Printf("mlit[%s] = %d\n", s, mlit[s]) } @@ -64,14 +64,14 @@ func main() { s := strconv.Itoa(i); s10 := strconv.Itoa(i*10); f := float(i); - t := T{int64(i),f}; + t := T(int64(i),f); apT[i] = new(T); apT[i].i = int64(i); apT[i].f = f; apT[2*i] = new(T); // need twice as many entries as we use, for the nonexistence check apT[2*i].i = int64(i); apT[2*i].f = f; - m := M{i: i+1}; + m := M(i: i+1); mib[i] = (i != 0); mii[i] = 10*i; mfi[float(i)] = 10*i; @@ -140,7 +140,7 @@ func main() { s := strconv.Itoa(i); s10 := strconv.Itoa(i*10); f := float(i); - t := T{int64(i), f}; + t := T(int64(i), f); // BUG m := M(i, i+1); if mib[i] != (i != 0) { fmt.Printf("mib[%d] = %t\n", i, mib[i]); @@ -193,7 +193,7 @@ func main() { for i := 0; i < count; i++ { s := strconv.Itoa(i); f := float(i); - t := T{int64(i), f}; + t := T(int64(i), f); { a, b := mib[i]; if !b { @@ -331,7 +331,7 @@ func main() { for i := count; i < 2*count; i++ { s := strconv.Itoa(i); f := float(i); - t := T{int64(i),f}; + t := T(int64(i),f); { a, b := mib[i]; if b { diff --git a/test/method3.go b/test/method3.go index 491bcdad3..5191c7f1c 100644 --- a/test/method3.go +++ b/test/method3.go @@ -16,7 +16,7 @@ type I interface { } func main() { - var t T = T{0,1,2,3,4}; + var t T = T(0,1,2,3,4); var i I; i = t; if i.Len() != 5 { |