reenable boot tests
This commit is contained in:
parent
aec5f6d3d8
commit
d2faeab35e
89
boot_test.go
89
boot_test.go
@ -20,65 +20,56 @@ func TestBoot(t *testing.T) {
|
|||||||
|
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
|
||||||
if _, err := f.Seek(0, 0); err != nil {
|
n0, err := b.Parse(f)
|
||||||
t.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
b.trace = NewTrace(1)
|
|
||||||
_, err = b.Parse(f)
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// s0 := NewSyntax()
|
s0 := NewSyntax()
|
||||||
// if err := define(s0, n0); err != nil {
|
if err := define(s0, n0); err != nil {
|
||||||
// t.Error(err)
|
t.Error(err)
|
||||||
// return
|
return
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
if err := s0.Init(); err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// _, err = f.Seek(0, 0)
|
if _, err := f.Seek(0, 0); err != nil {
|
||||||
// if err != nil {
|
t.Error(err)
|
||||||
// t.Error(err)
|
return
|
||||||
// return
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
// err = s0.Init()
|
n1, err := s0.Parse(f)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// t.Error(err)
|
t.Error(err)
|
||||||
// return
|
return
|
||||||
// }
|
}
|
||||||
|
|
||||||
// n1, err := s0.Parse(f)
|
checkNode(t, n1, n0)
|
||||||
// if err != nil {
|
if t.Failed() {
|
||||||
// t.Error(err)
|
return
|
||||||
// return
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
// checkNode(t, n1, n0)
|
s1 := NewSyntax()
|
||||||
// if t.Failed() {
|
if err := define(s1, n1); err != nil {
|
||||||
// return
|
t.Error(err)
|
||||||
// }
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// s1 := NewSyntax()
|
_, err = f.Seek(0, 0)
|
||||||
// if err := define(s1, n1); err != nil {
|
if err != nil {
|
||||||
// t.Error(err)
|
t.Error(err)
|
||||||
// return
|
return
|
||||||
// }
|
}
|
||||||
|
|
||||||
// _, err = f.Seek(0, 0)
|
n2, err := s1.Parse(f)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// t.Error(err)
|
t.Error(err)
|
||||||
// return
|
return
|
||||||
// }
|
}
|
||||||
|
|
||||||
// n2, err := s1.Parse(f)
|
checkNode(t, n2, n1)
|
||||||
// if err != nil {
|
|
||||||
// t.Error(err)
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
|
|
||||||
// checkNode(t, n2, n1)
|
|
||||||
}
|
}
|
||||||
|
8
char.go
8
char.go
@ -71,16 +71,16 @@ func (p *charParser) match(t rune) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *charParser) parse(t Trace, c *context) {
|
func (p *charParser) parse(t Trace, c *context) {
|
||||||
t = t.Extend(p.name)
|
// t = t.Extend(p.name)
|
||||||
t.Out1("parsing", c.offset)
|
// t.Out1("parsing", c.offset)
|
||||||
|
|
||||||
if tok, ok := c.token(); !ok || !p.match(tok) {
|
if tok, ok := c.token(); !ok || !p.match(tok) {
|
||||||
t.Out1("fail")
|
// t.Out1("fail")
|
||||||
c.fail(c.offset)
|
c.fail(c.offset)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Out1("success")
|
// t.Out1("success")
|
||||||
c.success(c.offset + 1)
|
c.success(c.offset + 1)
|
||||||
for _, includedBy := range p.includedBy {
|
for _, includedBy := range p.includedBy {
|
||||||
c.store.setMatch(c.offset, includedBy, c.offset+1)
|
c.store.setMatch(c.offset, includedBy, c.offset+1)
|
||||||
|
12
choice.go
12
choice.go
@ -160,8 +160,8 @@ func (p *choiceParser) nodeName() string { return p.name }
|
|||||||
func (p *choiceParser) nodeID() int { return p.id }
|
func (p *choiceParser) nodeID() int { return p.id }
|
||||||
|
|
||||||
func (p *choiceParser) parse(t Trace, c *context) {
|
func (p *choiceParser) parse(t Trace, c *context) {
|
||||||
t = t.Extend(p.name)
|
// t = t.Extend(p.name)
|
||||||
t.Out1("parsing choice", c.offset)
|
// t.Out1("parsing choice", c.offset)
|
||||||
|
|
||||||
// TODO: don't add documentation
|
// TODO: don't add documentation
|
||||||
// if p.commit&Documentation != 0 {
|
// if p.commit&Documentation != 0 {
|
||||||
@ -171,12 +171,12 @@ func (p *choiceParser) parse(t Trace, c *context) {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
if c.fromStore(p.id) {
|
if c.fromStore(p.id) {
|
||||||
t.Out1("found in store, match:")
|
// t.Out1("found in store, match:")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.excluded(c.offset, p.id) {
|
if c.excluded(c.offset, p.id) {
|
||||||
t.Out1("fail, excluded")
|
// t.Out1("fail, excluded")
|
||||||
c.fail(c.offset)
|
c.fail(c.offset)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -223,11 +223,11 @@ func (p *choiceParser) parse(t Trace, c *context) {
|
|||||||
if match {
|
if match {
|
||||||
c.success(to)
|
c.success(to)
|
||||||
c.include(from, p.id)
|
c.include(from, p.id)
|
||||||
t.Out1("choice, success")
|
// t.Out1("choice, success")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Out1("fail")
|
// t.Out1("fail")
|
||||||
c.store.setNoMatch(from, p.id)
|
c.store.setNoMatch(from, p.id)
|
||||||
c.fail(from)
|
c.fail(from)
|
||||||
c.include(from, p.id)
|
c.include(from, p.id)
|
||||||
|
12
sequence.go
12
sequence.go
@ -213,8 +213,8 @@ func (p *sequenceParser) nodeName() string { return p.name }
|
|||||||
func (p *sequenceParser) nodeID() int { return p.id }
|
func (p *sequenceParser) nodeID() int { return p.id }
|
||||||
|
|
||||||
func (p *sequenceParser) parse(t Trace, c *context) {
|
func (p *sequenceParser) parse(t Trace, c *context) {
|
||||||
t = t.Extend(p.name)
|
// t = t.Extend(p.name)
|
||||||
t.Out1("parsing sequence", c.offset)
|
// t.Out1("parsing sequence", c.offset)
|
||||||
|
|
||||||
// if p.commit&Documentation != 0 {
|
// if p.commit&Documentation != 0 {
|
||||||
// // t.Out1("fail, doc")
|
// // t.Out1("fail, doc")
|
||||||
@ -224,7 +224,7 @@ func (p *sequenceParser) parse(t Trace, c *context) {
|
|||||||
|
|
||||||
if !p.allChars {
|
if !p.allChars {
|
||||||
if c.excluded(c.offset, p.id) {
|
if c.excluded(c.offset, p.id) {
|
||||||
t.Out1("fail, excluded")
|
// t.Out1("fail, excluded")
|
||||||
c.fail(c.offset)
|
c.fail(c.offset)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -250,7 +250,7 @@ func (p *sequenceParser) parse(t Trace, c *context) {
|
|||||||
c.include(from, p.id)
|
c.include(from, p.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Out1("fail, not enough items")
|
// t.Out1("fail, not enough items")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,13 +275,13 @@ func (p *sequenceParser) parse(t Trace, c *context) {
|
|||||||
if !p.allChars {
|
if !p.allChars {
|
||||||
for _, includedBy := range p.includedBy {
|
for _, includedBy := range p.includedBy {
|
||||||
if c.excluded(from, includedBy) {
|
if c.excluded(from, includedBy) {
|
||||||
t.Out1("storing included", includedBy)
|
// t.Out1("storing included", includedBy)
|
||||||
c.store.setMatch(from, includedBy, to)
|
c.store.setMatch(from, includedBy, to)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Out1("success")
|
// t.Out1("success")
|
||||||
c.store.setMatch(from, p.id, to)
|
c.store.setMatch(from, p.id, to)
|
||||||
c.success(to)
|
c.success(to)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user