reenable boot tests

This commit is contained in:
Arpad Ryszka 2017-10-27 16:23:17 +02:00
parent aec5f6d3d8
commit d2faeab35e
4 changed files with 56 additions and 65 deletions

View File

@ -20,65 +20,56 @@ func TestBoot(t *testing.T) {
defer f.Close()
if _, err := f.Seek(0, 0); err != nil {
t.Error(err)
return
}
b.trace = NewTrace(1)
_, err = b.Parse(f)
n0, err := b.Parse(f)
if err != nil {
t.Error(err)
return
}
// s0 := NewSyntax()
// if err := define(s0, n0); err != nil {
// t.Error(err)
// return
// }
s0 := NewSyntax()
if err := define(s0, n0); err != nil {
t.Error(err)
return
}
// _, err = f.Seek(0, 0)
// if err != nil {
// t.Error(err)
// return
// }
if err := s0.Init(); err != nil {
t.Error(err)
return
}
// err = s0.Init()
// if err != nil {
// t.Error(err)
// return
// }
if _, err := f.Seek(0, 0); err != nil {
t.Error(err)
return
}
// n1, err := s0.Parse(f)
// if err != nil {
// t.Error(err)
// return
// }
n1, err := s0.Parse(f)
if err != nil {
t.Error(err)
return
}
// checkNode(t, n1, n0)
// if t.Failed() {
// return
// }
checkNode(t, n1, n0)
if t.Failed() {
return
}
// s1 := NewSyntax()
// if err := define(s1, n1); err != nil {
// t.Error(err)
// return
// }
s1 := NewSyntax()
if err := define(s1, n1); err != nil {
t.Error(err)
return
}
// _, err = f.Seek(0, 0)
// if err != nil {
// t.Error(err)
// return
// }
_, err = f.Seek(0, 0)
if err != nil {
t.Error(err)
return
}
// n2, err := s1.Parse(f)
// if err != nil {
// t.Error(err)
// return
// }
n2, err := s1.Parse(f)
if err != nil {
t.Error(err)
return
}
// checkNode(t, n2, n1)
checkNode(t, n2, n1)
}

View File

@ -71,16 +71,16 @@ func (p *charParser) match(t rune) bool {
}
func (p *charParser) parse(t Trace, c *context) {
t = t.Extend(p.name)
t.Out1("parsing", c.offset)
// t = t.Extend(p.name)
// t.Out1("parsing", c.offset)
if tok, ok := c.token(); !ok || !p.match(tok) {
t.Out1("fail")
// t.Out1("fail")
c.fail(c.offset)
return
}
t.Out1("success")
// t.Out1("success")
c.success(c.offset + 1)
for _, includedBy := range p.includedBy {
c.store.setMatch(c.offset, includedBy, c.offset+1)

View File

@ -160,8 +160,8 @@ func (p *choiceParser) nodeName() string { return p.name }
func (p *choiceParser) nodeID() int { return p.id }
func (p *choiceParser) parse(t Trace, c *context) {
t = t.Extend(p.name)
t.Out1("parsing choice", c.offset)
// t = t.Extend(p.name)
// t.Out1("parsing choice", c.offset)
// TODO: don't add documentation
// if p.commit&Documentation != 0 {
@ -171,12 +171,12 @@ func (p *choiceParser) parse(t Trace, c *context) {
// }
if c.fromStore(p.id) {
t.Out1("found in store, match:")
// t.Out1("found in store, match:")
return
}
if c.excluded(c.offset, p.id) {
t.Out1("fail, excluded")
// t.Out1("fail, excluded")
c.fail(c.offset)
return
}
@ -223,11 +223,11 @@ func (p *choiceParser) parse(t Trace, c *context) {
if match {
c.success(to)
c.include(from, p.id)
t.Out1("choice, success")
// t.Out1("choice, success")
return
}
t.Out1("fail")
// t.Out1("fail")
c.store.setNoMatch(from, p.id)
c.fail(from)
c.include(from, p.id)

View File

@ -213,8 +213,8 @@ func (p *sequenceParser) nodeName() string { return p.name }
func (p *sequenceParser) nodeID() int { return p.id }
func (p *sequenceParser) parse(t Trace, c *context) {
t = t.Extend(p.name)
t.Out1("parsing sequence", c.offset)
// t = t.Extend(p.name)
// t.Out1("parsing sequence", c.offset)
// if p.commit&Documentation != 0 {
// // t.Out1("fail, doc")
@ -224,7 +224,7 @@ func (p *sequenceParser) parse(t Trace, c *context) {
if !p.allChars {
if c.excluded(c.offset, p.id) {
t.Out1("fail, excluded")
// t.Out1("fail, excluded")
c.fail(c.offset)
return
}
@ -250,7 +250,7 @@ func (p *sequenceParser) parse(t Trace, c *context) {
c.include(from, p.id)
}
t.Out1("fail, not enough items")
// t.Out1("fail, not enough items")
return
}
@ -275,13 +275,13 @@ func (p *sequenceParser) parse(t Trace, c *context) {
if !p.allChars {
for _, includedBy := range p.includedBy {
if c.excluded(from, includedBy) {
t.Out1("storing included", includedBy)
// t.Out1("storing included", includedBy)
c.store.setMatch(from, includedBy, to)
}
}
}
t.Out1("success")
// t.Out1("success")
c.store.setMatch(from, p.id, to)
c.success(to)