1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
12 var goodGrammars
= []string{
18 `Program = "a" | "b" "c" .`,
20 `Program = "a" … "z" .`,
24 Note = Do | (Re | Mi | Fa | So | La) | Ti .
35 var badGrammars
= []string{
46 func checkGood(t
*testing
.T
, src
string) {
47 grammar
, err
:= Parse("", bytes
.NewBuffer([]byte(src
)))
49 t
.Errorf("Parse(%s) failed: %v", src
, err
)
52 if err
= Verify(grammar
, "Program"); err
!= nil {
53 t
.Errorf("Verify(%s) failed: %v", src
, err
)
57 func checkBad(t
*testing
.T
, src
string) {
58 _
, err
:= Parse("", bytes
.NewBuffer([]byte(src
)))
60 t
.Errorf("Parse(%s) should have failed", src
)
64 func TestGrammars(t
*testing
.T
) {
65 for _
, src
:= range goodGrammars
{
68 for _
, src
:= range badGrammars
{