mirror of
https://github.com/alda-lang/alda.git
synced 2026-03-03 18:23:36 +01:00
52 lines
1.0 KiB
Go
52 lines
1.0 KiB
Go
package parser
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"alda.io/client/model"
|
|
_ "alda.io/client/testing"
|
|
)
|
|
|
|
// TestExamples parses and compiles each of the example scores in the `examples`
|
|
// directory.
|
|
//
|
|
// Strictly speaking, this is not testing just the parser. Perhaps these tests
|
|
// should live in another package that consumes both the `parser` and `model`
|
|
// packages, but I'm not sure yet which package that should be.
|
|
func TestExamples(t *testing.T) {
|
|
dir, err := os.Getwd()
|
|
if err != nil {
|
|
t.Errorf("%v\n", err)
|
|
return
|
|
}
|
|
|
|
examplesDir := filepath.Join(filepath.Dir(filepath.Dir(dir)), "examples")
|
|
|
|
err = filepath.Walk(examplesDir,
|
|
func(path string, info os.FileInfo, err error) error {
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if info.IsDir() {
|
|
return nil
|
|
}
|
|
|
|
fmt.Printf("● %s\n", path)
|
|
|
|
scoreUpdates, err := ParseFile(path)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
score := model.NewScore()
|
|
return score.Update(scoreUpdates...)
|
|
})
|
|
if err != nil {
|
|
t.Errorf("%v\n", err)
|
|
}
|
|
}
|