1 // Copyright 2019 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
14 func TestIssue33649(t *testing.T) {
15 for _, src := range []string{
16 `package p; func _()`,
17 `package p; func _() {`,
18 `package p; func _() { _ = 0`,
19 `package p; func _() { _ = 0 }`,
21 fset := token.NewFileSet()
22 f, _ := parser.ParseFile(fset, "", src, parser.AllErrors)
24 panic("invalid test setup: parser didn't return an AST")
27 // find corresponding token.File
29 fset.Iterate(func(f *token.File) bool {
33 tfEnd := tf.Base() + tf.Size()
35 fd := f.Decls[len(f.Decls)-1].(*ast.FuncDecl)
36 fdEnd := int(fd.End())
39 t.Errorf("%q: got fdEnd = %d; want %d (base = %d, size = %d)", src, fdEnd, tfEnd, tf.Base(), tf.Size())