3 #(use-modules (srfi srfi-13)
9 #(define (my-parse-string-result str parser)
10 "Parse `str', which is supposed to contain a music expression."
11 (ly:parser-parse-string parser
12 (format #f "parseStringResult = \\notemode { ~a }" str))
13 (ly:parser-lookup parser 'parseStringResult))
15 #(define (my-read-lily-expression chr port)
16 (let ((lily-string (call-with-output-string
18 (do ((c (read-char port) (read-char port)))
20 (char=? (peek-char port) #\]))
23 `(let* ((parser-clone (ly:clone-parser parser))
24 (input-str (string-trim-both ,lily-string))
25 (music (car (ly:music-property (my-parse-string-result input-str parser-clone)
27 (result-str (string-trim-both (music->lily-string music))))
28 (cons input-str result-str))))
30 #(read-hash-extend #\[ my-read-lily-expression)
32 #(define test-number 0)
34 #(define (lily-string->markup str)
35 (make-column-markup (string-split str #\NewLine)))
37 initTest = #(def-music-function (parser location) ()
38 ;; Before using display-lily-music, it must be
39 ;; inited using display-lily-init
40 (display-lily-init parser)
42 (make-music 'SequentialMusic))
44 test = #(def-music-function (parser location result-info strings) (string? pair?)
45 (display-lily-init parser)
46 (let ((input (car strings))
47 (output (cdr strings)))
48 (set! test-number (1+ test-number))
49 (if (string=? input output)
50 (make-music 'SequentialMusic)
51 (make-music 'SequentialMusic
53 (list (make-music 'EventChord
54 'elements (list (make-music 'BreakEvent
57 (make-music 'EventChord
58 'elements (list (make-music 'SkipEvent
59 'duration (ly:make-duration 0 0 1 1))
60 (make-music 'TextScriptEvent
62 'text (markup #:column (#:simple (format #f "Test #~a "
64 (if (string-null? result-info)
66 (markup #:simple result-info))
67 #:typewriter (lily-string->markup input)
68 #:typewriter (lily-string->markup output)))))))))))
74 texidoc = \markup \column { \line { \typewriter display-lily-music unit tests }
75 \line { Real bugs (regressions) are marked as \bold BUG. }
76 \line { Known bugs are marked as TODO. } }
84 \override StaffSymbol #'line-count = #1
85 %\remove "Staff_symbol_engraver"
86 \remove "Time_signature_engraver"
87 \remove "Clef_engraver"
91 \remove "Bar_number_engraver"
97 \test #"" ##[ { { a b } { c d } } #] % SequentialMusic
98 \test #"" ##[ << { a b } { c d } >> #] % SimultaneousMusic
99 \test #"" ##[ << { a b } \\ { c d } >> #] % VoiceSeparator
102 \test #"" ##[ { ceses ces c cis cisis } #] % NoteEvent
103 \test #"" ##[ { deses des d dis disis } #]
104 \test #"" ##[ { eeses ees e eis eisis } #]
105 \test #"" ##[ { feses fes f fis fisis } #]
106 \test #"" ##[ { geses ges g gis gisis } #]
107 \test #"" ##[ { aeses aes a ais aisis } #]
108 \test #"" ##[ { beses bes b bis bisis } #]
109 \test #"" ##[ { c,, d' } #]
110 \test #"" ##[ { c' d'=' } #]
111 \test #"" ##[ { c! c? } #]
112 \test #"" ##[ r1.*4/3 #] % RestEvent
113 \test #"" ##[ c1\rest #] % RestEvent
114 \test #"" ##[ s2..*3/4 #] % SkipEvent
115 \test #"" ##[ R1.*2/3 #] % MultiMeasureRestMusicGroup, MultiMeasureRestEvent
116 \test #"" ##[ \skip 2.*3/4 #] % SkipMusic
117 \test #"" ##[ < c\1 e\3 >4.*3/4-. #] % EventChord, NoteEvent, StringNumberEvent, ArticulationEvent
120 \test #"" ##[ { \tag #'foo { c4 d } } #]
121 \test #"" ##[ c-\tag #'(foo baz) -^ -. #]
124 \test #"" ##[ { \grace c8 d2 } #] % GraceMusic
125 \test #"" ##[ { \appoggiatura c8 d2 } #]
126 \test #"" ##[ { \acciaccatura c8 d2 } #]
127 \test #"" ##[ { c1 \afterGrace { b,16 c } d2 } #]
130 \test #"" ##[ { \makeClusters { c4 g } } #] % ClusterNoteEvent
133 \test #"" ##[ \figures { < 6 > } #] % BassFigureEvent
134 \test #"" ##[ \figuremode { < 1-- 3- > < 2+ 4++ > < _! 7! > } #]
135 \test #"" ##[ \figuremode { < [6 > < 5] > } #]
138 \test #"" ##[ \lyrics { a b } #]
139 \test #"" ##[ \lyricmode { a -- b } #] % HyphenEvent
140 \test #"" ##[ \lyricmode { a __ b } #] % ExtenderEvent
141 \test #"" ##[ \lyricmode { "a " } #] % LyricEvent
142 \test #"" ##[ \lyricsto "foo" { bla bla } #] % LyricCombineMusic
143 \test #"" ##[ { { c d }
144 \addlyrics { bla bla } } #]
145 \test #"" ##[ \oldaddlyrics { c d }
146 \lyricmode { bla bla } #] % OldLyricCombineMusic
149 \test #"" ##[ \drums { hihat } #]
150 \test #"" ##[ \drummode { hihat4.*3/4 } #]
153 \test #"" ##[ c4 ~ #] % TieEvent
154 \test #"" ##[ c\noBeam #] % BeamForbidEvent
155 \test #"" ##[ c\1 #] % StringNumberEvent
156 \test #"" ##[ { c: c:1 } #] % TremoloEvent
157 \test #"" ##[ { c-^ c^^ c_^ } #] % ArticulationEvent
158 \test #"" ##[ { c-+ c^+ c_+ } #]
159 \test #"" ##[ { c-- c^- c_- } #]
160 \test #"" ##[ { c-| c^| c_| } #]
161 \test #"" ##[ { c-> c^> c_> } #]
162 \test #"" ##[ { c-. c^. c_. } #]
163 \test #"" ##[ { c-_ c^_ c__ } #]
164 \test #"" ##[ { c-\trill c^\trill c_\trill } #]
165 \test #"" ##[ { c-1 c^2 c_3 } #] % FingerEvent
166 \test #"" ##[ { c-"foo" c^"foo" c_"foo" } #] % TextScriptEvent
167 \test #"" ##[ { R1*4 -"foo" R ^"foo" R _"foo" } #] % MultiMeasureTextEvent
168 \test #"" ##[ { c4-\harmonic c^\harmonic c_\harmonic } #] % HarmonicEvent
169 \test #"" ##[ { c-\glissando c^\glissando c_\glissando } #] % GlissandoEvent
170 \test #"" ##[ { c-\arpeggio c^\arpeggio c_\arpeggio } #] % ArpeggioEvent
171 \test #"" ##[ { c\p c^\ff c_\sfz } #] % AbsoluteDynamicEvent
172 \test #"" ##[ { c[ c] c^[ c^] c_[ c_] } #] % BeamEvent
173 \test #"" ##[ { c( c) c^( c^) c_( c_) } #] % SlurEvent
174 \test #"" ##[ { c\< c\! c^\< c^\! c_\< c_\! } #] % CrescendoEvent
175 \test #"" ##[ { c\> c\! c^\> c^\! c_\> c_\! } #] % DecrescendoEvent
176 \test #"" ##[ { c\( c\) c^\( c^\) c_\( c_\) } #] % PhrasingSlurEvent
177 \test #"" ##[ { c\sustainDown c\sustainUp } #] % SustainEvent
178 \test #"" ##[ { c\sostenutoDown c\sostenutoUp } #] % SostenutoEvent
179 \test #"" ##[ { c\melisma c\melismaEnd } #] % ManualMelismaEvent
180 \test #"" ##[ { c\startTextSpan c\stopTextSpan } #] % TextSpanEvent
181 \test #"" ##[ { c\startTrillSpan c\stopTrillSpan } #] % TrillSpanEvent
182 \test #"" ##[ { c \startStaff c \stopStaff } #] % StaffSpanEvent
183 \test #"" ##[ { c\startGroup c\stopGroup c^\startGroup c^\stopGroup c_\startGroup c_\stopGroup } #] % NoteGroupingEvent
184 \test #"" ##[ { c\unaCorda c\treCorde } #] % UnaCordaEvent
185 \test #"" ##[ \breathe #]
186 \test #"" ##[ { c \[ c \] } #] % LigatureEvent
187 \test #"" ##[ \~ #] % PesOrFlexaEvent
189 \test #"" ##[ \break #]
192 \test #"" ##[ \octave a' #] % RelativeOctaveCheck
193 \test #"" ##[ | #] % BarCheck
196 \test #"" ##[ \mark \default #] % MarkEvent
197 \test #"" ##[ \mark "Allegro" #]
198 \test #"" ##[ \tempo 4 = 120 #] % MetronomeChangeEvent
200 %% key, time, clef, bar
201 \test #"" ##[ \key \default #] % KeyChangeEvent
202 \test #"" ##[ \key e \minor #]
203 \test #"" ##[ \clef "bass" #]
204 \test #"" ##[ \clef "french^2" #]
205 \test #"" ##[ \clef "alto_3" #]
206 \test #"" ##[ \time 2/4 #]
207 \test #"" ##[ #(set-time-signature 5 8 '(3 2)) #]
208 \test #"" ##[ \bar "|." #]
211 \test #"" ##[ \autochange { c d } #] % AutoChangeMusic
212 \test #"" ##[ { \change Staff = "up" { c d } } #] % ContextChange
215 \test #"" ##[ \times 2/3 { c8 d e } #] % TimeScaledMusic
216 \test #"" ##[ \times 4/6 { c16 d e f g a } #]
218 %% \relative and \tranpose
219 \test #"NOT A BUG" ##[ \relative c' { c b } #] % RelativeOctaveMusic
220 \test #"NOT A BUG" ##[ \transpose c d { c d } #] % TransposedMusic
223 \test #"" ##[ \repeat volta 2 { c d } #] % VoltaRepeatedMusic
224 \test #"" ##[ \repeat unfold 2 { c d } #] % UnfoldedRepeatedMusic
225 \test #"" ##[ \repeat fold 2 { c d } #] % FoldedRepeatedMusic
226 \test #"" ##[ \repeat percent 2 { c d } #] % PercentRepeatedMusic
227 \test #"" ##[ \repeat tremolo 4 { c16 d } #] % TremoloRepeatedMusic
228 \test #"" ##[ \repeat volta 2 { c4 d } \alternative { { c d } { e f } } #] %
231 \test #"" ##[ \new Staff { c d } #] % ContextSpeccedMusic
232 \test #"" ##[ \context Staff { c d } #]
233 \test #"" ##[ \context Staff = "up" { c d } #]
236 \consists "Timing_engraver"
237 \remove "Clef_engraver"
239 %% Context properties
240 \test #"" ##[ \once \set Score . skipBars = ##t #] % PropertySet
241 \test #"" ##[ \set autoBeaming = ##f #]
242 \test #"" ##[ \unset Score . skipBars #] % PropertyUnset
243 \test #"" ##[ \unset autoBeaming #]
245 \test #"" ##[ \override Staff . Stem #'thickness = #4.0 #] % OverrideProperty
246 \test #"" ##[ \once \override Beam #'thickness = #0.6 #]
247 \test #"" ##[ \revert Staff . Stem #'thickness #] % RevertProperty
248 \test #"" ##[ \revert Beam #'thickness #]
253 \test #"" ##[ \partial 2 #]
254 \test #"" ##[ \partial 8. #]
255 \test #"TODO? exotic durations in \\partial" ##[ \partial 4*2/3 #]
258 \test #"" ##[ \partcombine { c e }
259 { d f } #] % PartCombineMusic UnrelativableMusic
262 \test #"" ##[ \cueDuring #"foo" #1 { c d } #]
263 \test #"" ##[ \quoteDuring #"foo" { c d } #]