github.com/NeowayLabs/nash@v0.2.2-0.20200127205349-a227041ffd50/spec_test.go (about)

     1  package nash
     2  
     3  import (
     4  	"bytes"
     5  	"io/ioutil"
     6  	"path/filepath"
     7  	"testing"
     8  
     9  	"github.com/madlambda/nash/tests"
    10  	"golang.org/x/exp/ebnf"
    11  )
    12  
    13  func TestSpecificationIsSane(t *testing.T) {
    14  	filename := filepath.Join(tests.Projectpath, "spec.ebnf")
    15  	content, err := ioutil.ReadFile(filename)
    16  	if err != nil {
    17  		t.Error(err)
    18  		return
    19  	}
    20  
    21  	buf := bytes.NewBuffer(content)
    22  	grammar, err := ebnf.Parse(filename, buf)
    23  	if err != nil {
    24  		t.Error(err)
    25  		return
    26  	}
    27  
    28  	err = ebnf.Verify(grammar, "program")
    29  	if err != nil {
    30  		t.Error(err)
    31  		return
    32  	}
    33  }