]> Cypherpunks repositories - gostls13.git/commitdiff
clean up some tests
authorRob Pike <r@golang.org>
Mon, 5 Jan 2009 21:09:34 +0000 (13:09 -0800)
committerRob Pike <r@golang.org>
Mon, 5 Jan 2009 21:09:34 +0000 (13:09 -0800)
R=rsc
DELTA=10  (1 added, 2 deleted, 7 changed)
OCL=22033
CL=22033

test/fixedbugs/bug027.go
test/fixedbugs/bug045.go
test/fixedbugs/bug054.go
test/fixedbugs/bug097.go
test/fixedbugs/bug119.go

index d15da9cd421a9088af2fb765c04e0081738ab661..428a4b6a889a8e3dbacd0e02d48a2831c59a3427 100644 (file)
@@ -17,7 +17,7 @@ type Vector struct {
 func New() *Vector {
        v := new(*Vector);
        v.nelem = 0;
-       v.elem = new([10]Element);
+       v.elem = new([]Element, 10);
        return v;
 }
 
@@ -30,9 +30,8 @@ func (v *Vector) Insert(e Element) {
        v.nelem++;
 }
 
-type I struct { val int; };  // BUG: can't be local;
-
 func main() {
+       type I struct { val int; };
        i0 := new(*I); i0.val = 0;
        i1 := new(*I); i1.val = 11;
        i2 := new(*I); i2.val = 222;
index d8a712c6dab0cf47f65bd25b4684850220185abf..37c17c13bb78ed448850e44e26fbbe9a6d32ef48 100644 (file)
@@ -13,7 +13,7 @@ type T struct {
 func main() {
        var ta []*T;
 
-       ta = new([1]*T);
+       ta = *new(*[1]*T);      // TODO: the first * shouldn't be necessary
        ta[0] = nil;
 }
 /*
index 2caff0f0ca074c01f2c774f331eaa5e5da063a43..c121fb5e7617753e1690d4ef4a01d57ffc6b5b9f 100644 (file)
@@ -31,7 +31,7 @@ func (s *TStruct) field(i int) *TStruct {
 
 func main() {
        v := new(*Vector);
-       v.elem = new([10]Element);
+       v.elem = new([]Element, 10);
        t := new(*TStruct);
        t.name = "hi";
        v.elem[0] = t;
index 21376837e32b3d6ccfa2d2aa8fe44e7aeb543323..fe5fd4b87e3910c2414ce2811f72759c21d7b7fd 100644 (file)
@@ -9,9 +9,9 @@ package main
 type A []int;
 
 func main() {
-       var a [3]*A;
+       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(); }
index e565cffd4f6b02cd702183d5688727a5641fff4b..8e51ef2cecbe621c88b788daed38f352366e4486 100644 (file)
@@ -7,14 +7,14 @@
 package main
 
 func foo(a []int) int {
-       return (*a)[0]  // this seesm to do the wrong thing
+       return a[0]  // this seems to do the wrong thing
 }
 
 func main() {
        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)
+       if x := foo(*a) ; x != 12 { panicln(3) }  // fails (x is incorrect)
 }
 
 /*