diff options
author | Robert Griesemer <gri@golang.org> | 2009-03-26 16:08:44 -0700 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2009-03-26 16:08:44 -0700 |
commit | 795ddc5b1475926e5f33cc3feccc8f3f419438da (patch) | |
tree | 3ea5470c1c587e84855b4a4defa12193d8e1b35f /src/lib/go/scanner_test.go | |
parent | 0927eb15dfd27af2dda7427839558cb37dfb19d5 (diff) | |
download | golang-795ddc5b1475926e5f33cc3feccc8f3f419438da.tar.gz |
- renamed scanner.Location to token.Position
- by moving Position into token, scanner dependencies
are removed from several files
- clearer field names in token.Position, now possible to
have a Pos() accessor w/o naming conflicts
- added Pos() accessor
- use anonymous token.Position field in AST nodes
R=r
DELTA=244 (28 added, 55 deleted, 161 changed)
OCL=26786
CL=26793
Diffstat (limited to 'src/lib/go/scanner_test.go')
-rw-r--r-- | src/lib/go/scanner_test.go | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/lib/go/scanner_test.go b/src/lib/go/scanner_test.go index 2309fcd09..2042b191f 100644 --- a/src/lib/go/scanner_test.go +++ b/src/lib/go/scanner_test.go @@ -160,7 +160,7 @@ type TestErrorHandler struct { t *testing.T } -func (h *TestErrorHandler) Error(loc scanner.Location, msg string) { +func (h *TestErrorHandler) Error(pos token.Position, msg string) { h.t.Errorf("Error() called (msg = %s)", msg); } @@ -186,9 +186,9 @@ func Test(t *testing.T) { // verify scan index := 0; - eloc := scanner.Location{0, 1, 1}; + eloc := token.Position{0, 1, 1}; scanner.Tokenize(io.StringBytes(src), &TestErrorHandler{t}, true, - func (loc Location, tok token.Token, litb []byte) bool { + func (pos token.Position, tok token.Token, litb []byte) bool { e := elt{token.EOF, "", special}; if index < len(tokens) { e = tokens[index]; @@ -196,16 +196,16 @@ func Test(t *testing.T) { lit := string(litb); if tok == token.EOF { lit = "<EOF>"; - eloc.Col = 0; + eloc.Column = 0; } - if loc.Pos != eloc.Pos { - t.Errorf("bad position for %s: got %d, expected %d", lit, loc.Pos, eloc.Pos); + if pos.Offset != eloc.Offset { + t.Errorf("bad position for %s: got %d, expected %d", lit, pos.Offset, eloc.Offset); } - if loc.Line != eloc.Line { - t.Errorf("bad line for %s: got %d, expected %d", lit, loc.Line, eloc.Line); + if pos.Line != eloc.Line { + t.Errorf("bad line for %s: got %d, expected %d", lit, pos.Line, eloc.Line); } - if loc.Col != eloc.Col { - t.Errorf("bad column for %s: got %d, expected %d", lit, loc.Col, eloc.Col); + if pos.Column!= eloc.Column { + t.Errorf("bad column for %s: got %d, expected %d", lit, pos.Column, eloc.Column); } if tok != e.tok { t.Errorf("bad token for %s: got %s, expected %s", lit, tok.String(), e.tok.String()); @@ -216,7 +216,7 @@ func Test(t *testing.T) { if tokenclass(tok) != e.class { t.Errorf("bad class for %s: got %d, expected %d", lit, tokenclass(tok), e.class); } - eloc.Pos += len(lit) + len(whitespace); + eloc.Offset += len(lit) + len(whitespace); eloc.Line += NewlineCount(lit) + whitespace_linecount; index++; return tok != token.EOF; |