Skip to content

Commit 191e9ce

Browse files
committed
go/gcexportdata: switch constant used in tests
text/scanner was used in tests because it was unlikely to change between releases, but of course, a line number changed, breaking the tests. Use a different constant for testing that remained on the same line. Change-Id: I41425728e0918ffe388b3c8df9fd71e8371eb38e Reviewed-on: https://go-review.googlesource.com/c/163197 Run-TryBot: Rebecca Stambler <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Julie Qiu <[email protected]>
1 parent 97f80cd commit 191e9ce

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

go/gcexportdata/example_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func ExampleNewImporter() {
7575
// choosing a package that is unlikely to change across releases
7676
import "text/scanner"
7777
78-
const eof = scanner.EOF
78+
const scanIdents = scanner.ScanIdents
7979
`
8080
fset := token.NewFileSet()
8181
f, err := parser.ParseFile(fset, "myscanner.go", src, 0)
@@ -92,7 +92,7 @@ const eof = scanner.EOF
9292
}
9393

9494
// object from imported package
95-
pi := packages["text/scanner"].Scope().Lookup("EOF")
95+
pi := packages["text/scanner"].Scope().Lookup("ScanIdents")
9696
fmt.Printf("const %s.%s %s = %s // %s\n",
9797
pi.Pkg().Path(),
9898
pi.Name(),
@@ -102,7 +102,7 @@ const eof = scanner.EOF
102102
)
103103

104104
// object in source package
105-
twopi := pkg.Scope().Lookup("eof")
105+
twopi := pkg.Scope().Lookup("scanIdents")
106106
fmt.Printf("const %s %s = %s // %s\n",
107107
twopi.Name(),
108108
twopi.Type(),
@@ -112,8 +112,8 @@ const eof = scanner.EOF
112112

113113
// Output:
114114
//
115-
// const text/scanner.EOF untyped int = -1 // $GOROOT/src/text/scanner/scanner.go:75:1
116-
// const eof untyped int = -1 // myscanner.go:6:7
115+
// const text/scanner.ScanIdents untyped int = 4 // $GOROOT/src/text/scanner/scanner.go:62:1
116+
// const scanIdents untyped int = 4 // myscanner.go:6:7
117117
}
118118

119119
func slashify(posn token.Position) token.Position {

0 commit comments

Comments
 (0)