summaryrefslogtreecommitdiff
path: root/src/pkg/scanner/scanner_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/scanner/scanner_test.go')
-rw-r--r--src/pkg/scanner/scanner_test.go23
1 files changed, 0 insertions, 23 deletions
diff --git a/src/pkg/scanner/scanner_test.go b/src/pkg/scanner/scanner_test.go
index cf9ad0111..4ba1587e8 100644
--- a/src/pkg/scanner/scanner_test.go
+++ b/src/pkg/scanner/scanner_test.go
@@ -13,14 +13,12 @@ import (
"utf8"
)
-
// A StringReader delivers its data one string segment at a time via Read.
type StringReader struct {
data []string
step int
}
-
func (r *StringReader) Read(p []byte) (n int, err os.Error) {
if r.step < len(r.data) {
s := r.data[r.step]
@@ -32,7 +30,6 @@ func (r *StringReader) Read(p []byte) (n int, err os.Error) {
return
}
-
func readRuneSegments(t *testing.T, segments []string) {
got := ""
want := strings.Join(segments, "")
@@ -49,7 +46,6 @@ func readRuneSegments(t *testing.T, segments []string) {
}
}
-
var segmentList = [][]string{
{},
{""},
@@ -61,14 +57,12 @@ var segmentList = [][]string{
{"Hello", ", ", "", "World", "!"},
}
-
func TestNext(t *testing.T) {
for _, s := range segmentList {
readRuneSegments(t, s)
}
}
-
type token struct {
tok int
text string
@@ -234,7 +228,6 @@ var tokenList = []token{
{'(', "("},
}
-
func makeSource(pattern string) *bytes.Buffer {
var buf bytes.Buffer
for _, k := range tokenList {
@@ -243,7 +236,6 @@ func makeSource(pattern string) *bytes.Buffer {
return &buf
}
-
func checkTok(t *testing.T, s *Scanner, line, got, want int, text string) {
if got != want {
t.Fatalf("tok = %s, want %s for %q", TokenString(got), TokenString(want), text)
@@ -263,7 +255,6 @@ func checkTok(t *testing.T, s *Scanner, line, got, want int, text string) {
}
}
-
func countNewlines(s string) int {
n := 0
for _, ch := range s {
@@ -274,7 +265,6 @@ func countNewlines(s string) int {
return n
}
-
func testScan(t *testing.T, mode uint) {
s := new(Scanner).Init(makeSource(" \t%s\n"))
s.Mode = mode
@@ -290,13 +280,11 @@ func testScan(t *testing.T, mode uint) {
checkTok(t, s, line, tok, EOF, "")
}
-
func TestScan(t *testing.T) {
testScan(t, GoTokens)
testScan(t, GoTokens&^SkipComments)
}
-
func TestPosition(t *testing.T) {
src := makeSource("\t\t\t\t%s\n")
s := new(Scanner).Init(src)
@@ -323,7 +311,6 @@ func TestPosition(t *testing.T) {
}
}
-
func TestScanZeroMode(t *testing.T) {
src := makeSource("%s\n")
str := src.String()
@@ -345,7 +332,6 @@ func TestScanZeroMode(t *testing.T) {
}
}
-
func testScanSelectedMode(t *testing.T, mode uint, class int) {
src := makeSource("%s\n")
s := new(Scanner).Init(src)
@@ -362,7 +348,6 @@ func testScanSelectedMode(t *testing.T, mode uint, class int) {
}
}
-
func TestScanSelectedMask(t *testing.T) {
testScanSelectedMode(t, 0, 0)
testScanSelectedMode(t, ScanIdents, Ident)
@@ -375,7 +360,6 @@ func TestScanSelectedMask(t *testing.T) {
testScanSelectedMode(t, ScanComments, Comment)
}
-
func TestScanNext(t *testing.T) {
s := new(Scanner).Init(bytes.NewBufferString("if a == bcd /* comment */ {\n\ta += c\n} // line comment ending in eof"))
checkTok(t, s, 1, s.Scan(), Ident, "if")
@@ -397,7 +381,6 @@ func TestScanNext(t *testing.T) {
}
}
-
func TestScanWhitespace(t *testing.T) {
var buf bytes.Buffer
var ws uint64
@@ -418,7 +401,6 @@ func TestScanWhitespace(t *testing.T) {
}
}
-
func testError(t *testing.T, src, msg string, tok int) {
s := new(Scanner).Init(bytes.NewBufferString(src))
errorCalled := false
@@ -443,7 +425,6 @@ func testError(t *testing.T, src, msg string, tok int) {
}
}
-
func TestError(t *testing.T) {
testError(t, "\x00", "illegal character NUL", 0)
testError(t, "\xff", "illegal UTF-8 encoding", utf8.RuneError)
@@ -459,7 +440,6 @@ func TestError(t *testing.T) {
testError(t, `"abc`+"\xff"+`def"`, "illegal UTF-8 encoding", String)
}
-
func checkPos(t *testing.T, got, want Position) {
if got.Offset != want.Offset || got.Line != want.Line || got.Column != want.Column {
t.Errorf("got offset, line, column = %d, %d, %d; want %d, %d, %d",
@@ -467,7 +447,6 @@ func checkPos(t *testing.T, got, want Position) {
}
}
-
func checkNextPos(t *testing.T, s *Scanner, offset, line, column, char int) {
if ch := s.Next(); ch != char {
t.Errorf("ch = %s, want %s", TokenString(ch), TokenString(char))
@@ -476,7 +455,6 @@ func checkNextPos(t *testing.T, s *Scanner, offset, line, column, char int) {
checkPos(t, s.Pos(), want)
}
-
func checkScanPos(t *testing.T, s *Scanner, offset, line, column, char int) {
want := Position{Offset: offset, Line: line, Column: column}
checkPos(t, s.Pos(), want)
@@ -489,7 +467,6 @@ func checkScanPos(t *testing.T, s *Scanner, offset, line, column, char int) {
checkPos(t, s.Position, want)
}
-
func TestPos(t *testing.T) {
// corner case: empty source
s := new(Scanner).Init(bytes.NewBufferString(""))