Files
alda-mirror/client/parser/comments_test.go
Dave Yarwood 3588fd4689 make PitchIdentifier an interface instead of implicitly using certain fields of Note in certain situations
In accordance with the "don't make invalid data representable" principle.

This also allows us to create a LispPitch type in alda.lisp, which will just
wrap PitchIdentifier.
2019-11-04 09:32:51 -05:00

46 lines
1.1 KiB
Go

package parser
import (
"testing"
"alda.io/client/model"
_ "alda.io/client/testing"
)
func TestComments(t *testing.T) {
executeParseTestCases(
t,
parseTestCase{
label: "simple comment",
given: `piano: c
# d
e`,
expect: []model.ScoreUpdate{
model.PartDeclaration{Names: []string{"piano"}},
model.Note{Pitch: model.LetterAndAccidentals{NoteLetter: model.C}},
model.Note{Pitch: model.LetterAndAccidentals{NoteLetter: model.E}},
},
},
parseTestCase{
label: "comment at the end of a line",
given: `piano: c # d
e`,
expect: []model.ScoreUpdate{
model.PartDeclaration{Names: []string{"piano"}},
model.Note{Pitch: model.LetterAndAccidentals{NoteLetter: model.C}},
model.Note{Pitch: model.LetterAndAccidentals{NoteLetter: model.E}},
},
},
parseTestCase{
label: "comment without a leading space",
given: `piano: c #d
e`,
expect: []model.ScoreUpdate{
model.PartDeclaration{Names: []string{"piano"}},
model.Note{Pitch: model.LetterAndAccidentals{NoteLetter: model.C}},
model.Note{Pitch: model.LetterAndAccidentals{NoteLetter: model.E}},
},
},
)
}