]> Cypherpunks.ru repositories - gostls13.git/commitdiff
cmd/compile/internal/types2: enable TestIssue25627
authorRobert Griesemer <gri@golang.org>
Sat, 20 Feb 2021 00:47:04 +0000 (16:47 -0800)
committerRobert Griesemer <gri@golang.org>
Tue, 23 Feb 2021 04:13:10 +0000 (04:13 +0000)
Since we have syntax.Walk, we can make this test work again.

Change-Id: I55cbde7303e5bcbe1123b6679f2ce859d377fd86
Reviewed-on: https://go-review.googlesource.com/c/go/+/294472
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
src/cmd/compile/internal/types2/issues_test.go

index 5a32fa590acf689ebbc1920c9a198d52e5406d10..ba7cefb8925a8ae6c20c68e86b7666c0176d581e 100644 (file)
@@ -300,8 +300,6 @@ func TestIssue22525(t *testing.T) {
 }
 
 func TestIssue25627(t *testing.T) {
-       t.Skip("requires syntax tree inspection")
-
        const prefix = `package p; import "unsafe"; type P *struct{}; type I interface{}; type T `
        // The src strings (without prefix) are constructed such that the number of semicolons
        // plus one corresponds to the number of fields expected in the respective struct.
@@ -325,20 +323,17 @@ func TestIssue25627(t *testing.T) {
                        }
                }
 
-               unimplemented()
-               /*
-                       ast.Inspect(f, func(n syntax.Node) bool {
-                               if spec, _ := n.(*syntax.TypeDecl); spec != nil {
-                                       if tv, ok := info.Types[spec.Type]; ok && spec.Name.Value == "T" {
-                                               want := strings.Count(src, ";") + 1
-                                               if got := tv.Type.(*Struct).NumFields(); got != want {
-                                                       t.Errorf("%s: got %d fields; want %d", src, got, want)
-                                               }
+               syntax.Walk(f, func(n syntax.Node) bool {
+                       if decl, _ := n.(*syntax.TypeDecl); decl != nil {
+                               if tv, ok := info.Types[decl.Type]; ok && decl.Name.Value == "T" {
+                                       want := strings.Count(src, ";") + 1
+                                       if got := tv.Type.(*Struct).NumFields(); got != want {
+                                               t.Errorf("%s: got %d fields; want %d", src, got, want)
                                        }
                                }
-                               return true
-                       })
-               */
+                       }
+                       return false
+               })
        }
 }