]> git.donarmstrong.com Git - lilypond.git/blob - input/regression/display-lily-tests.ly
print display-lily-tests results with ly:progress
[lilypond.git] / input / regression / display-lily-tests.ly
1 \version "2.11.6"
2
3 #(use-modules (srfi srfi-13)
4               (ice-9 format))
5
6 %%%
7 %%% Testing utilities
8 %%%
9
10 #(define (parse-lily-and-compute-lily-string chr port)
11   (let ((lily-string (call-with-output-string
12                       (lambda (out)
13                         (do ((c (read-char port) (read-char port)))
14                             ((and (char=? c #\#)
15                                   (char=? (peek-char port) #\]))
16                              (read-char port))
17                           (display c out))))))
18     `(let* ((parser-clone (ly:parser-clone parser))
19             (input-str (string-trim-both ,lily-string))
20             (music (car (ly:music-property (parse-string-result input-str
21                                                                 parser-clone)
22                                            'elements)))
23             (result-str (string-trim-both (music->lily-string music parser-clone))))
24        (cons input-str result-str))))
25
26 #(read-hash-extend #\[ parse-lily-and-compute-lily-string) %{ ] %}
27
28 #(define (lily-string->markup str)
29    (make-column-markup (string-split str #\NewLine)))
30
31 #(define test-function
32   (let ((test-number 0))
33    (lambda (parser location result-info strings)
34     (let ((input (car strings))
35          (output (cdr strings)))
36      (set! test-number (1+ test-number))
37      (if (not (equal? input output))
38          (ly:progress "Test ~a unequal: ~a. \nin  = ~a\nout = ~a\n"
39           test-number
40           (if result-info
41               result-info "BUG")
42           input output))
43
44
45      (make-music 'SequentialMusic 'void #t)
46     
47    ))))
48           
49 test = 
50 #(define-music-function (parser location result-info strings) (string? pair?)
51    (test-function parser location result-info strings))
52
53 %%%
54 %%% Tests
55 %%%
56 \header {
57   texidoc = "This is a test of the display-lily-music unit. Problems are reported on the
58 stderr of this run." 
59 }
60
61 \layout {
62   raggedright = ##t 
63   indent = 0\cm
64   \context {
65     \Staff
66     \override StaffSymbol #'line-count = #1
67     \remove "Time_signature_engraver"
68     \remove "Clef_engraver"
69   }
70   \context {
71     \Score
72     \remove "Bar_number_engraver"
73   }
74 }
75
76 %% Sequential music
77 \test "" ##[ { { a b } { c d } } #]             % SequentialMusic
78 \test "" ##[ << { a b } { c d } >> #]           % SimultaneousMusic
79 \test "" ##[ << { a b } \\ { c d } >> #]        % VoiceSeparator
80
81 %% Chords and Notes
82 \test "" ##[ { ceses ces c cis cisis } #]       % NoteEvent
83 \test "" ##[ { deses des d dis disis } #]
84 \test "" ##[ { eeses ees e eis eisis } #]
85 \test "" ##[ { feses fes f fis fisis } #]
86 \test "" ##[ { geses ges g gis gisis } #]
87 \test "" ##[ { aeses aes a ais aisis } #]
88 \test "" ##[ { beses bes b bis bisis } #]
89 \test "" ##[ { c,, d' } #]
90 \test "" ##[ { c' d'=' } #]
91 \test "" ##[ { c! c? } #]
92 \test "" ##[ r1.*4/3 #]         % RestEvent
93 \test "" ##[ c1\rest #]         % RestEvent
94 \test "" ##[ s2..*3/4 #]                % SkipEvent
95 \test "" ##[ R1.*2/3 #]         % MultiMeasureRestMusicGroup, MultiMeasureRestEvent
96 \test "" ##[ \skip 2.*3/4 #]            % SkipMusic
97 \test "" ##[ < c\1 e\3 >4.*3/4-. #]     % EventChord, NoteEvent, StringNumberEvent, ArticulationEvent
98
99 %% tags
100 \test "" ##[ { \tag #'foo { c4 d } } #]
101 \test "" ##[ c-\tag #'foo -\tag #'baz -^ -. #]
102
103 %% Graces
104 \test "" ##[ { \grace c8 d2 } #]                        % GraceMusic
105 \test "" ##[ { \appoggiatura c8 d2 } #]
106 \test "" ##[ { \acciaccatura c8 d2 } #]
107 \test "" ##[ { c1 \afterGrace { b,16 c } d2 } #]
108
109 %% Clusters
110 \test "" ##[ { \makeClusters { c4 g } } #]              % ClusterNoteEvent
111
112 %% Figured bass
113 \test "" ##[ \figures { < 6 > } #]                      % BassFigureEvent
114 \test "" ##[ \figuremode { < 1-- 3- > < 2+ 4++ > < _! 7! > } #]
115 \test "" ##[ \figuremode { < [6 > < 5] > } #]
116
117 %% Lyrics
118 \test "" ##[ \lyrics { a b } #]
119 \test "" ##[ \lyricmode { a --  b } #]          % HyphenEvent
120 \test "" ##[ \lyricmode { a __  b } #]          % ExtenderEvent
121 \test "" ##[ \lyricmode { "a " } #]                     % LyricEvent
122 \test "" ##[ \lyricsto "foo" { bla bla } #]             % LyricCombineMusic
123 \test "" ##[ { { c d }
124   \addlyrics { bla bla } } #]
125
126 %% Drums
127 \test "" ##[ \drums { hihat } #]
128 \test "" ##[ \drummode { hihat4.*3/4 } #]
129
130 %% Expressive marks
131 \test "" ##[ c4 ~ #]                                    % TieEvent
132 \test "" ##[ c\noBeam #]                                % BeamForbidEvent
133 \test "" ##[ c\1 #]                                     % StringNumberEvent
134 \test "" ##[ { c:  c:1  } #]                            % TremoloEvent
135 \test "" ##[ { c-^  c^^  c_^  } #]                      % ArticulationEvent
136 \test "" ##[ { c-+  c^+  c_+  } #]
137 \test "" ##[ { c--  c^-  c_-  } #]
138 \test "" ##[ { c-|  c^|  c_|  } #]
139 \test "" ##[ { c->  c^>  c_>  } #]
140 \test "" ##[ { c-.  c^.  c_.  } #]
141 \test "" ##[ { c-_  c^_  c__  } #]
142 \test "" ##[ { c-\trill  c^\trill  c_\trill  } #]
143 \test "" ##[ { c-1  c^2  c_3  } #]                      % FingerEvent
144 \test "" ##[ { c-"foo"  c^"foo"  c_"foo"  } #]  % TextScriptEvent
145 \test "" ##[ { R1*4-"foo"  R^"foo"  R_"foo"  } #]       % MultiMeasureTextEvent
146 \test "" ##[ { c4-\harmonic  c^\harmonic  c_\harmonic  } #]     % HarmonicEvent
147 \test "" ##[ { c-\glissando  c^\glissando  c_\glissando  } #] % GlissandoEvent
148 \test "" ##[ { c-\arpeggio  c^\arpeggio  c_\arpeggio  } #]      % ArpeggioEvent
149 \test "" ##[ { c\p  c^\ff  c_\sfz  } #]                 % AbsoluteDynamicEvent
150 \test "" ##[ { c[  c]  c^[  c^]  c_[  c_]  } #]         % BeamEvent
151 \test "" ##[ { c(  c)  c^(  c^)  c_(  c_)  } #]         % SlurEvent
152 \test "" ##[ { c\<  c\!  c^\<  c^\!  c_\<  c_\!  } #]   % CrescendoEvent
153 \test "" ##[ { c\>  c\!  c^\>  c^\!  c_\>  c_\!  } #]   % DecrescendoEvent
154 \test "" ##[ { c\(  c\)  c^\(  c^\)  c_\(  c_\)  } #]   % PhrasingSlurEvent
155 \test "" ##[ { c\sustainDown  c\sustainUp  } #] % SustainEvent
156 \test "" ##[ { c\sostenutoDown  c\sostenutoUp  } #] % SostenutoEvent
157 \test "" ##[ \melisma #]
158 \test "" ##[ \melismaEnd #]
159 \test "" ##[ { c\startTextSpan  c\stopTextSpan  } #] % TextSpanEvent
160 \test "" ##[ { c\startTrillSpan  c\stopTrillSpan  } #] % TrillSpanEvent
161 \test "" ##[ { c \startStaff c \stopStaff } #]  % StaffSpanEvent
162 \test "" ##[ { c\startGroup  c\stopGroup  c^\startGroup  c^\stopGroup  c_\startGroup  c_\stopGroup  } #] % NoteGroupingEvent
163 \test "" ##[ { c\unaCorda  c\treCorde  } #] % UnaCordaEvent
164 \test "" ##[ \breathe #]
165 \test "" ##[ { c \[ c \] } #]                   % LigatureEvent
166 \test "" ##[ \~ #]                                      % PesOrFlexaEvent
167
168 \test "" ##[ \break #]
169 \test "" ##[ \noBreak #]
170 \test "" ##[ \pageBreak #]
171 \test "" ##[ \noPageBreak #]
172 \test "" ##[ \pageTurn #]
173 \test "" ##[ \noPageTurn #]
174
175 %% Checks
176 \test "" ##[ \octave a' #]                              % RelativeOctaveCheck
177 \test "" ##[ | #]                                       % BarCheck
178
179 %% Marks
180 \test "" ##[ \mark \default #]                  % MarkEvent
181 \test "" ##[ \mark "Allegro" #]
182 \test "" ##[ \tempo 4 = 120 #]                  % MetronomeChangeEvent
183
184 %% key, time, clef, bar
185 \test "" ##[ \key \default #]                   % KeyChangeEvent
186 \test "" ##[ \key e \minor #]
187 \test "" ##[ \clef "bass" #]
188 \test "" ##[ \clef "french^2" #]
189 \test "" ##[ \clef "alto_3" #]
190 \test "" ##[ \time 2/4 #]
191 \test "" ##[ #(set-time-signature 5 8 '(3 2)) #]
192 \test "" ##[ \bar "|." #]
193
194 %% staff switches
195 \test "" ##[ \autochange { c d } #]                     % AutoChangeMusic
196 \test "" ##[ { \change Staff = "up" { c d } } #]        % ContextChange
197
198 %% Tuplets
199 \test "" ##[ \times 2/3 { c8 d e } #]                           % TimeScaledMusic
200 \test "" ##[ \times 4/6 { c16 d e f g a } #]
201 %}
202 %% \relative and \tranpose
203 \test #"NOT A BUG" ##[ \relative c' { c b } #]  % RelativeOctaveMusic
204 \test #"NOT A BUG" ##[ \transpose c d { c d } #]        % TransposedMusic
205 %}
206 %% Repeats
207 \test "" ##[ \repeat volta 2 { c d } #]         % VoltaRepeatedMusic
208 \test "" ##[ \repeat unfold 2 { c d } #]                % UnfoldedRepeatedMusic
209 \test "" ##[ \repeat fold 2 { c d } #]          % FoldedRepeatedMusic
210 \test "" ##[ \repeat percent 2 { c d } #]               % PercentRepeatedMusic
211 \test "" ##[ \repeat tremolo 4 { c16 d } #]             % TremoloRepeatedMusic
212 \test "" ##[ \repeat volta 2 { c4 d } \alternative { { c d } { e f } } #] % 
213
214 %% Context creation
215 \test "" ##[ \new Staff { c d } #]                      % ContextSpeccedMusic
216 \test "" ##[ \new Staff = "up" { c d } #]                       % ContextSpeccedMusic
217 \test "" ##[ \context Staff { c d } #]
218 \test "" ##[ \context Staff = "up" { c d } #]
219 \test "" ##[
220 \new Staff \with {
221   \consists "Timing_engraver"
222   \remove "Clef_engraver"
223 } { c d } #]
224 %% Context properties
225 \test "" ##[ \once \set Score . skipBars = ##t #]       % PropertySet
226 \test "" ##[ \set autoBeaming = ##f #]
227 \test "" ##[ \unset Score . skipBars #]         % PropertyUnset
228 \test "" ##[ \unset autoBeaming #]
229 %% Layout properties
230 \test "" ##[ \override Staff . Stem #'thickness = #4.0 #]       % OverrideProperty
231 \test "" ##[ \once \override Beam #'thickness = #0.6 #]
232 \test "" ##[ \revert Staff . Stem #'thickness #]        % RevertProperty
233 \test "" ##[ \revert Beam #'thickness #]
234
235 %% \applyOutput
236 \test "" ##[ \applyOutput #'Foo #(lambda (arg) (list)) #]
237 %% \applyContext
238 \test "" ##[ \applyContext #(lambda (arg) (list)) #]
239
240 %% \partial
241 \test "" ##[ \partial 2 #]
242 \test "" ##[ \partial 8. #]
243 \test #"TODO? exotic durations in \\partial" ##[ \partial 4*2/3 #]
244
245 %% \partcombine
246 \test "" ##[ \partcombine { c e }
247 { d f } #]                                              % PartCombineMusic UnrelativableMusic
248
249 %% Cue notes
250 \test "" ##[ \cueDuring #"foo" #1 { c d } #]
251 \test "" ##[ \quoteDuring #"foo" { c d } #]
252
253
254 %% end test.
255
256 #(read-hash-extend #\[ #f) %{ ] %}