aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/syntax/scanner_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/compile/internal/syntax/scanner_test.go')
-rw-r--r--src/cmd/compile/internal/syntax/scanner_test.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/syntax/scanner_test.go b/src/cmd/compile/internal/syntax/scanner_test.go
new file mode 100644
index 0000000000..0e90812d4b
--- /dev/null
+++ b/src/cmd/compile/internal/syntax/scanner_test.go
@@ -0,0 +1,34 @@
+// Copyright 2016 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package syntax
+
+import (
+ "fmt"
+ "io/ioutil"
+ "testing"
+)
+
+func TestScanner(t *testing.T) {
+ src, err := ioutil.ReadFile("parser.go")
+ if err != nil {
+ t.Fatal(err)
+ }
+ var s scanner
+ s.init(src)
+ for {
+ s.next()
+ if s.tok == _EOF {
+ break
+ }
+ switch s.tok {
+ case _Name:
+ fmt.Println(s.line, s.tok, "=>", s.lit)
+ case _Operator:
+ fmt.Println(s.line, s.tok, "=>", s.op, s.prec)
+ default:
+ fmt.Println(s.line, s.tok)
+ }
+ }
+}