More tests on AST
This commit is contained in:
@@ -45,6 +45,8 @@ type Subnode struct {
|
|||||||
Definitions []Definition
|
Definitions []Definition
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Subnode) Pos() Position { return s.Position }
|
||||||
|
|
||||||
type Value interface {
|
type Value interface {
|
||||||
Node
|
Node
|
||||||
isValue()
|
isValue()
|
||||||
@@ -115,7 +117,11 @@ type Comment struct {
|
|||||||
Doc bool // true if starts with //#
|
Doc bool // true if starts with //#
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Comment) Pos() Position { return c.Position }
|
||||||
|
|
||||||
type Pragma struct {
|
type Pragma struct {
|
||||||
Position Position
|
Position Position
|
||||||
Text string
|
Text string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *Pragma) Pos() Position { return p.Position }
|
||||||
|
|||||||
@@ -84,11 +84,29 @@ func TestASTCoverage(t *testing.T) {
|
|||||||
|
|
||||||
// Package
|
// Package
|
||||||
pkg := &parser.Package{Position: pos}
|
pkg := &parser.Package{Position: pos}
|
||||||
// Package implements Node?
|
|
||||||
// ast.go: func (p *Package) Pos() Position { return p.Position }
|
|
||||||
// Yes.
|
|
||||||
n = pkg
|
n = pkg
|
||||||
if n.Pos() != pos {
|
if n.Pos() != pos {
|
||||||
t.Error("Package.Pos failed")
|
t.Error("Package.Pos failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Subnode
|
||||||
|
sn := &parser.Subnode{Position: pos}
|
||||||
|
n = sn
|
||||||
|
if n.Pos() != pos {
|
||||||
|
t.Error("Subnode.Pos failed")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Comment
|
||||||
|
cmt := &parser.Comment{Position: pos}
|
||||||
|
n = cmt
|
||||||
|
if n.Pos() != pos {
|
||||||
|
t.Error("Comment.Pos failed")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pragma
|
||||||
|
prg := &parser.Pragma{Position: pos}
|
||||||
|
n = prg
|
||||||
|
if n.Pos() != pos {
|
||||||
|
t.Error("Pragma.Pos failed")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user