diff options
author | Robert Griesemer <gri@golang.org> | 2009-03-26 10:53:14 -0700 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2009-03-26 10:53:14 -0700 |
commit | ecfb1855e02ed9bc71b904a7a51afdaa3631c073 (patch) | |
tree | d73a42b68db17bfa6044151ce3e0f62f666c5442 /src/lib/go/scanner_test.go | |
parent | 95207c8d8eda9ff909cd5ca6bbef053a6ce4bc92 (diff) | |
download | golang-ecfb1855e02ed9bc71b904a7a51afdaa3631c073.tar.gz |
- introduce explicit Token type
- convert some functions into methods
- corresponding changes in pretty
R=r
DELTA=57 (3 added, 0 deleted, 54 changed)
OCL=26764
CL=26777
Diffstat (limited to 'src/lib/go/scanner_test.go')
-rw-r--r-- | src/lib/go/scanner_test.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/lib/go/scanner_test.go b/src/lib/go/scanner_test.go index 247bbe4df..2309fcd09 100644 --- a/src/lib/go/scanner_test.go +++ b/src/lib/go/scanner_test.go @@ -20,18 +20,18 @@ const /* class */ ( ) -func tokenclass(tok int) int { +func tokenclass(tok token.Token) int { switch { - case token.IsLiteral(tok): return literal; - case token.IsOperator(tok): return operator; - case token.IsKeyword(tok): return keyword; + case tok.IsLiteral(): return literal; + case tok.IsOperator(): return operator; + case tok.IsKeyword(): return keyword; } return special; } type elt struct { - tok int; + tok token.Token; lit string; class int; } @@ -188,7 +188,7 @@ func Test(t *testing.T) { index := 0; eloc := scanner.Location{0, 1, 1}; scanner.Tokenize(io.StringBytes(src), &TestErrorHandler{t}, true, - func (loc Location, tok int, litb []byte) bool { + func (loc Location, tok token.Token, litb []byte) bool { e := elt{token.EOF, "", special}; if index < len(tokens) { e = tokens[index]; @@ -208,9 +208,9 @@ func Test(t *testing.T) { t.Errorf("bad column for %s: got %d, expected %d", lit, loc.Col, eloc.Col); } if tok != e.tok { - t.Errorf("bad token for %s: got %s, expected %s", lit, token.TokenString(tok), token.TokenString(e.tok)); + t.Errorf("bad token for %s: got %s, expected %s", lit, tok.String(), e.tok.String()); } - if token.IsLiteral(e.tok) && lit != e.lit { + if e.tok.IsLiteral() && lit != e.lit { t.Errorf("bad literal for %s: got %s, expected %s", lit, lit, e.lit); } if tokenclass(tok) != e.class { |