aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/syntax/scanner_test.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2018-01-02 13:36:38 -0800
committerRobert Griesemer <gri@golang.org>2018-02-12 22:57:49 +0000
commite87f2a1b70f4751551ea5bd33e0db3417e76ac4c (patch)
treeac4c32bb09839baea1e60de2d7e757b9709988ff /src/cmd/compile/internal/syntax/scanner_test.go
parent7ac393a3f208ab72263a245b80e22ad62abae565 (diff)
downloadgo-e87f2a1b70f4751551ea5bd33e0db3417e76ac4c.tar.gz
go-e87f2a1b70f4751551ea5bd33e0db3417e76ac4c.zip
cmd/compile/internal/syntax: remove ParseBytes from API - not needed
R=go1.11 Also: Minor updates to syntax.Parse doc string. Change-Id: I649965be9670a2f1c3de2cdb350634ed21e36ad9 Reviewed-on: https://go-review.googlesource.com/85663 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/cmd/compile/internal/syntax/scanner_test.go')
-rw-r--r--src/cmd/compile/internal/syntax/scanner_test.go15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/cmd/compile/internal/syntax/scanner_test.go b/src/cmd/compile/internal/syntax/scanner_test.go
index 53995e0c79..ba4ba8f69c 100644
--- a/src/cmd/compile/internal/syntax/scanner_test.go
+++ b/src/cmd/compile/internal/syntax/scanner_test.go
@@ -5,6 +5,7 @@
package syntax
import (
+ "bytes"
"fmt"
"os"
"strings"
@@ -42,17 +43,17 @@ func TestScanner(t *testing.T) {
func TestTokens(t *testing.T) {
// make source
- var buf []byte
+ var buf bytes.Buffer
for i, s := range sampleTokens {
- buf = append(buf, "\t\t\t\t"[:i&3]...) // leading indentation
- buf = append(buf, s.src...) // token
- buf = append(buf, " "[:i&7]...) // trailing spaces
- buf = append(buf, "/* foo */ // bar\n"...) // comments
+ buf.WriteString("\t\t\t\t"[:i&3]) // leading indentation
+ buf.WriteString(s.src) // token
+ buf.WriteString(" "[:i&7]) // trailing spaces
+ buf.WriteString("/* foo */ // bar\n") // comments
}
// scan source
var got scanner
- got.init(&bytesReader{buf}, nil, nil)
+ got.init(&buf, nil, nil)
got.next()
for i, want := range sampleTokens {
nlsemi := false
@@ -337,7 +338,7 @@ func TestScanErrors(t *testing.T) {
} {
var s scanner
nerrors := 0
- s.init(&bytesReader{[]byte(test.src)}, func(line, col uint, msg string) {
+ s.init(strings.NewReader(test.src), func(line, col uint, msg string) {
nerrors++
// only check the first error
if nerrors == 1 {